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.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user