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)
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)
pos = s.position()
not_none = 0
default = None
- base_type = p_c_base_type(s, cmethod_flag, nonempty = nonempty)
+ annotation = None
+ 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()