diff options
author | Robert Bradshaw <robertwb@gmail.com> | 2014-08-20 23:53:00 -0700 |
---|---|---|
committer | Robert Bradshaw <robertwb@gmail.com> | 2014-08-20 23:53:00 -0700 |
commit | c79d2aa87cc159b05e009d458e4d4f81d5fee214 (patch) | |
tree | d50a32b72fc12f5afb51e0e5b7c834b4f007e249 | |
parent | 0c23fb81176e8cacb13d7867fb73c9a0ee8327d6 (diff) | |
download | cython-c79d2aa87cc159b05e009d458e4d4f81d5fee214.tar.gz |
Allow staticmethod in non-decorator contexts.
-rw-r--r-- | Cython/Compiler/ParseTreeTransforms.py | 2 | ||||
-rw-r--r-- | tests/run/staticmethod.pyx | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/Cython/Compiler/ParseTreeTransforms.py b/Cython/Compiler/ParseTreeTransforms.py index 7ebec5472..d3bee361b 100644 --- a/Cython/Compiler/ParseTreeTransforms.py +++ b/Cython/Compiler/ParseTreeTransforms.py @@ -2555,7 +2555,7 @@ class TransformBuiltinMethods(EnvTransform): node = ExprNodes.StringNode(node.pos, value=EncodedString(version)) elif attribute == u'NULL': node = ExprNodes.NullNode(node.pos) - elif attribute in (u'set', u'frozenset'): + elif attribute in (u'set', u'frozenset', u'staticmethod'): node = ExprNodes.NameNode(node.pos, name=EncodedString(attribute), entry=self.current_env().builtin_scope().lookup_here(attribute)) elif PyrexTypes.parse_basic_type(attribute): diff --git a/tests/run/staticmethod.pyx b/tests/run/staticmethod.pyx index c3d6b7434..cec047601 100644 --- a/tests/run/staticmethod.pyx +++ b/tests/run/staticmethod.pyx @@ -120,3 +120,12 @@ cdef class ArgsKwargs(object): (1, 2, ('a', 3)) """ return args + tuple(sorted(kwargs.items())) + +class StaticmethodSubclass(staticmethod): + """ + >>> s = StaticmethodSubclass(None) + >>> s.is_subtype() + True + """ + def is_subtype(self): + return isinstance(self, staticmethod) |