You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Regression in 3.13.1 for imports of nonexistant names from CFFI modules #128030
This is where _test_import_from_lib is a CFFI C extension, which does not contain a member lib.bar. So in this case _test_import_from_lib.lib probably doesn't have an origin.
(gdb) run
Starting program: /home/stefanor/git/upstream/cffi/ve/bin/python -m pytest testing/cffi1/test_new_ffi_1.py -k test_import_from_lib
This GDB supports auto-downloading debuginfo from the following URLs:
<https://debuginfod.debian.net>
Enable debuginfod for this session? (y or [n]) y
Debuginfod has been enabled.
To make this setting permanent, add 'set debuginfod enabled on' to .gdbinit.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Breakpoint 1.1, PyModule_GetFilenameObject (mod=mod@entry=<module at remote 0x7ffff7c98090>)
at ./Include/object.h:336336 return ob->ob_type;
(gdb) cont
Continuing.
==================================== test session starts =====================================
platform linux -- Python 3.13.1+, pytest-8.3.4, pluggy-1.5.0
rootdir: /home/stefanor/git/upstream/cffi
configfile: pyproject.toml
collected 124 items / 123 deselected / 1 selected
testing/cffi1/test_new_ffi_1.py [Detaching after vfork from child process 3670695]
[Detaching after vfork from child process 3670698]
[Detaching after vfork from child process 3670701]
[Detaching after vfork from child process 3670704]
Breakpoint 1.1, PyModule_GetFilenameObject (
mod=mod@entry=<_cffi_backend.Lib at remote 0x7ffff6ccc6d0>) at ./Include/object.h:336336 return ob->ob_type;
(gdb) s
604 if (!PyModule_Check(mod)) {
(gdb)
0x00005555556a28b4 in PyObject_TypeCheck (
ob=ob@entry=<_cffi_backend.Lib at remote 0x7ffff6ccc6d0>,
type=0x555555a7e040 <PyModule_Type>) at ./Include/object.h:542542 return Py_IS_TYPE(ob, type) || PyType_IsSubtype(Py_TYPE(ob), type);
(gdb) p ob
$1 = <_cffi_backend.Lib at remote 0x7ffff6ccc6d0>
(gdb) p type
$2 = (PyTypeObject *) 0x555555a7e040 <PyModule_Type>
(gdb) s
604 if (!PyModule_Check(mod)) {
(gdb)
PyObject_TypeCheck (ob=ob@entry=<_cffi_backend.Lib at remote 0x7ffff6ccc6d0>,
type=0x555555a7e040 <PyModule_Type>) at ./Include/object.h:542542 return Py_IS_TYPE(ob, type) || PyType_IsSubtype(Py_TYPE(ob), type);
(gdb)
Py_IS_TYPE (ob=ob@entry=<_cffi_backend.Lib at remote 0x7ffff6ccc6d0>,
type=0x555555a7e040 <PyModule_Type>) at ./Include/object.h:369369 return Py_TYPE(ob) == type;
(gdb)
0x00005555556a28bf in Py_TYPE (ob=ob@entry=<_cffi_backend.Lib at remote 0x7ffff6ccc6d0>)
at ./Include/object.h:336336 return ob->ob_type;
(gdb)
PyType_IsSubtype (a=0x7ffff71bbc60 <Lib_Type>, b=b@entry=0x555555a7e040 <PyModule_Type>)
at Objects/typeobject.c:24792479 return is_subtype_with_mro(a->tp_mro, a, b);
(gdb) p a->tp_mro
$3 = (<type at remote 0x7ffff71bbc60>, <type at remote 0x555555a83f60>)
(gdb) s
is_subtype_with_mro (
a_mro=(<type at remote 0x7ffff71bbc60>, <type at remote 0x555555a83f60>),
a=0x7ffff71bbc60 <Lib_Type>, b=0x555555a7e040 <PyModule_Type>)
at Objects/typeobject.c:24552455 if (a_mro != NULL) {
(gdb)
2460 n = PyTuple_GET_SIZE(a_mro);
(gdb) s
PyTuple_GET_SIZE (op=(<type at remote 0x7ffff71bbc60>, <type at remote 0x555555a83f60>))
at ./Include/cpython/tupleobject.h:2323 return Py_SIZE(tuple);
(gdb) s
Py_SIZE (ob=(<type at remote 0x7ffff71bbc60>, <type at remote 0x555555a83f60>))
at ./Include/object.h:349349 return _PyVarObject_CAST(ob)->ob_size;
(gdb) p _PyVarObject_CAST(ob)->ob_size
No symbol"_PyVarObject_CAST" in current context.
(gdb) s
is_subtype_with_mro (
a_mro=(<type at remote 0x7ffff71bbc60>, <type at remote 0x555555a83f60>),
a=0x7ffff71bbc60 <Lib_Type>, b=0x555555a7e040 <PyModule_Type>)
at Objects/typeobject.c:24622462 for (i = 0; i < n; i++) {
(gdb) p n
$4 = 2
(gdb) s
2463 if (PyTuple_GET_ITEM(a_mro, i) == (PyObject *)b) {
(gdb) s
2463 if (PyTuple_GET_ITEM(a_mro, i) == (PyObject *)b) {
(gdb) s
PyModule_GetFilenameObject (mod=mod@entry=<_cffi_backend.Lib at remote 0x7ffff6ccc6d0>)
at Objects/moduleobject.c:605605 PyErr_BadArgument();
Activity
stefanor commentedon Dec 17, 2024
Here's the relevant type: https://github.com/python-cffi/cffi/blob/main/src/c/lib_obj.c#L591-L627
pythongh-128030: Avoid error from PyModule_GetFilenameObject for non-…
hauntsaninja commentedon Dec 17, 2024
Thanks for tagging me! I've opened #128047 , I will confirm that that fixes the CFFI test case.
gh-128030: Avoid error from PyModule_GetFilenameObject for non-module (…
pythongh-128030: Avoid error from PyModule_GetFilenameObject for non-…
hauntsaninja commentedon Dec 20, 2024
Thanks for the timely report. Fix is backported to 3.13 and I confirmed it makes cffi's test_import_from_lib pass
[3.13] gh-128030: Avoid error from PyModule_GetFilenameObject for non…
pythongh-128030: Avoid error from PyModule_GetFilenameObject for non-…
pythongh-128030: Avoid error from PyModule_GetFilenameObject for non-…