Commits

Amaury Forgeot d'Arc  committed ef8ae87

Fix when bin/py.py calls posix.fork() and the cpyext module is loaded.

  • Participants
  • Parent commits 4053bfe
  • Branches kill-faking

Comments (0)

Files changed (1)

File pypy/module/cpyext/api.py

                                TP, compilation_info=eci)
         globals()['va_get_%s' % name_no_star] = func
 
-def setup_init_functions(eci):
+def setup_init_functions(eci, translating):
     init_buffer = rffi.llexternal('init_bufferobject', [], lltype.Void,
                                   compilation_info=eci, _nowrapper=True)
     init_pycobject = rffi.llexternal('init_pycobject', [], lltype.Void,
         lambda space: init_capsule(),
     ])
     from pypy.module.posix.interp_posix import add_fork_hook
-    reinit_tls = rffi.llexternal('PyThread_ReInitTLS', [], lltype.Void,
-                                 compilation_info=eci)    
+    if translating:
+        reinit_tls = rffi.llexternal('PyThread_ReInitTLS', [], lltype.Void,
+                                     compilation_info=eci)
+    else:
+        reinit_tls = rffi.llexternal('PyPyThread_ReInitTLS', [], lltype.Void,
+                                     compilation_info=eci)
     add_fork_hook('child', reinit_tls)
 
 def init_function(func):
 
     setup_va_functions(eci)
 
-    setup_init_functions(eci)
+    setup_init_functions(eci, translating=False)
     return modulename.new(ext='')
 
 def generate_macros(export_symbols, rename=True, do_deref=True):
         deco = entrypoint("cpyext", func.argtypes, name, relax=True)
         deco(func.get_wrapper(space))
 
-    setup_init_functions(eci)
+    setup_init_functions(eci, translating=True)
     trunk_include = pypydir.dirpath() / 'include'
     copy_header_files(trunk_include)