[pypy-svn] r7397 - in pypy/trunk/src/pypy: annotation translator
mwh at codespeak.net
mwh at codespeak.net
Thu Nov 18 18:31:48 CET 2004
Author: mwh
Date: Thu Nov 18 18:31:48 2004
New Revision: 7397
Modified:
pypy/trunk/src/pypy/annotation/model.py
pypy/trunk/src/pypy/annotation/unaryop.py
pypy/trunk/src/pypy/translator/genc.py
Log:
Some nasty and probably wrong hacks around the area we call
'staticmethods'
Modified: pypy/trunk/src/pypy/annotation/model.py
==============================================================================
--- pypy/trunk/src/pypy/annotation/model.py (original)
+++ pypy/trunk/src/pypy/annotation/model.py Thu Nov 18 18:31:48 2004
@@ -148,7 +148,7 @@
def __init__(self, callables):
# callables is a dictionary containing concrete python
# callable objects as keys and - in the case of a method -
- # the value contains the classdef (see SomeMethod above)
+ # the value contains the classdef (see SomeMethod below)
self.callables = callables
if len(callables) == 1:
self.const, = callables
@@ -229,7 +229,7 @@
result = SomeDict({}, items)
elif ishashable(x) and x in BUILTIN_FUNCTIONS:
result = SomeBuiltin(BUILTIN_FUNCTIONS[x])
- elif callable(x):
+ elif callable(x) or isinstance(x, staticmethod): # XXX
if hasattr(x, '__self__') and x.__self__ is not None:
s_self = immutablevalue(x.__self__)
del s_self.const # stop infinite recursion getattr<->immutablevalue
Modified: pypy/trunk/src/pypy/annotation/unaryop.py
==============================================================================
--- pypy/trunk/src/pypy/annotation/unaryop.py (original)
+++ pypy/trunk/src/pypy/annotation/unaryop.py Thu Nov 18 18:31:48 2004
@@ -179,6 +179,8 @@
print ("!!! rebinding an already bound"
" method %r with %r" % (func, value))
d[func] = classdef
+ elif isinstance(func, staticmethod):
+ d[func.__get__(43)] = value
else:
d[func] = value
return SomeCallable(d)
Modified: pypy/trunk/src/pypy/translator/genc.py
==============================================================================
--- pypy/trunk/src/pypy/translator/genc.py (original)
+++ pypy/trunk/src/pypy/translator/genc.py Thu Nov 18 18:31:48 2004
@@ -218,6 +218,9 @@
continue
# XXX some __NAMES__ are important... nicer solution sought
#raise Exception, "unexpected name %r in class %s"%(key, cls)
+ if isinstance(value, staticmethod) and value.__get__(1) not in self.translator.flowgraphs and self.translator.frozen:
+ print value
+ continue
if isinstance(value, FunctionType) and value not in self.translator.flowgraphs and self.translator.frozen:
print value
continue
More information about the Pypy-commit
mailing list