From: Stefan Behnel Date: Sat, 20 Mar 2010 12:37:11 +0000 (+0100) Subject: merged in latest cython-devel X-Git-Tag: 0.13.beta0~2^2~93 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=02fa6935e7a06cf2420277cd2e94784df5eaedfe;p=cython.git merged in latest cython-devel --- 02fa6935e7a06cf2420277cd2e94784df5eaedfe diff --cc Cython/Compiler/ModuleNode.py index 85b0b178,72229376..6b859990 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@@ -1671,16 -1660,10 +1658,12 @@@ class ModuleNode(Nodes.Node, Nodes.Bloc code.putln("__pyx_refnanny = __Pyx_RefNanny->SetupContext(\"%s\", __LINE__, __FILE__);"% header3) code.putln("#endif") - self.generate_filename_init_call(code) - code.putln("%s = PyTuple_New(0); %s" % (Naming.empty_tuple, code.error_goto_if_null(Naming.empty_tuple, self.pos))); - code.putln("#if PY_MAJOR_VERSION < 3"); - code.putln("%s = PyString_FromStringAndSize(\"\", 0); %s" % (Naming.empty_bytes, code.error_goto_if_null(Naming.empty_bytes, self.pos))); - code.putln("#else"); - code.putln("%s = PyBytes_FromStringAndSize(\"\", 0); %s" % (Naming.empty_bytes, code.error_goto_if_null(Naming.empty_bytes, self.pos))); - code.putln("#endif"); + code.putln("%s = __Pyx_PyBytes_FromStringAndSize(\"\", 0); %s" % (Naming.empty_bytes, code.error_goto_if_null(Naming.empty_bytes, self.pos))); + + code.putln("#ifdef %s_USED" % Naming.binding_cfunc) + code.putln("if (%s_init() < 0) %s" % (Naming.binding_cfunc, code.error_goto(self.pos))) + code.putln("#endif") code.putln("/*--- Library function declarations ---*/") env.generate_library_function_declarations(code) diff --cc Cython/Compiler/Parsing.py index c9583bbe,3ee56367..63b85e5a --- a/Cython/Compiler/Parsing.py +++ b/Cython/Compiler/Parsing.py @@@ -1379,9 -1331,15 +1379,15 @@@ def p_except_clause(s) exc_value = None if s.sy != ':': exc_type = p_simple_expr(s) - if s.sy == ',': + if s.sy == ',' or (s.sy == 'IDENT' and s.systring == 'as'): s.next() exc_value = p_simple_expr(s) + elif s.sy == 'IDENT' and s.systring == 'as': + # Py3 syntax requires a name here + s.next() + pos2 = s.position() + name = p_ident(s) + exc_value = ExprNodes.NameNode(pos2, name = name) body = p_suite(s) return Nodes.ExceptClauseNode(pos, pattern = exc_type, target = exc_value, body = body) @@@ -2135,10 -2089,17 +2141,18 @@@ def p_c_arg_decl(s, ctx, in_pyfunc, cme pos = s.position() not_none = 0 default = None + annotation = None - base_type = p_c_base_type(s, cmethod_flag, nonempty = nonempty) + if s.in_python_file: + # empty type declaration + base_type = Nodes.CSimpleBaseTypeNode(pos, + name = None, module_path = [], + is_basic_c_type = 0, signed = 0, + complex = 0, longness = 0, + is_self_arg = cmethod_flag, templates = None) + else: + base_type = p_c_base_type(s, cmethod_flag, nonempty = nonempty) declarator = p_c_declarator(s, ctx, nonempty = nonempty) - if s.sy == 'not': + if s.sy == 'not' and not s.in_python_file: s.next() if s.sy == 'IDENT' and s.systring == 'None': s.next()