mirror of
https://github.com/python/cpython.git
synced 2025-07-19 01:05:26 +00:00
[3.13] gh-128030: Avoid error from PyModule_GetFilenameObject for non-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 45e6dd63b8
)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
This commit is contained in:
parent
3a8bdaf698
commit
f320f747da
3 changed files with 25 additions and 1 deletions
|
@ -2781,7 +2781,7 @@ import_from(PyThreadState *tstate, PyObject *v, PyObject *name)
|
|||
}
|
||||
}
|
||||
|
||||
if (origin == NULL) {
|
||||
if (origin == NULL && PyModule_Check(v)) {
|
||||
// Fall back to __file__ for diagnostics if we don't have
|
||||
// an origin that is a location
|
||||
origin = PyModule_GetFilenameObject(v);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue