GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — bpo-1635741: Port _locale extension module to multiphase initialization (PEP 489) by shihai1991 · Pull Request #18358 · python/cpython Conversation
|
Codecov Report
@@ Coverage Diff @@ ## master #18358 +/- ## ========================================== - Coverage 82.11% 82.07% -0.05% ========================================== Files 1955 1955 Lines 588624 584187 -4437 Branches 44406 44464 +58 ========================================== - Hits 483366 479456 -3910 + Misses 95615 95110 -505 + Partials 9643 9621 -22
Continue to review full report at Codecov.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| state = PyModule_GetState(self); | ||
| if (state == NULL) { | ||
| return NULL; | ||
| } |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I don't think that it's worth it to check for error: this function cannot fail, self is always a module object.
I would prefer a function like:
static inline _locale_state* get_locale_state(PyObject *mod)
{
void *state = PyModule_GetState(mod);
assert(state != NULL);
return (_locale_state*)state;
}
And then use:
PyErr_SetString(get_locale_state(self)->Error, "invalid locale category");
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Make sense, I update this PR.
Do we need add a global macros of get_state?
I found some other extension modules use local macro do this behavior too. such as: https://github.com/python/cpython/blob/master/Modules/_hashopenssl.c#L55
Thanks a million, victor. You helpe me merge much PRs today ;)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
A static inline function is a bit better than a macro.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sure, I remember victor have explained in other bpo/PR(oh, I forgot which one is). It's easy for debuging and something else.
I will try to add this inline function in free time.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Looks CI gate of |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I remove assert operation in some error info like: and the trace back: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I have made the requested changes; please review again. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for making the requested changes! @encukou: please review the changes made to this pull request. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The assertion was good! If you remove it, you should add I hope you don't mind me pushing to this branch directly – I already made the change and ran tests on it locally. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
petr, pls go ahead ;) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Hi, petr. Do you have wins env to test this PR? #18608. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I plan to merge when I have time to watch the buildbots afterwards.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| locale_traverse(PyObject *m, visitproc visit, void *arg) | ||
| { | ||
| _locale_state *state = (_locale_state*)PyModule_GetState(m); | ||
| if (state) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
As I asked on your two other PRs (binascii, audioop), I don't think that state can be NULL here. Same remark in locale_clear().
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Hi, victor. There have some description info about traverse slot in https://docs.python.org/3/c-api/module.html?highlight=pymoduledef#c.PyModuleDef:
A traversal function to call during GC traversal of the module object, or NULL if not needed. This function may be called before module state is allocated (PyModule_GetState() may return NULL), and before the Py_mod_exec function is executed.
So this behavior is a planned behavior, isn't it?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Let's discuss that in https://bugs.python.org/issue39824
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The discussion won't be over before Nick Coghlan is satisfied (and that's a good thing!)
Meanwhile, this PR is correct according to current behavior and documentation. I don't think bpo-39824 should block it.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Alright. I expected https://bugs.python.org/issue39824 to be resolved quick, but I'm ok to merge @shihai1991 PR's first, and revisit the code later if we decided that m_clear/m_free cannot be called with a NULL state.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.