Skip to content

Commit a2a5147

Browse files
authored
[mypyc] Don't crash on --cache-dir=/dev/null and the like (#8101)
1 parent 6a83e71 commit a2a5147

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

mypyc/emitmodule.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,11 +336,16 @@ def write_cache(
336336
st = result.graph[id]
337337

338338
meta_path, _, _ = get_cache_names(id, st.xpath, result.manager.options)
339+
# If the metadata isn't there, skip writing the cache.
340+
try:
341+
meta_data = result.manager.metastore.read(meta_path)
342+
except IOError:
343+
continue
339344

340345
newpath = get_state_ir_cache_name(st)
341346
ir_data = {
342347
'ir': module.serialize(),
343-
'meta_hash': compute_hash(result.manager.metastore.read(meta_path)),
348+
'meta_hash': compute_hash(meta_data),
344349
'src_hashes': hashes[group_map[id]],
345350
}
346351

0 commit comments

Comments
 (0)