[tor-commits] [stem/master] Py_GetArgcArgv unavailable with pypy
atagar at torproject.org
atagar at torproject.org
Sun Jan 20 04:55:47 UTC 2013
commit 80f11181966c5390a0aabbb531c20bbcd06a3860
Author: Damian Johnson <atagar at torproject.org>
Date: Sat Jan 19 20:51:12 2013 -0800
Py_GetArgcArgv unavailable with pypy
Peer reports that stem fails with an AttributeError on pypy. Unsurprisingly
this is in the process renaming voodoo - adding a try/catch to make this more
relient.
Traceback (most recent call last):
File "app_main.py", line 51, in run_toplevel
File "first_pass.py", line 62, in <module>
for router in parse_file(consensus_file):
File "stem/descriptor/__init__.py", line 94, in parse_file
import stem.descriptor.server_descriptor
File "stem/descriptor/server_descriptor.py", line 40, in <module>
import stem.version
File "stem/version.py", line 65, in <module>
import stem.util.system
File "stem/util/system.py", line 74, in <module>
Py_GetArgcArgv = ctypes.pythonapi.Py_GetArgcArgv
File "/usr/lib/pypy/lib-python/2.7/ctypes/__init__.py", line 371, in
__getattr__
func = self.__getitem__(name)
File "/usr/lib/pypy/lib-python/2.7/ctypes/__init__.py", line 376, in
__getitem__
func = self._FuncPtr((name_or_ordinal, self))
File "/usr/lib/pypy/lib_pypy/_ctypes/function.py", line 250, in __init__
ptr = self._getfuncptr([], ctypes.c_int)
File "/usr/lib/pypy/lib_pypy/_ctypes/function.py", line 421, in _getfuncptr
self._ptr = cdll.getfunc(self.name, ffi_argtypes, ffi_restype)
AttributeError: No symbol Py_GetArgcArgv found in library <None>
---
stem/util/system.py | 21 +++++++++++++++------
1 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/stem/util/system.py b/stem/util/system.py
index 2b46dad..4f9ba29 100644
--- a/stem/util/system.py
+++ b/stem/util/system.py
@@ -71,12 +71,18 @@ PR_SET_NAME = 15
argc_t = ctypes.POINTER(ctypes.c_char_p)
-Py_GetArgcArgv = ctypes.pythonapi.Py_GetArgcArgv
-Py_GetArgcArgv.restype = None
-Py_GetArgcArgv.argtypes = [
- ctypes.POINTER(ctypes.c_int),
- ctypes.POINTER(argc_t),
-]
+# The following can fail with pypy...
+# AttributeError: No symbol Py_GetArgcArgv found in library <None>
+
+try:
+ Py_GetArgcArgv = ctypes.pythonapi.Py_GetArgcArgv
+ Py_GetArgcArgv.restype = None
+ Py_GetArgcArgv.argtypes = [
+ ctypes.POINTER(ctypes.c_int),
+ ctypes.POINTER(argc_t),
+ ]
+except:
+ Py_GetArgcArgv = None
# This is both a cache for get_process_name() and tracks what we've changed our
# process name to.
@@ -766,6 +772,9 @@ def _set_argv(process_name):
strcpy(argv[0], "new_name");
"""
+ if Py_GetArgcArgv is None:
+ return
+
global _PROCESS_NAME
# both gets the current process name and initializes _MAX_NAME_LENGTH
More information about the tor-commits
mailing list