| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
@encukou, aside from the other things this PR does, it should also take care of the problem with is_singlephase() you described in #117953 (comment). |
Sorry, something went wrong.
There was a problem hiding this comment.
Thank you! I have a few comments of the nitpicky kind.
Sorry, something went wrong.
| } | ||
|
|
||
| static bool | ||
| check_multiphase_preinit(PyModuleDef *def) |
There was a problem hiding this comment.
Nitpick: consider making these do the assert, and naming them assert_multiphase_preinit & assert_singlephase. “check” is ambigous (should it do the assert?), and there aren't really suitable for anything but asserts.
Sorry, something went wrong.
There was a problem hiding this comment.
done
Sorry, something went wrong.
| // XXX Two modules should not share the same def->m_base. | ||
| //assert(def->m_base.m_init == NULL | ||
| // || def->m_base.m_init == singlephase->m_init); |
There was a problem hiding this comment.
Hm, I don't remember why this is here.
Let's have the tests find where this was needed? A debug-build assert probably is the best tool.
| // XXX Two modules should not share the same def->m_base. | |
| //assert(def->m_base.m_init == NULL | |
| // || def->m_base.m_init == singlephase->m_init); | |
| // The following assert used to be skipped if | |
| // def->m_base.m_init == singlephase->m_init | |
| // but two modules should not share the same def->m_base. | |
| assert(def->m_base.m_init == NULL); |
Sorry, something went wrong.
There was a problem hiding this comment.
Yeah, that isn't very clear and the commented-out assert isn't helping matters. I'll clarify the comment and drop the rest.
Sorry, something went wrong.
There was a problem hiding this comment.
done
Sorry, something went wrong.
| return NULL; | ||
| } | ||
| assert(!PyErr_Occurred()); | ||
| assert(!PyErr_Occurred() && res.err == NULL); |
There was a problem hiding this comment.
Let this tell you which one went wrong.
| assert(!PyErr_Occurred() && res.err == NULL); | |
| assert(!PyErr_Occurred()); | |
| assert(res.err == NULL); |
Sorry, something went wrong.
There was a problem hiding this comment.
done
Sorry, something went wrong.
|
|
||
| // XXX __file__ doesn't get set! |
There was a problem hiding this comment.
This is now solved, file gets set elsewhere.
| // XXX __file__ doesn't get set! |
Sorry, something went wrong.
There was a problem hiding this comment.
While the import machinery (in importlib._bootstrap) does set __file__, the only place it gets set for a single-phase init module via _imp.load_dynamic (ergo ExtensionFileLoader.exec_module()) is the first time it is loaded, in import_run_extension(). In the above case, the module was found in the global cache and gets reloaded from the cached init function.
I was going to clarify the comment, but it would be just as easy to actually set __file__ and be done with it. 😄
Sorry, something went wrong.
There was a problem hiding this comment.
done
Sorry, something went wrong.
| goto finally; | ||
| } | ||
| assert(!PyErr_Occurred()); | ||
| assert(!PyErr_Occurred() && res.err == NULL); |
There was a problem hiding this comment.
| assert(!PyErr_Occurred() && res.err == NULL); | |
| assert(!PyErr_Occurred()); | |
| assert(res.err == NULL); |
Sorry, something went wrong.
There was a problem hiding this comment.
done
Sorry, something went wrong.
| } | ||
|
|
||
| if (err->exc != NULL) { | ||
| PyErr_SetRaisedException(err->exc); |
There was a problem hiding this comment.
Consider warning the reader about that function's quirk:
| PyErr_SetRaisedException(err->exc); | |
| PyErr_SetRaisedException(err->exc); | |
| err->exc = NULL; /* SetRaisedException stole our reference */ |
Maybe it would be better to merge _Py_ext_module_loader_result_apply_error and _Py_ext_module_loader_result_clear? They're effectively always used together (with apply skipped on success).
Sorry, something went wrong.
There was a problem hiding this comment.
done
Sorry, something went wrong.
| } | ||
|
|
||
| assert(!PyErr_Occurred()); | ||
| assert(!PyErr_Occurred() && res.err == NULL); |
There was a problem hiding this comment.
| assert(!PyErr_Occurred() && res.err == NULL); | |
| assert(!PyErr_Occurred()); | |
| aeesrt(res.err == NULL); |
Sorry, something went wrong.
There was a problem hiding this comment.
done
Sorry, something went wrong.
…sult_apply_error().
…ort Machinery (pythongh-118205) This change will make some later changes simpler.
| Back | FazBrowse Home | New Git URL |
I've pulled this out of #118116.
This change will make some later changes simpler.