[pypy-commit] pypy app_main-refactor: make sure to import CPython's ctypes, not pypy's
antocuni
noreply at buildbot.pypy.org
Sun Jun 10 17:04:52 CEST 2012
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: app_main-refactor
Changeset: r55545:d2dfe5495d04
Date: 2012-06-10 16:53 +0200
http://bitbucket.org/pypy/pypy/changeset/d2dfe5495d04/
Log: make sure to import CPython's ctypes, not pypy's
diff --git a/pypy/translator/goal/app_main.py b/pypy/translator/goal/app_main.py
--- a/pypy/translator/goal/app_main.py
+++ b/pypy/translator/goal/app_main.py
@@ -250,7 +250,15 @@
except ImportError:
if sys.version_info < (2, 7):
return
- import ctypes # HACK: while running on top of CPython
+ # HACK: while running on top of CPython, and make sure to import
+ # CPython's ctypes (because at this point sys.path has already been
+ # set to the pypy one)
+ pypy_path = sys.path
+ try:
+ sys.path = sys.cpython_path
+ import ctypes
+ finally:
+ sys.path = pypy_path
set_file_encoding = ctypes.pythonapi.PyFile_SetEncodingAndErrors
set_file_encoding.argtypes = [ctypes.py_object, ctypes.c_char_p, ctypes.c_char_p]
else:
@@ -751,6 +759,7 @@
sys.pypy_version_info = PYPY_VERSION
sys.pypy_find_executable = pypy_find_executable
sys.pypy_find_stdlib = pypy_find_stdlib
+ sys.cpython_path = sys.path[:]
os = nanos.os_module_for_testing
try:
sys.exit(int(entry_point(sys.argv[0], sys.argv[1:], os)))
More information about the pypy-commit
mailing list