[pypy-svn] r74532 - in pypy/trunk/pypy/rpython: . module test
afa at codespeak.net
afa at codespeak.net
Mon May 17 17:47:22 CEST 2010
Author: afa
Date: Mon May 17 17:47:20 2010
New Revision: 74532
Modified:
pypy/trunk/pypy/rpython/extfunc.py
pypy/trunk/pypy/rpython/module/ll_os.py
pypy/trunk/pypy/rpython/test/test_extfuncregister.py
Log:
hasattr(os, 'kill') is not enough to disable the function with CPython2.7 on Windows,
which provides os.kill, with a special implementation of course.
Add an additional "condition" parameter.
Modified: pypy/trunk/pypy/rpython/extfunc.py
==============================================================================
--- pypy/trunk/pypy/rpython/extfunc.py (original)
+++ pypy/trunk/pypy/rpython/extfunc.py Mon May 17 17:47:20 2010
@@ -58,13 +58,16 @@
return method
return decorator
-def registering_if(ns, name):
+def registering_if(ns, name, condition=True):
try:
func = getattr(ns, name)
except AttributeError:
- return lambda method: None
- else:
+ condition = False
+
+ if condition:
return registering(func)
+ else:
+ return lambda method: None
class LazyRegisteringMeta(type):
def __new__(self, _name, _type, _vars):
Modified: pypy/trunk/pypy/rpython/module/ll_os.py
==============================================================================
--- pypy/trunk/pypy/rpython/module/ll_os.py (original)
+++ pypy/trunk/pypy/rpython/module/ll_os.py Mon May 17 17:47:20 2010
@@ -1329,7 +1329,7 @@
return extdef([int], int, llimpl=umask_llimpl,
export_name="ll_os.ll_os_umask")
- @registering_if(os, 'kill')
+ @registering_if(os, 'kill', sys.platform != 'win32')
def register_os_kill(self):
os_kill = self.llexternal('kill', [rffi.PID_T, rffi.INT],
rffi.INT)
Modified: pypy/trunk/pypy/rpython/test/test_extfuncregister.py
==============================================================================
--- pypy/trunk/pypy/rpython/test/test_extfuncregister.py (original)
+++ pypy/trunk/pypy/rpython/test/test_extfuncregister.py Mon May 17 17:47:20 2010
@@ -105,3 +105,9 @@
assert bar is None
+ @registering_if(A, 'f', False)
+ def baz():
+ pass
+
+ assert baz is None
+
More information about the Pypy-commit
mailing list