summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorShantanu <12621235+hauntsaninja@users.noreply.github.com>2024-12-20 08:22:26 (GMT)
committerGitHub <noreply@github.com>2024-12-20 08:22:26 (GMT)
commit45e6dd63b88a782f2ec96ab1da54eb5a074d8f4c (patch)
treefad1d18683f0a9bd13d538c3626bedc0988653d3 /Python
parentdaa260ebb1c1b20321e7f26df7c9dbd35d4edcbf (diff)
downloadcpython-45e6dd63b88a782f2ec96ab1da54eb5a074d8f4c.zip
cpython-45e6dd63b88a782f2ec96ab1da54eb5a074d8f4c.tar.gz
cpython-45e6dd63b88a782f2ec96ab1da54eb5a074d8f4c.tar.bz2
gh-128030: Avoid error from PyModule_GetFilenameObject for non-module (#128047)
I missed the extra `PyModule_Check` in #127660 because I was looking at 3.12 as the base implementation for import from. This meant that I missed the `PyModuleCheck` introduced in #112661.
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index fd891d7..bfdf568 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2860,7 +2860,7 @@ _PyEval_ImportFrom(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);