Commit bd1645a8 authored by Stefan Behnel's avatar Stefan Behnel

merged in latest cython-devel

parents 1e544e4d 14acb834
...@@ -1576,6 +1576,9 @@ def p_statement(s, ctx, first_statement = 0): ...@@ -1576,6 +1576,9 @@ def p_statement(s, ctx, first_statement = 0):
decorators = p_decorators(s) decorators = p_decorators(s)
if s.sy not in ('def', 'cdef', 'cpdef'): if s.sy not in ('def', 'cdef', 'cpdef'):
s.error("Decorators can only be followed by functions ") s.error("Decorators can only be followed by functions ")
elif s.sy == 'pass' and cdef_flag:
# empty cdef block
return p_pass_statement(s, with_newline = 1)
overridable = 0 overridable = 0
if s.sy == 'cdef': if s.sy == 'cdef':
......
...@@ -275,8 +275,14 @@ class BuiltinObjectType(PyObjectType): ...@@ -275,8 +275,14 @@ class BuiltinObjectType(PyObjectType):
base_type = None base_type = None
module_name = '__builtin__' module_name = '__builtin__'
alternative_name = None # used for str/bytes duality
def __init__(self, name, cname): def __init__(self, name, cname):
self.name = name self.name = name
if name == 'str':
self.alternative_name = 'bytes'
elif name == 'bytes':
self.alternative_name = 'str'
self.cname = cname self.cname = cname
self.typeptr_cname = "&" + cname self.typeptr_cname = "&" + cname
...@@ -293,7 +299,9 @@ class BuiltinObjectType(PyObjectType): ...@@ -293,7 +299,9 @@ class BuiltinObjectType(PyObjectType):
def assignable_from(self, src_type): def assignable_from(self, src_type):
if isinstance(src_type, BuiltinObjectType): if isinstance(src_type, BuiltinObjectType):
return src_type.name == self.name return src_type.name == self.name or (
src_type.name == self.alternative_name and
src_type.name is not None)
else: else:
return not src_type.is_extension_type return not src_type.is_extension_type
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment