-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
Regression in 3.13.1 for imports of nonexistant names from CFFI modules #128030
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
3.13
bugs and security fixes
3.14
new features, bugs and security fixes
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
type-bug
An unexpected behavior, bug, or error
Comments
(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:336
336 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:336
336 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:542
542 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:542
542 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:369
369 return Py_TYPE(ob) == type;
(gdb)
0x00005555556a28bf in Py_TYPE (ob=ob@entry=<_cffi_backend.Lib at remote 0x7ffff6ccc6d0>)
at ./Include/object.h:336
336 return ob->ob_type;
(gdb)
PyType_IsSubtype (a=0x7ffff71bbc60 <Lib_Type>, b=b@entry=0x555555a7e040 <PyModule_Type>)
at Objects/typeobject.c:2479
2479 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:2455
2455 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:23
23 return Py_SIZE(tuple);
(gdb) s
Py_SIZE (ob=(<type at remote 0x7ffff71bbc60>, <type at remote 0x555555a83f60>))
at ./Include/object.h:349
349 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:2462
2462 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:605
605 PyErr_BadArgument(); Here's the relevant type: https://github.com/python-cffi/cffi/blob/main/src/c/lib_obj.c#L591-L627 |
hauntsaninja
added a commit
to hauntsaninja/cpython
that referenced
this issue
Dec 17, 2024
…module I missed the extra `PyModule_Check` in python#127660 because I was looking at 3.12 as the base implementation for import from. This meant that I missed the `PyModuleCheck` introduced in python#112661.
Thanks for tagging me! I've opened #128047 , I will confirm that that fixes the CFFI test case. |
hauntsaninja
added a commit
that referenced
this issue
Dec 20, 2024
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Dec 20, 2024
…module (pythonGH-128047) I missed the extra `PyModule_Check` in pythonGH-127660 because I was looking at 3.12 as the base implementation for import from. This meant that I missed the `PyModuleCheck` introduced in pythonGH-112661. (cherry picked from commit 45e6dd6) Co-authored-by: Shantanu <[email protected]>
Thanks for the timely report. Fix is backported to 3.13 and I confirmed it makes cffi's test_import_from_lib pass |
hauntsaninja
added a commit
that referenced
this issue
Dec 20, 2024
…-module (GH-128047) (#128114) gh-128030: Avoid error from PyModule_GetFilenameObject for non-module (GH-128047) I missed the extra `PyModule_Check` in GH-127660 because I was looking at 3.12 as the base implementation for import from. This meant that I missed the `PyModuleCheck` introduced in GH-112661. (cherry picked from commit 45e6dd6) Co-authored-by: Shantanu <[email protected]>
srinivasreddy
pushed a commit
to srinivasreddy/cpython
that referenced
this issue
Dec 23, 2024
…module (python#128047) I missed the extra `PyModule_Check` in python#127660 because I was looking at 3.12 as the base implementation for import from. This meant that I missed the `PyModuleCheck` introduced in python#112661.
srinivasreddy
pushed a commit
to srinivasreddy/cpython
that referenced
this issue
Jan 8, 2025
…module (python#128047) I missed the extra `PyModule_Check` in python#127660 because I was looking at 3.12 as the base implementation for import from. This meant that I missed the `PyModuleCheck` introduced in python#112661.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
3.13
bugs and security fixes
3.14
new features, bugs and security fixes
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
type-bug
An unexpected behavior, bug, or error
Bug report
Bug description:
cffi's
TestNewFFI1.test_import_from_lib
started failing with:This is where
_test_import_from_lib
is a CFFI C extension, which does not contain a memberlib.bar
. So in this case_test_import_from_lib.lib
probably doesn't have an origin.More details here: python-cffi/cffi#150
The offending change seems to be the introduction of
PyModule_GetFilenameObject
in #127775. (@hauntsaninja, @serhiy-storchaka)CPython versions tested on:
3.13
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: