Commit 0663454f authored by Stefan Behnel's avatar Stefan Behnel

fix unused arguments warning for tp_new() functions without base type

parent 668a2d85
...@@ -991,11 +991,18 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -991,11 +991,18 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
have_entries, (py_attrs, py_buffers, memoryview_slices) = \ have_entries, (py_attrs, py_buffers, memoryview_slices) = \
scope.get_refcounted_entries(include_weakref=True) scope.get_refcounted_entries(include_weakref=True)
new_func_entry = scope.lookup_here("__new__")
if base_type or (new_func_entry and new_func_entry.is_special
and not new_func_entry.trivial_signature):
unused_marker = ''
else:
unused_marker = 'CYTHON_UNUSED '
need_self_cast = type.vtabslot_cname or have_entries need_self_cast = type.vtabslot_cname or have_entries
code.putln("") code.putln("")
code.putln( code.putln(
"static PyObject *%s(PyTypeObject *t, PyObject *a, PyObject *k) {" "static PyObject *%s(PyTypeObject *t, %sPyObject *a, %sPyObject *k) {"
% scope.mangle_internal("tp_new")) % (scope.mangle_internal("tp_new"), unused_marker, unused_marker))
if need_self_cast: if need_self_cast:
code.putln( code.putln(
"%s;" "%s;"
...@@ -1046,15 +1053,14 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1046,15 +1053,14 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
if cclass_entry.cname == '__pyx_memoryviewslice': if cclass_entry.cname == '__pyx_memoryviewslice':
code.putln("p->from_slice.memview = NULL;") code.putln("p->from_slice.memview = NULL;")
entry = scope.lookup_here("__new__") if new_func_entry and new_func_entry.is_special:
if entry and entry.is_special: if new_func_entry.trivial_signature:
if entry.trivial_signature:
cinit_args = "o, %s, NULL" % Naming.empty_tuple cinit_args = "o, %s, NULL" % Naming.empty_tuple
else: else:
cinit_args = "o, a, k" cinit_args = "o, a, k"
code.putln( code.putln(
"if (%s(%s) < 0) {" % "if (%s(%s) < 0) {" %
(entry.func_cname, cinit_args)) (new_func_entry.func_cname, cinit_args))
code.put_decref_clear("o", py_object_type, nanny=False); code.put_decref_clear("o", py_object_type, nanny=False);
code.putln( code.putln(
"}") "}")
......
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