Permalink
Browse files

Merge pull request #188 from pv/pyxbuild-fixes

pyximport: fix a bug crashing other processes
  • Loading branch information...
2 parents 7845d15 + e2f2580 commit e68266894c83ab697d80ed568d44018b394b11e5 @scoder scoder committed Mar 4, 2013
Showing with 11 additions and 0 deletions.
  1. +11 −0 pyximport/pyxbuild.py
View
@@ -124,6 +124,17 @@ def pyx_to_dll(filename, ext = None, force_rebuild = 0,
basename + '.reload%s'%count)
try:
import shutil # late import / reload_support is: debugging
+ try:
+ # Try to unlink first --- if the .so file
+ # is mmapped by another process,
+ # overwriting its contents corrupts the
+ # loaded image (on Linux) and crashes the
+ # other process. On Windows, unlinking an
+ # open file just fails.
+ if os.path.isfile(r_path):
+ os.unlink(r_path)
+ except OSError:
+ continue
shutil.copy2(org_path, r_path)
so_path = r_path
except IOError:

0 comments on commit e682668

Please sign in to comment.