Commit 036a1810 authored by Stefan Behnel's avatar Stefan Behnel

merged in latest cython-unstable

parents f17a1512 bd1645a8
...@@ -1811,12 +1811,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1811,12 +1811,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
Naming.builtins_cname, Naming.builtins_cname,
code.error_goto(self.pos))) code.error_goto(self.pos)))
if Options.embed: if Options.embed:
__main__cname = code.globalstate.get_py_string_const( __main__name = code.globalstate.get_py_string_const(
EncodedString("__main__"), identifier=True) EncodedString("__main__"), identifier=True)
code.putln( code.putln(
'if (__Pyx_SetAttrString(%s, "__name__", %s) < 0) %s;' % ( 'if (__Pyx_SetAttrString(%s, "__name__", %s) < 0) %s;' % (
env.module_cname, env.module_cname,
__main__cname, __main__name.cname,
code.error_goto(self.pos))) code.error_goto(self.pos)))
if Options.pre_import is not None: if Options.pre_import is not None:
code.putln( code.putln(
......
...@@ -1614,6 +1614,9 @@ def p_statement(s, ctx, first_statement = 0): ...@@ -1614,6 +1614,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