Commit 0bf060f9 authored by Matthias Braun's avatar Matthias Braun Committed by GitHub

Avoid using "tp_name" when CYTHON_COMPILING_IN_LIMITED_API (GH-3693)

parent 61a4f099
...@@ -13111,6 +13111,8 @@ class PyTypeTestNode(CoercionNode): ...@@ -13111,6 +13111,8 @@ class PyTypeTestNode(CoercionNode):
type_test = self.type.type_test_code( type_test = self.type.type_test_code(
self.arg.py_result(), self.arg.py_result(),
self.notnone, exact=self.exact_builtin_type) self.notnone, exact=self.exact_builtin_type)
code.globalstate.use_utility_code(UtilityCode.load_cached(
"RaiseUnexpectedTypeError", "ObjectHandling.c"))
else: else:
type_test = self.type.type_test_code( type_test = self.type.type_test_code(
self.arg.py_result(), self.notnone) self.arg.py_result(), self.notnone)
......
...@@ -781,6 +781,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -781,6 +781,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln('#define __Pyx_PyObject_FromString __Pyx_Py%s_FromString' % c_string_func_name) code.putln('#define __Pyx_PyObject_FromString __Pyx_Py%s_FromString' % c_string_func_name)
code.putln('#define __Pyx_PyObject_FromStringAndSize __Pyx_Py%s_FromStringAndSize' % c_string_func_name) code.putln('#define __Pyx_PyObject_FromStringAndSize __Pyx_Py%s_FromStringAndSize' % c_string_func_name)
code.put(UtilityCode.load_as_string("TypeConversions", "TypeConversion.c")[0]) code.put(UtilityCode.load_as_string("TypeConversions", "TypeConversion.c")[0])
env.use_utility_code(UtilityCode.load_cached("FormatTypeName", "ObjectHandling.c"))
# These utility functions are assumed to exist and used elsewhere. # These utility functions are assumed to exist and used elsewhere.
PyrexTypes.c_long_type.create_to_py_utility_code(env) PyrexTypes.c_long_type.create_to_py_utility_code(env)
...@@ -1865,6 +1866,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1865,6 +1866,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln( code.putln(
"static int %s(PyObject *o, PyObject *i, PyObject *v) {" % ( "static int %s(PyObject *o, PyObject *i, PyObject *v) {" % (
scope.mangle_internal("mp_ass_subscript"))) scope.mangle_internal("mp_ass_subscript")))
code.putln(
"__Pyx_TypeName o_type_name;")
code.putln( code.putln(
"if (v) {") "if (v) {")
if set_entry: if set_entry:
...@@ -1872,10 +1875,14 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1872,10 +1875,14 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
else: else:
self.generate_guarded_basetype_call( self.generate_guarded_basetype_call(
base_type, "tp_as_mapping", "mp_ass_subscript", "o, i, v", code) base_type, "tp_as_mapping", "mp_ass_subscript", "o, i, v", code)
code.putln(
"o_type_name = __Pyx_PyType_GetName(Py_TYPE(o));")
code.putln( code.putln(
"PyErr_Format(PyExc_NotImplementedError,") "PyErr_Format(PyExc_NotImplementedError,")
code.putln( code.putln(
' "Subscript assignment not supported by %.200s", Py_TYPE(o)->tp_name);') ' "Subscript assignment not supported by " __Pyx_FMT_TYPENAME, o_type_name);')
code.putln(
"__Pyx_DECREF_TypeName(o_type_name);")
code.putln( code.putln(
"return -1;") "return -1;")
code.putln( code.putln(
...@@ -1889,10 +1896,14 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1889,10 +1896,14 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
else: else:
self.generate_guarded_basetype_call( self.generate_guarded_basetype_call(
base_type, "tp_as_mapping", "mp_ass_subscript", "o, i, v", code) base_type, "tp_as_mapping", "mp_ass_subscript", "o, i, v", code)
code.putln(
"o_type_name = __Pyx_PyType_GetName(Py_TYPE(o));")
code.putln( code.putln(
"PyErr_Format(PyExc_NotImplementedError,") "PyErr_Format(PyExc_NotImplementedError,")
code.putln( code.putln(
' "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name);') ' "Subscript deletion not supported by " __Pyx_FMT_TYPENAME, o_type_name);')
code.putln(
"__Pyx_DECREF_TypeName(o_type_name);")
code.putln( code.putln(
"return -1;") "return -1;")
code.putln( code.putln(
...@@ -1930,6 +1941,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1930,6 +1941,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln( code.putln(
"static int %s(PyObject *o, Py_ssize_t i, Py_ssize_t j, PyObject *v) {" % ( "static int %s(PyObject *o, Py_ssize_t i, Py_ssize_t j, PyObject *v) {" % (
scope.mangle_internal("sq_ass_slice"))) scope.mangle_internal("sq_ass_slice")))
code.putln(
"__Pyx_TypeName o_type_name;")
code.putln( code.putln(
"if (v) {") "if (v) {")
if set_entry: if set_entry:
...@@ -1939,10 +1952,14 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1939,10 +1952,14 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
else: else:
self.generate_guarded_basetype_call( self.generate_guarded_basetype_call(
base_type, "tp_as_sequence", "sq_ass_slice", "o, i, j, v", code) base_type, "tp_as_sequence", "sq_ass_slice", "o, i, j, v", code)
code.putln(
"o_type_name = __Pyx_PyType_GetName(Py_TYPE(o));")
code.putln( code.putln(
"PyErr_Format(PyExc_NotImplementedError,") "PyErr_Format(PyExc_NotImplementedError,")
code.putln( code.putln(
' "2-element slice assignment not supported by %.200s", Py_TYPE(o)->tp_name);') ' "2-element slice assignment not supported by " __Pyx_FMT_TYPENAME, o_type_name);')
code.putln(
"__Pyx_DECREF_TypeName(o_type_name);")
code.putln( code.putln(
"return -1;") "return -1;")
code.putln( code.putln(
...@@ -1956,10 +1973,14 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1956,10 +1973,14 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
else: else:
self.generate_guarded_basetype_call( self.generate_guarded_basetype_call(
base_type, "tp_as_sequence", "sq_ass_slice", "o, i, j, v", code) base_type, "tp_as_sequence", "sq_ass_slice", "o, i, j, v", code)
code.putln(
"o_type_name = __Pyx_PyType_GetName(Py_TYPE(o));")
code.putln( code.putln(
"PyErr_Format(PyExc_NotImplementedError,") "PyErr_Format(PyExc_NotImplementedError,")
code.putln( code.putln(
' "2-element slice deletion not supported by %.200s", Py_TYPE(o)->tp_name);') ' "2-element slice deletion not supported by " __Pyx_FMT_TYPENAME, o_type_name);')
code.putln(
"__Pyx_DECREF_TypeName(o_type_name);")
code.putln( code.putln(
"return -1;") "return -1;")
code.putln( code.putln(
......
...@@ -5149,9 +5149,13 @@ class CClassDefNode(ClassDefNode): ...@@ -5149,9 +5149,13 @@ class CClassDefNode(ClassDefNode):
code.put_gotref(trial_type, py_object_type) code.put_gotref(trial_type, py_object_type)
code.putln("if (((PyTypeObject*) %s)->tp_base != %s) {" % ( code.putln("if (((PyTypeObject*) %s)->tp_base != %s) {" % (
trial_type, first_base)) trial_type, first_base))
code.putln("PyErr_Format(PyExc_TypeError, \"best base '%s' must be equal to first base '%s'\",") code.putln("__Pyx_TypeName base_name = __Pyx_PyType_GetName(((PyTypeObject*) %s)->tp_base);" % trial_type)
code.putln(" ((PyTypeObject*) %s)->tp_base->tp_name, %s->tp_name);" % ( code.putln("__Pyx_TypeName type_name = __Pyx_PyType_GetName(%s);" % first_base)
trial_type, first_base)) code.putln("PyErr_Format(PyExc_TypeError, "
"\"best base '\" __Pyx_FMT_TYPENAME \"' must be equal to first base '\" __Pyx_FMT_TYPENAME \"'\",")
code.putln(" base_name, type_name);")
code.putln("__Pyx_DECREF_TypeName(base_name);")
code.putln("__Pyx_DECREF_TypeName(type_name);")
code.putln(code.error_goto(self.pos)) code.putln(code.error_goto(self.pos))
code.putln("}") code.putln("}")
code.funcstate.release_temp(trial_type) code.funcstate.release_temp(trial_type)
......
...@@ -1442,14 +1442,9 @@ class BuiltinObjectType(PyObjectType): ...@@ -1442,14 +1442,9 @@ class BuiltinObjectType(PyObjectType):
check += '||((%s) == Py_None)' % arg check += '||((%s) == Py_None)' % arg
if self.name == 'basestring': if self.name == 'basestring':
name = '(PY_MAJOR_VERSION < 3 ? "basestring" : "str")' name = '(PY_MAJOR_VERSION < 3 ? "basestring" : "str")'
space_for_name = 16
else: else:
name = '"%s"' % self.name name = '"%s"' % self.name
# avoid wasting too much space but limit number of different format strings return check + ' || __Pyx_RaiseUnexpectedTypeError(%s, %s)' % (name, arg)
space_for_name = (len(self.name) // 16 + 1) * 16
error = '(PyErr_Format(PyExc_TypeError, "Expected %%.%ds, got %%.200s", %s, __Pyx_PyType_Name(Py_TYPE(%s))), 0)' % (
space_for_name, name, arg)
return check + '||' + error
def declaration_code(self, entity_code, def declaration_code(self, entity_code,
for_display = 0, dll_linkage = None, pyrex = 0): for_display = 0, dll_linkage = None, pyrex = 0):
...@@ -3587,6 +3582,7 @@ class CStructOrUnionType(CType): ...@@ -3587,6 +3582,7 @@ class CStructOrUnionType(CType):
var_entries=self.scope.var_entries, var_entries=self.scope.var_entries,
funcname=self.from_py_function, funcname=self.from_py_function,
) )
env.use_utility_code(UtilityCode.load_cached("RaiseUnexpectedTypeError", "ObjectHandling.c"))
from .UtilityCode import CythonUtilityCode from .UtilityCode import CythonUtilityCode
self._convert_from_py_code = CythonUtilityCode.load( self._convert_from_py_code = CythonUtilityCode.load(
"FromPyStructUtility" if self.is_struct else "FromPyUnionUtility", "FromPyStructUtility" if self.is_struct else "FromPyUnionUtility",
......
...@@ -111,6 +111,7 @@ typedef struct { ...@@ -111,6 +111,7 @@ typedef struct {
#if PY_MAJOR_VERSION < 3 #if PY_MAJOR_VERSION < 3
static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
__Pyx_TypeName obj_type_name;
if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags); if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags);
{{for type_ptr, getbuffer, releasebuffer in types}} {{for type_ptr, getbuffer, releasebuffer in types}}
...@@ -119,7 +120,11 @@ static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { ...@@ -119,7 +120,11 @@ static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
{{endif}} {{endif}}
{{endfor}} {{endfor}}
PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name); obj_type_name = __Pyx_PyType_GetName(Py_TYPE(obj));
PyErr_Format(PyExc_TypeError,
"'" __Pyx_FMT_TYPENAME "' does not have the buffer interface",
obj_type_name);
__Pyx_DECREF_TypeName(obj_type_name);
return -1; return -1;
} }
......
...@@ -69,8 +69,12 @@ static PyObject* __Pyx_PyExec3(PyObject* o, PyObject* globals, PyObject* locals) ...@@ -69,8 +69,12 @@ static PyObject* __Pyx_PyExec3(PyObject* o, PyObject* globals, PyObject* locals)
if (!globals || globals == Py_None) { if (!globals || globals == Py_None) {
globals = $moddict_cname; globals = $moddict_cname;
} else if (unlikely(!PyDict_Check(globals))) { } else if (unlikely(!PyDict_Check(globals))) {
PyErr_Format(PyExc_TypeError, "exec() arg 2 must be a dict, not %.200s", __Pyx_TypeName globals_type_name =
Py_TYPE(globals)->tp_name); __Pyx_PyType_GetName(Py_TYPE(globals));
PyErr_Format(PyExc_TypeError,
"exec() arg 2 must be a dict, not " __Pyx_FMT_TYPENAME,
globals_type_name);
__Pyx_DECREF_TypeName(globals_type_name);
goto bad; goto bad;
} }
if (!locals || locals == Py_None) { if (!locals || locals == Py_None) {
...@@ -106,9 +110,11 @@ static PyObject* __Pyx_PyExec3(PyObject* o, PyObject* globals, PyObject* locals) ...@@ -106,9 +110,11 @@ static PyObject* __Pyx_PyExec3(PyObject* o, PyObject* globals, PyObject* locals)
#else #else
} else if (unlikely(!PyString_Check(o))) { } else if (unlikely(!PyString_Check(o))) {
#endif #endif
__Pyx_TypeName o_type_name = __Pyx_PyType_GetName(Py_TYPE(o));
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"exec: arg 1 must be string, bytes or code object, got %.200s", "exec: arg 1 must be string, bytes or code object, got " __Pyx_FMT_TYPENAME,
Py_TYPE(o)->tp_name); o_type_name);
__Pyx_DECREF_TypeName(o_type_name);
goto bad; goto bad;
} }
#if PY_MAJOR_VERSION >= 3 #if PY_MAJOR_VERSION >= 3
...@@ -194,11 +200,12 @@ static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) { ...@@ -194,11 +200,12 @@ static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
static PyObject* __Pyx_Intern(PyObject* s); /* proto */ static PyObject* __Pyx_Intern(PyObject* s); /* proto */
//////////////////// Intern //////////////////// //////////////////// Intern ////////////////////
//@requires: ObjectHandling.c::RaiseUnexpectedTypeError
static PyObject* __Pyx_Intern(PyObject* s) { static PyObject* __Pyx_Intern(PyObject* s) {
if (unlikely(!PyString_CheckExact(s))) { if (unlikely(!PyString_CheckExact(s))) {
PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(s)->tp_name); __Pyx_RaiseUnexpectedTypeError("str", s);
return 0; return NULL;
} }
Py_INCREF(s); Py_INCREF(s);
#if PY_MAJOR_VERSION >= 3 #if PY_MAJOR_VERSION >= 3
...@@ -307,8 +314,11 @@ static long __Pyx__PyObject_Ord(PyObject* c) { ...@@ -307,8 +314,11 @@ static long __Pyx__PyObject_Ord(PyObject* c) {
#endif #endif
} else { } else {
// FIXME: support character buffers - but CPython doesn't support them either // FIXME: support character buffers - but CPython doesn't support them either
__Pyx_TypeName c_type_name = __Pyx_PyType_GetName(Py_TYPE(c));
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"ord() expected string of length 1, but %.200s found", c->ob_type->tp_name); "ord() expected string of length 1, but " __Pyx_FMT_TYPENAME " found",
c_type_name);
__Pyx_DECREF_TypeName(c_type_name);
return (long)(Py_UCS4)-1; return (long)(Py_UCS4)-1;
} }
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
......
...@@ -6,12 +6,13 @@ cdef extern from *: ...@@ -6,12 +6,13 @@ cdef extern from *:
PyTypeObject *Py_TYPE(obj) PyTypeObject *Py_TYPE(obj)
bint PyMapping_Check(obj) bint PyMapping_Check(obj)
object PyErr_Format(exc, const char *format, ...) object PyErr_Format(exc, const char *format, ...)
int __Pyx_RaiseUnexpectedTypeError(const char *expected, object obj) except 0
@cname("{{funcname}}") @cname("{{funcname}}")
cdef {{struct_type}} {{funcname}}(obj) except *: cdef {{struct_type}} {{funcname}}(obj) except *:
cdef {{struct_type}} result cdef {{struct_type}} result
if not PyMapping_Check(obj): if not PyMapping_Check(obj):
PyErr_Format(TypeError, b"Expected %.16s, got %.200s", b"a mapping", Py_TYPE(obj).tp_name) __Pyx_RaiseUnexpectedTypeError(b"a mapping", obj)
{{for member in var_entries:}} {{for member in var_entries:}}
try: try:
...@@ -31,13 +32,14 @@ cdef extern from *: ...@@ -31,13 +32,14 @@ cdef extern from *:
PyTypeObject *Py_TYPE(obj) PyTypeObject *Py_TYPE(obj)
bint PyMapping_Check(obj) bint PyMapping_Check(obj)
object PyErr_Format(exc, const char *format, ...) object PyErr_Format(exc, const char *format, ...)
int __Pyx_RaiseUnexpectedTypeError(const char *expected, object obj) except 0
@cname("{{funcname}}") @cname("{{funcname}}")
cdef {{struct_type}} {{funcname}}(obj) except *: cdef {{struct_type}} {{funcname}}(obj) except *:
cdef {{struct_type}} result cdef {{struct_type}} result
cdef Py_ssize_t length cdef Py_ssize_t length
if not PyMapping_Check(obj): if not PyMapping_Check(obj):
PyErr_Format(TypeError, b"Expected %.16s, got %.200s", b"a mapping", Py_TYPE(obj).tp_name) __Pyx_RaiseUnexpectedTypeError(b"a mapping", obj)
last_found = None last_found = None
length = len(obj) length = len(obj)
......
...@@ -7,9 +7,10 @@ static CYTHON_INLINE PyObject* __Pyx_Generator_Yield_From(__pyx_CoroutineObject ...@@ -7,9 +7,10 @@ static CYTHON_INLINE PyObject* __Pyx_Generator_Yield_From(__pyx_CoroutineObject
#if CYTHON_USE_TYPE_SLOTS #if CYTHON_USE_TYPE_SLOTS
static void __Pyx_PyIter_CheckErrorAndDecref(PyObject *source) { static void __Pyx_PyIter_CheckErrorAndDecref(PyObject *source) {
__Pyx_TypeName source_type_name = __Pyx_PyType_GetName(Py_TYPE(source));
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"iter() returned non-iterator of type '%.100s'", "iter() returned non-iterator of type '" __Pyx_FMT_TYPENAME "'", source_type_name);
Py_TYPE(source)->tp_name); __Pyx_DECREF_TypeName(source_type_name);
Py_DECREF(source); Py_DECREF(source);
} }
#endif #endif
...@@ -138,13 +139,13 @@ static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAwaitableIter(PyObject *o) { ...@@ -138,13 +139,13 @@ static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAwaitableIter(PyObject *o) {
static void __Pyx_Coroutine_AwaitableIterError(PyObject *source) { static void __Pyx_Coroutine_AwaitableIterError(PyObject *source) {
#if PY_VERSION_HEX >= 0x030600B3 || defined(_PyErr_FormatFromCause) #if PY_VERSION_HEX >= 0x030600B3 || defined(_PyErr_FormatFromCause)
_PyErr_FormatFromCause( __Pyx_TypeName source_type_name = __Pyx_PyType_GetName(Py_TYPE(source));
PyExc_TypeError, _PyErr_FormatFromCause(PyExc_TypeError,
"'async for' received an invalid object " "'async for' received an invalid object from __anext__: " __Pyx_FMT_TYPENAME, source_type_name);
"from __anext__: %.100s", __Pyx_DECREF_TypeName(source_type_name);
Py_TYPE(source)->tp_name);
#elif PY_MAJOR_VERSION >= 3 #elif PY_MAJOR_VERSION >= 3
PyObject *exc, *val, *val2, *tb; PyObject *exc, *val, *val2, *tb;
__Pyx_TypeName source_type_name = __Pyx_PyType_GetName(Py_TYPE(source));
assert(PyErr_Occurred()); assert(PyErr_Occurred());
PyErr_Fetch(&exc, &val, &tb); PyErr_Fetch(&exc, &val, &tb);
PyErr_NormalizeException(&exc, &val, &tb); PyErr_NormalizeException(&exc, &val, &tb);
...@@ -154,11 +155,9 @@ static void __Pyx_Coroutine_AwaitableIterError(PyObject *source) { ...@@ -154,11 +155,9 @@ static void __Pyx_Coroutine_AwaitableIterError(PyObject *source) {
} }
Py_DECREF(exc); Py_DECREF(exc);
assert(!PyErr_Occurred()); assert(!PyErr_Occurred());
PyErr_Format( PyErr_Format(PyExc_TypeError,
PyExc_TypeError, "'async for' received an invalid object from __anext__: " __Pyx_FMT_TYPENAME, source_type_name);
"'async for' received an invalid object " __Pyx_DECREF_TypeName(source_type_name);
"from __anext__: %.100s",
Py_TYPE(source)->tp_name);
PyErr_Fetch(&exc, &val2, &tb); PyErr_Fetch(&exc, &val2, &tb);
PyErr_NormalizeException(&exc, &val2, &tb); PyErr_NormalizeException(&exc, &val2, &tb);
...@@ -209,9 +208,10 @@ static PyObject *__Pyx__Coroutine_GetAwaitableIter(PyObject *obj) { ...@@ -209,9 +208,10 @@ static PyObject *__Pyx__Coroutine_GetAwaitableIter(PyObject *obj) {
goto bad; goto bad;
} }
if (unlikely(!PyIter_Check(res))) { if (unlikely(!PyIter_Check(res))) {
__Pyx_TypeName res_type_name = __Pyx_PyType_GetName(Py_TYPE(res));
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"__await__() returned non-iterator of type '%.100s'", "__await__() returned non-iterator of type '" __Pyx_FMT_TYPENAME "'", res_type_name);
Py_TYPE(res)->tp_name); __Pyx_DECREF_TypeName(res_type_name);
Py_CLEAR(res); Py_CLEAR(res);
} else { } else {
int is_coroutine = 0; int is_coroutine = 0;
...@@ -231,9 +231,12 @@ static PyObject *__Pyx__Coroutine_GetAwaitableIter(PyObject *obj) { ...@@ -231,9 +231,12 @@ static PyObject *__Pyx__Coroutine_GetAwaitableIter(PyObject *obj) {
} }
return res; return res;
slot_error: slot_error:
PyErr_Format(PyExc_TypeError, {
"object %.100s can't be used in 'await' expression", __Pyx_TypeName obj_type_name = __Pyx_PyType_GetName(Py_TYPE(obj));
Py_TYPE(obj)->tp_name); PyErr_Format(PyExc_TypeError,
"object " __Pyx_FMT_TYPENAME " can't be used in 'await' expression", obj_type_name);
__Pyx_DECREF_TypeName(obj_type_name);
}
bad: bad:
return NULL; return NULL;
} }
...@@ -249,6 +252,7 @@ static CYTHON_INLINE PyObject *__Pyx_Coroutine_AsyncIterNext(PyObject *o); /*pro ...@@ -249,6 +252,7 @@ static CYTHON_INLINE PyObject *__Pyx_Coroutine_AsyncIterNext(PyObject *o); /*pro
//@requires: ObjectHandling.c::PyObjectCallMethod0 //@requires: ObjectHandling.c::PyObjectCallMethod0
static PyObject *__Pyx_Coroutine_GetAsyncIter_Generic(PyObject *obj) { static PyObject *__Pyx_Coroutine_GetAsyncIter_Generic(PyObject *obj) {
__Pyx_TypeName obj_type_name;
#if PY_VERSION_HEX < 0x030500B1 #if PY_VERSION_HEX < 0x030500B1
{ {
PyObject *iter = __Pyx_PyObject_CallMethod0(obj, PYIDENT("__aiter__")); PyObject *iter = __Pyx_PyObject_CallMethod0(obj, PYIDENT("__aiter__"));
...@@ -263,8 +267,10 @@ static PyObject *__Pyx_Coroutine_GetAsyncIter_Generic(PyObject *obj) { ...@@ -263,8 +267,10 @@ static PyObject *__Pyx_Coroutine_GetAsyncIter_Generic(PyObject *obj) {
if ((0)) (void) __Pyx_PyObject_CallMethod0(obj, PYIDENT("__aiter__")); if ((0)) (void) __Pyx_PyObject_CallMethod0(obj, PYIDENT("__aiter__"));
#endif #endif
PyErr_Format(PyExc_TypeError, "'async for' requires an object with __aiter__ method, got %.100s", obj_type_name = __Pyx_PyType_GetName(Py_TYPE(obj));
Py_TYPE(obj)->tp_name); PyErr_Format(PyExc_TypeError,
"'async for' requires an object with __aiter__ method, got " __Pyx_FMT_TYPENAME, obj_type_name);
__Pyx_DECREF_TypeName(obj_type_name);
return NULL; return NULL;
} }
...@@ -297,8 +303,12 @@ static PyObject *__Pyx__Coroutine_AsyncIterNext(PyObject *obj) { ...@@ -297,8 +303,12 @@ static PyObject *__Pyx__Coroutine_AsyncIterNext(PyObject *obj) {
// FIXME: for the sake of a nicely conforming exception message, assume any AttributeError meant '__anext__' // FIXME: for the sake of a nicely conforming exception message, assume any AttributeError meant '__anext__'
if (PyErr_ExceptionMatches(PyExc_AttributeError)) if (PyErr_ExceptionMatches(PyExc_AttributeError))
#endif #endif
PyErr_Format(PyExc_TypeError, "'async for' requires an object with __anext__ method, got %.100s", {
Py_TYPE(obj)->tp_name); __Pyx_TypeName obj_type_name = __Pyx_PyType_GetName(Py_TYPE(obj));
PyErr_Format(PyExc_TypeError,
"'async for' requires an object with __anext__ method, got " __Pyx_FMT_TYPENAME, obj_type_name);
__Pyx_DECREF_TypeName(obj_type_name);
}
return NULL; return NULL;
} }
......
...@@ -38,17 +38,24 @@ static int __Pyx_PyType_Ready(PyTypeObject *t) { ...@@ -38,17 +38,24 @@ static int __Pyx_PyType_Ready(PyTypeObject *t) {
b = (PyTypeObject*)b0; b = (PyTypeObject*)b0;
if (!__Pyx_PyType_HasFeature(b, Py_TPFLAGS_HEAPTYPE)) if (!__Pyx_PyType_HasFeature(b, Py_TPFLAGS_HEAPTYPE))
{ {
PyErr_Format(PyExc_TypeError, "base class '%.200s' is not a heap type", __Pyx_TypeName b_name = __Pyx_PyType_GetName(b);
b->tp_name); PyErr_Format(PyExc_TypeError,
"base class '" __Pyx_FMT_TYPENAME "' is not a heap type", b_name);
__Pyx_DECREF_TypeName(b_name);
return -1; return -1;
} }
if (t->tp_dictoffset == 0 && b->tp_dictoffset) if (t->tp_dictoffset == 0 && b->tp_dictoffset)
{ {
__Pyx_TypeName t_name = __Pyx_PyType_GetName(t);
__Pyx_TypeName b_name = __Pyx_PyType_GetName(b);
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"extension type '%.200s' has no __dict__ slot, but base type '%.200s' has: " "extension type '" __Pyx_FMT_TYPENAME "' has no __dict__ slot, "
"but base type '" __Pyx_FMT_TYPENAME "' has: "
"either add 'cdef dict __dict__' to the extension type " "either add 'cdef dict __dict__' to the extension type "
"or add '__slots__ = [...]' to the base type", "or add '__slots__ = [...]' to the base type",
t->tp_name, b->tp_name); t_name, b_name);
__Pyx_DECREF_TypeName(t_name);
__Pyx_DECREF_TypeName(b_name);
return -1; return -1;
} }
} }
...@@ -309,8 +316,13 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { ...@@ -309,8 +316,13 @@ static int __Pyx_setup_reduce(PyObject* type_obj) {
goto __PYX_GOOD; goto __PYX_GOOD;
__PYX_BAD: __PYX_BAD:
if (!PyErr_Occurred()) if (!PyErr_Occurred()) {
PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", __Pyx_PyType_Name(type_obj)); __Pyx_TypeName type_obj_name =
__Pyx_PyType_GetName((PyTypeObject*)type_obj);
PyErr_Format(PyExc_RuntimeError,
"Unable to initialize pickling for " __Pyx_FMT_TYPENAME, type_obj_name);
__Pyx_DECREF_TypeName(type_obj_name);
}
ret = -1; ret = -1;
__PYX_GOOD: __PYX_GOOD:
#if !CYTHON_USE_PYTYPE_LOOKUP #if !CYTHON_USE_PYTYPE_LOOKUP
......
...@@ -11,6 +11,8 @@ static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *nam ...@@ -11,6 +11,8 @@ static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *nam
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
{ {
__Pyx_TypeName type_name;
__Pyx_TypeName obj_type_name;
if (unlikely(!type)) { if (unlikely(!type)) {
PyErr_SetString(PyExc_SystemError, "Missing type object"); PyErr_SetString(PyExc_SystemError, "Missing type object");
return 0; return 0;
...@@ -23,9 +25,13 @@ static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *nam ...@@ -23,9 +25,13 @@ static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *nam
else { else {
if (likely(__Pyx_TypeCheck(obj, type))) return 1; if (likely(__Pyx_TypeCheck(obj, type))) return 1;
} }
type_name = __Pyx_PyType_GetName(type);
obj_type_name = __Pyx_PyType_GetName(Py_TYPE(obj));
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", "Argument '%.200s' has incorrect type (expected " __Pyx_FMT_TYPENAME
name, type->tp_name, Py_TYPE(obj)->tp_name); ", got " __Pyx_FMT_TYPENAME ")", name, type_name, obj_type_name);
__Pyx_DECREF_TypeName(type_name);
__Pyx_DECREF_TypeName(obj_type_name);
return 0; return 0;
} }
...@@ -111,7 +117,10 @@ static void __Pyx_RaiseMappingExpectedError(PyObject* arg); /*proto*/ ...@@ -111,7 +117,10 @@ static void __Pyx_RaiseMappingExpectedError(PyObject* arg); /*proto*/
//////////////////// RaiseMappingExpected //////////////////// //////////////////// RaiseMappingExpected ////////////////////
static void __Pyx_RaiseMappingExpectedError(PyObject* arg) { static void __Pyx_RaiseMappingExpectedError(PyObject* arg) {
PyErr_Format(PyExc_TypeError, "'%.200s' object is not a mapping", Py_TYPE(arg)->tp_name); __Pyx_TypeName arg_type_name = __Pyx_PyType_GetName(Py_TYPE(arg));
PyErr_Format(PyExc_TypeError,
"'" __Pyx_FMT_TYPENAME "' object is not a mapping", arg_type_name);
__Pyx_DECREF_TypeName(arg_type_name);
} }
......
...@@ -756,6 +756,8 @@ static int __Pyx_MergeVtables(PyTypeObject *type); /*proto*/ ...@@ -756,6 +756,8 @@ static int __Pyx_MergeVtables(PyTypeObject *type); /*proto*/
static int __Pyx_MergeVtables(PyTypeObject *type) { static int __Pyx_MergeVtables(PyTypeObject *type) {
int i; int i;
void** base_vtables; void** base_vtables;
__Pyx_TypeName tp_base_name;
__Pyx_TypeName base_name;
void* unknown = (void*)-1; void* unknown = (void*)-1;
PyObject* bases = type->tp_bases; PyObject* bases = type->tp_bases;
int base_depth = 0; int base_depth = 0;
...@@ -798,10 +800,12 @@ static int __Pyx_MergeVtables(PyTypeObject *type) { ...@@ -798,10 +800,12 @@ static int __Pyx_MergeVtables(PyTypeObject *type) {
free(base_vtables); free(base_vtables);
return 0; return 0;
bad: bad:
PyErr_Format( tp_base_name = __Pyx_PyType_GetName(type->tp_base);
PyExc_TypeError, base_name = __Pyx_PyType_GetName((PyTypeObject*)PyTuple_GET_ITEM(bases, i));
"multiple bases have vtable conflict: '%s' and '%s'", PyErr_Format(PyExc_TypeError,
type->tp_base->tp_name, ((PyTypeObject*)PyTuple_GET_ITEM(bases, i))->tp_name); "multiple bases have vtable conflict: '" __Pyx_FMT_TYPENAME "' and '" __Pyx_FMT_TYPENAME "'", tp_base_name, base_name);
__Pyx_DECREF_TypeName(tp_base_name);
__Pyx_DECREF_TypeName(base_name);
free(base_vtables); free(base_vtables);
return -1; return -1;
} }
......
...@@ -704,14 +704,8 @@ static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict, ...@@ -704,14 +704,8 @@ static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict,
/* Type slots */ /* Type slots */
#if CYTHON_COMPILING_IN_LIMITED_API #if CYTHON_COMPILING_IN_LIMITED_API
#if defined(_PyType_Name)
#define __Pyx_PyType_Name(tp) (_PyType_Name((PyTypeObject *)tp))
#else
#define __Pyx_PyType_Name(tp) (((PyTypeObject *)tp)->tp_name)
#endif
#define __Pyx_PyType_GetFlags(tp) (PyType_GetFlags((PyTypeObject *)tp)) #define __Pyx_PyType_GetFlags(tp) (PyType_GetFlags((PyTypeObject *)tp))
#else #else
#define __Pyx_PyType_Name(tp) (((PyTypeObject *)tp)->tp_name)
#define __Pyx_PyType_GetFlags(tp) (((PyTypeObject *)tp)->tp_flags) #define __Pyx_PyType_GetFlags(tp) (((PyTypeObject *)tp)->tp_flags)
#endif #endif
...@@ -901,7 +895,6 @@ static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict, ...@@ -901,7 +895,6 @@ static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict,
} __Pyx_PyAsyncMethodsStruct; } __Pyx_PyAsyncMethodsStruct;
#endif #endif
/////////////// SmallCodeConfig.proto /////////////// /////////////// SmallCodeConfig.proto ///////////////
#ifndef CYTHON_SMALL_CODE #ifndef CYTHON_SMALL_CODE
......
...@@ -185,8 +185,10 @@ static PyObject *__Pyx_PyIter_Next2Default(PyObject* defval) { ...@@ -185,8 +185,10 @@ static PyObject *__Pyx_PyIter_Next2Default(PyObject* defval) {
} }
static void __Pyx_PyIter_Next_ErrorNoIterator(PyObject *iterator) { static void __Pyx_PyIter_Next_ErrorNoIterator(PyObject *iterator) {
__Pyx_TypeName iterator_type_name = __Pyx_PyType_GetName(Py_TYPE(iterator));
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"%.200s object is not an iterator", Py_TYPE(iterator)->tp_name); __Pyx_FMT_TYPENAME " object is not an iterator", iterator_type_name);
__Pyx_DECREF_TypeName(iterator_type_name);
} }
// originally copied from Py3's builtin_next() // originally copied from Py3's builtin_next()
...@@ -295,13 +297,17 @@ static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject *index) { ...@@ -295,13 +297,17 @@ static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject *index) {
// Error handling code -- only manage OverflowError differently. // Error handling code -- only manage OverflowError differently.
if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) { if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
__Pyx_TypeName index_type_name = __Pyx_PyType_GetName(Py_TYPE(index));
PyErr_Clear(); PyErr_Clear();
PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name); PyErr_Format(PyExc_IndexError,
"cannot fit '" __Pyx_FMT_TYPENAME "' into an index-sized integer", index_type_name);
__Pyx_DECREF_TypeName(index_type_name);
} }
return NULL; return NULL;
} }
static PyObject *__Pyx_PyObject_GetItem_Slow(PyObject *obj, PyObject *key) { static PyObject *__Pyx_PyObject_GetItem_Slow(PyObject *obj, PyObject *key) {
__Pyx_TypeName obj_type_name;
// Handles less common slow-path checks for GetItem // Handles less common slow-path checks for GetItem
if (likely(PyType_Check(obj))) { if (likely(PyType_Check(obj))) {
PyObject *meth = __Pyx_PyObject_GetAttrStrNoError(obj, PYIDENT("__class_getitem__")); PyObject *meth = __Pyx_PyObject_GetAttrStrNoError(obj, PYIDENT("__class_getitem__"));
...@@ -312,7 +318,10 @@ static PyObject *__Pyx_PyObject_GetItem_Slow(PyObject *obj, PyObject *key) { ...@@ -312,7 +318,10 @@ static PyObject *__Pyx_PyObject_GetItem_Slow(PyObject *obj, PyObject *key) {
} }
} }
PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name); obj_type_name = __Pyx_PyType_GetName(Py_TYPE(obj));
PyErr_Format(PyExc_TypeError,
"'" __Pyx_FMT_TYPENAME "' object is not subscriptable", obj_type_name);
__Pyx_DECREF_TypeName(obj_type_name);
return NULL; return NULL;
} }
...@@ -640,6 +649,7 @@ static CYTHON_INLINE int __Pyx_PyObject_SetSlice(PyObject* obj, PyObject* value, ...@@ -640,6 +649,7 @@ static CYTHON_INLINE int __Pyx_PyObject_SetSlice(PyObject* obj, PyObject* value,
Py_ssize_t cstart, Py_ssize_t cstop, Py_ssize_t cstart, Py_ssize_t cstop,
PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice, PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) { int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
__Pyx_TypeName obj_type_name;
#if CYTHON_USE_TYPE_SLOTS #if CYTHON_USE_TYPE_SLOTS
PyMappingMethods* mp; PyMappingMethods* mp;
#if PY_MAJOR_VERSION < 3 #if PY_MAJOR_VERSION < 3
...@@ -742,13 +752,15 @@ static CYTHON_INLINE int __Pyx_PyObject_SetSlice(PyObject* obj, PyObject* value, ...@@ -742,13 +752,15 @@ static CYTHON_INLINE int __Pyx_PyObject_SetSlice(PyObject* obj, PyObject* value,
} }
return result; return result;
} }
obj_type_name = __Pyx_PyType_GetName(Py_TYPE(obj));
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
{{if access == 'Get'}} {{if access == 'Get'}}
"'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name); "'" __Pyx_FMT_TYPENAME "' object is unsliceable", obj_type_name);
{{else}} {{else}}
"'%.200s' object does not support slice %.10s", "'" __Pyx_FMT_TYPENAME "' object does not support slice %.10s",
Py_TYPE(obj)->tp_name, value ? "assignment" : "deletion"); obj_type_name, value ? "assignment" : "deletion");
{{endif}} {{endif}}
__Pyx_DECREF_TypeName(obj_type_name);
bad: bad:
return {{if access == 'Get'}}NULL{{else}}-1{{endif}}; return {{if access == 'Get'}}NULL{{else}}-1{{endif}};
...@@ -1096,15 +1108,18 @@ static int __Pyx_SetNamesPEP487(PyObject *type_obj) { ...@@ -1096,15 +1108,18 @@ static int __Pyx_SetNamesPEP487(PyObject *type_obj) {
tmp = __Pyx_PyObject_Call2Args(set_name, type_obj, key); tmp = __Pyx_PyObject_Call2Args(set_name, type_obj, key);
Py_DECREF(set_name); Py_DECREF(set_name);
if (unlikely(tmp == NULL)) { if (unlikely(tmp == NULL)) {
__Pyx_TypeName value_type_name =
__Pyx_PyType_GetName(Py_TYPE(value));
__Pyx_TypeName type_name = __Pyx_PyType_GetName(type);
PyErr_Format(PyExc_RuntimeError, PyErr_Format(PyExc_RuntimeError,
#if PY_MAJOR_VERSION >= 3 #if PY_MAJOR_VERSION >= 3
"Error calling __set_name__ on '%.100s' instance %R " "Error calling __set_name__ on '" __Pyx_FMT_TYPENAME "' instance %R " "in '" __Pyx_FMT_TYPENAME "'",
"in '%.100s'", value_type_name, key, type_name);
Py_TYPE(value)->tp_name, key, type->tp_name);
#else #else
"Error calling __set_name__ on '%.100s' instance %.100s " "Error calling __set_name__ on '" __Pyx_FMT_TYPENAME "' instance %.100s in '" __Pyx_FMT_TYPENAME "'",
"in '%.100s'", value_type_name,
Py_TYPE(value)->tp_name, PyString_Check(key) ? PyString_AS_STRING(key) : "?", type->tp_name); PyString_Check(key) ? PyString_AS_STRING(key) : "?",
type_name);
#endif #endif
goto bad; goto bad;
} else { } else {
...@@ -1269,14 +1284,21 @@ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*pr ...@@ -1269,14 +1284,21 @@ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*pr
/////////////// ExtTypeTest /////////////// /////////////// ExtTypeTest ///////////////
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
__Pyx_TypeName obj_type_name;
__Pyx_TypeName type_name;
if (unlikely(!type)) { if (unlikely(!type)) {
PyErr_SetString(PyExc_SystemError, "Missing type object"); PyErr_SetString(PyExc_SystemError, "Missing type object");
return 0; return 0;
} }
if (likely(__Pyx_TypeCheck(obj, type))) if (likely(__Pyx_TypeCheck(obj, type)))
return 1; return 1;
PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", obj_type_name = __Pyx_PyType_GetName(Py_TYPE(obj));
Py_TYPE(obj)->tp_name, type->tp_name); type_name = __Pyx_PyType_GetName(type);
PyErr_Format(PyExc_TypeError,
"Cannot convert " __Pyx_FMT_TYPENAME " to " __Pyx_FMT_TYPENAME,
obj_type_name, type_name);
__Pyx_DECREF_TypeName(obj_type_name);
__Pyx_DECREF_TypeName(type_name);
return 0; return 0;
} }
...@@ -1578,14 +1600,16 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj ...@@ -1578,14 +1600,16 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) { static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
__Pyx_TypeName type_name = __Pyx_PyType_GetName(tp);
PyErr_Format(PyExc_AttributeError, PyErr_Format(PyExc_AttributeError,
#if PY_MAJOR_VERSION >= 3 #if PY_MAJOR_VERSION >= 3
"'%.50s' object has no attribute '%U'", "'" __Pyx_FMT_TYPENAME "' object has no attribute '%U'",
tp->tp_name, attr_name); type_name, attr_name);
#else #else
"'%.50s' object has no attribute '%.400s'", "'" __Pyx_FMT_TYPENAME "' object has no attribute '%.400s'",
tp->tp_name, PyString_AS_STRING(attr_name)); type_name, PyString_AS_STRING(attr_name));
#endif #endif
__Pyx_DECREF_TypeName(type_name);
return NULL; return NULL;
} }
...@@ -1741,6 +1765,7 @@ static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **me ...@@ -1741,6 +1765,7 @@ static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **me
static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) { static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
PyObject *attr; PyObject *attr;
__Pyx_TypeName type_name;
#if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP #if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
// Copied from _PyObject_GetMethod() in CPython 3.7 // Copied from _PyObject_GetMethod() in CPython 3.7
PyTypeObject *tp = Py_TYPE(obj); PyTypeObject *tp = Py_TYPE(obj);
...@@ -1820,14 +1845,16 @@ static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **me ...@@ -1820,14 +1845,16 @@ static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **me
return 0; return 0;
} }
type_name = __Pyx_PyType_GetName(tp);
PyErr_Format(PyExc_AttributeError, PyErr_Format(PyExc_AttributeError,
#if PY_MAJOR_VERSION >= 3 #if PY_MAJOR_VERSION >= 3
"'%.50s' object has no attribute '%U'", "'" __Pyx_FMT_TYPENAME "' object has no attribute '%U'",
tp->tp_name, name); type_name, name);
#else #else
"'%.50s' object has no attribute '%.400s'", "'" __Pyx_FMT_TYPENAME "' object has no attribute '%.400s'",
tp->tp_name, PyString_AS_STRING(name)); type_name, PyString_AS_STRING(name));
#endif #endif
__Pyx_DECREF_TypeName(type_name);
return 0; return 0;
// Generic fallback implementation using normal attribute lookup. // Generic fallback implementation using normal attribute lookup.
...@@ -2651,6 +2678,8 @@ done: ...@@ -2651,6 +2678,8 @@ done:
} }
static PyObject* __Pyx__PyNumber_MatrixMultiply(PyObject* x, PyObject* y, const char* op_name) { static PyObject* __Pyx__PyNumber_MatrixMultiply(PyObject* x, PyObject* y, const char* op_name) {
__Pyx_TypeName x_type_name;
__Pyx_TypeName y_type_name;
int right_is_subtype = PyObject_IsSubclass((PyObject*)Py_TYPE(y), (PyObject*)Py_TYPE(x)); int right_is_subtype = PyObject_IsSubclass((PyObject*)Py_TYPE(y), (PyObject*)Py_TYPE(x));
if (unlikely(right_is_subtype == -1)) if (unlikely(right_is_subtype == -1))
return NULL; return NULL;
...@@ -2663,11 +2692,13 @@ static PyObject* __Pyx__PyNumber_MatrixMultiply(PyObject* x, PyObject* y, const ...@@ -2663,11 +2692,13 @@ static PyObject* __Pyx__PyNumber_MatrixMultiply(PyObject* x, PyObject* y, const
if (!right_is_subtype) { if (!right_is_subtype) {
__Pyx_TryMatrixMethod(y, x, PYIDENT("__rmatmul__")) __Pyx_TryMatrixMethod(y, x, PYIDENT("__rmatmul__"))
} }
x_type_name = __Pyx_PyType_GetName(Py_TYPE(x));
y_type_name = __Pyx_PyType_GetName(Py_TYPE(y));
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for %.2s: '%.100s' and '%.100s'", "unsupported operand type(s) for %.2s: '" __Pyx_FMT_TYPENAME "' and '"
op_name, __Pyx_FMT_TYPENAME "'", op_name, x_type_name, y_type_name);
Py_TYPE(x)->tp_name, __Pyx_DECREF_TypeName(x_type_name);
Py_TYPE(y)->tp_name); __Pyx_DECREF_TypeName(y_type_name);
return NULL; return NULL;
} }
...@@ -2873,3 +2904,49 @@ static CYTHON_INLINE PyObject *__Pyx_PyUnicode_ConcatInPlaceImpl(PyObject **p_le ...@@ -2873,3 +2904,49 @@ static CYTHON_INLINE PyObject *__Pyx_PyUnicode_ConcatInPlaceImpl(PyObject **p_le
PyNumber_Add(a, b) : __Pyx_PyStr_Concat(a, b)) PyNumber_Add(a, b) : __Pyx_PyStr_Concat(a, b))
#define __Pyx_PyStr_ConcatInPlaceSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ? \ #define __Pyx_PyStr_ConcatInPlaceSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ? \
PyNumber_InPlaceAdd(a, b) : __Pyx_PyStr_ConcatInPlace(a, b)) PyNumber_InPlaceAdd(a, b) : __Pyx_PyStr_ConcatInPlace(a, b))
/////////////// FormatTypeName.proto ///////////////
#if CYTHON_COMPILING_IN_LIMITED_API
typedef PyObject *__Pyx_TypeName;
#define __Pyx_FMT_TYPENAME "%U"
static __Pyx_TypeName __Pyx_PyType_GetName(PyTypeObject* tp); /*proto*/
#define __Pyx_DECREF_TypeName(obj) Py_XDECREF(obj)
#else
typedef const char *__Pyx_TypeName;
#define __Pyx_FMT_TYPENAME "%.200s"
#define __Pyx_PyType_GetName(tp) ((tp)->tp_name)
#define __Pyx_DECREF_TypeName(obj)
#endif
/////////////// FormatTypeName ///////////////
#if CYTHON_COMPILING_IN_LIMITED_API
static __Pyx_TypeName
__Pyx_PyType_GetName(PyTypeObject* tp)
{
PyObject *name = __Pyx_PyObject_GetAttrStr((PyObject *)tp,
PYIDENT("__name__"));
if (unlikely(name == NULL) || unlikely(!PyUnicode_Check(name))) {
PyErr_Clear();
Py_XSETREF(name, __Pyx_NewRef(PYIDENT("?")));
}
return name;
}
#endif
/////////////// RaiseUnexpectedTypeError.proto ///////////////
static int __Pyx_RaiseUnexpectedTypeError(const char *expected, PyObject *obj); /*proto*/
/////////////// RaiseUnexpectedTypeError ///////////////
static int
__Pyx_RaiseUnexpectedTypeError(const char *expected, PyObject *obj)
{
__Pyx_TypeName obj_type_name = __Pyx_PyType_GetName(Py_TYPE(obj));
PyErr_Format(PyExc_TypeError, "Expected %s, got " __Pyx_FMT_TYPENAME,
expected, obj_type_name);
__Pyx_DECREF_TypeName(obj_type_name);
return 0;
}
...@@ -609,9 +609,11 @@ static double __Pyx__PyObject_AsDouble(PyObject* obj) { ...@@ -609,9 +609,11 @@ static double __Pyx__PyObject_AsDouble(PyObject* obj) {
if (likely(nb) && likely(nb->nb_float)) { if (likely(nb) && likely(nb->nb_float)) {
float_value = nb->nb_float(obj); float_value = nb->nb_float(obj);
if (likely(float_value) && unlikely(!PyFloat_Check(float_value))) { if (likely(float_value) && unlikely(!PyFloat_Check(float_value))) {
__Pyx_TypeName float_value_type_name = __Pyx_PyType_GetName(Py_TYPE(float_value));
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"__float__ returned non-float (type %.200s)", "__float__ returned non-float (type " __Pyx_FMT_TYPENAME ")",
Py_TYPE(float_value)->tp_name); float_value_type_name);
__Pyx_DECREF_TypeName(float_value_type_name);
Py_DECREF(float_value); Py_DECREF(float_value);
goto bad; goto bad;
} }
......
...@@ -314,23 +314,27 @@ static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) { ...@@ -314,23 +314,27 @@ static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
} }
static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
__Pyx_TypeName result_type_name = __Pyx_PyType_GetName(Py_TYPE(result));
#if PY_MAJOR_VERSION >= 3 #if PY_MAJOR_VERSION >= 3
if (PyLong_Check(result)) { if (PyLong_Check(result)) {
// CPython issue #17576: warn if 'result' not of exact type int. // CPython issue #17576: warn if 'result' not of exact type int.
if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
"__int__ returned non-int (type %.200s). " "__int__ returned non-int (type " __Pyx_FMT_TYPENAME "). "
"The ability to return an instance of a strict subclass of int " "The ability to return an instance of a strict subclass of int is deprecated, "
"is deprecated, and may be removed in a future version of Python.", "and may be removed in a future version of Python.",
__Pyx_PyType_Name(Py_TYPE(result)))) { result_type_name)) {
__Pyx_DECREF_TypeName(result_type_name);
Py_DECREF(result); Py_DECREF(result);
return NULL; return NULL;
} }
__Pyx_DECREF_TypeName(result_type_name);
return result; return result;
} }
#endif #endif
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"__%.4s__ returned non-%.4s (type %.200s)", "__%.4s__ returned non-%.4s (type " __Pyx_FMT_TYPENAME ")",
type_name, type_name, __Pyx_PyType_Name(Py_TYPE(result))); type_name, type_name, result_type_name);
__Pyx_DECREF_TypeName(result_type_name);
Py_DECREF(result); Py_DECREF(result);
return NULL; return NULL;
} }
...@@ -492,7 +496,10 @@ static {{struct_type_decl}} {{funcname}}(PyObject * o) { ...@@ -492,7 +496,10 @@ static {{struct_type_decl}} {{funcname}}(PyObject * o) {
{{struct_type_decl}} result; {{struct_type_decl}} result;
if (!PyTuple_Check(o) || PyTuple_GET_SIZE(o) != {{size}}) { if (!PyTuple_Check(o) || PyTuple_GET_SIZE(o) != {{size}}) {
PyErr_Format(PyExc_TypeError, "Expected %.16s of size %d, got %.200s", "a tuple", {{size}}, Py_TYPE(o)->tp_name); __Pyx_TypeName o_type_name = __Pyx_PyType_GetName(Py_TYPE(o));
PyErr_Format(PyExc_TypeError,
"Expected a tuple of size %d, got " __Pyx_FMT_TYPENAME, {{size}}, o_type_name);
__Pyx_DECREF_TypeName(o_type_name);
goto bad; goto bad;
} }
......
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