| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
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.
| state = PyModule_GetState(self); | ||
| if (state == NULL) { | ||
| return NULL; | ||
| } |
There was a problem hiding this comment.
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 a problem hiding this comment.
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 a problem hiding this comment.
A static inline function is a bit better than a macro.
Sorry, something went wrong.
There was a problem hiding this comment.
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.
|
Looks CI gate of macOS have broken, I saw some other PR have this problem. |
Sorry, something went wrong.
|
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 I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request. |
Sorry, something went wrong.
|
I remove assert operation in get_locale_state(), becasue this assert operation always failed when I add traverse slot. some error info like: $ ./python -E -S -m sysconfig --generate-posix-vars python: ./Modules/_localemodule.c:52: get_locale_state: Assertion `state != ((void *)0)' failed. [1] 17894 abort ./python -E -S -m sysconfig --generate-posix-vars and the trace back: #0 0x00007ffff6ce2207 in raise () from /lib64/libc.so.6
#1 0x00007ffff6ce38f8 in abort () from /lib64/libc.so.6
#2 0x00007ffff6cdb026 in __assert_fail_base () from /lib64/libc.so.6
#3 0x00007ffff6cdb0d2 in __assert_fail () from /lib64/libc.so.6
#4 0x00000000005986f3 in get_locale_state (m=<optimized out>) at ./Modules/_localemodule.c:52
#5 locale_traverse (m=<optimized out>, visit=0x462d26 <bad_traverse_test>, arg=0x0) at ./Modules/_localemodule.c:780
#6 0x000000000046384c in PyModule_FromDefAndSpec2TraceRefs (def=def@entry=0x96e680 <_localemodule>, spec=spec@entry=0x7ffff00567d0, module_api_version=module_api_version@entry=1013)
at Objects/moduleobject.c:370
#7 0x0000000000512153 in _imp_create_builtin (module=<optimized out>, spec=0x7ffff00567d0) at Python/import.c:1300
|
Sorry, something went wrong.
|
I have made the requested changes; please review again. |
Sorry, something went wrong.
|
Thanks for making the requested changes! @encukou: please review the changes made to this pull request. |
Sorry, something went wrong.
|
The assertion was good! If you remove it, you should add if (state != NULL) checks after any use of get_locale_state. 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.
petr, pls go ahead ;) |
Sorry, something went wrong.
Hi, petr. Do you have wins env to test this PR? #18608. |
Sorry, something went wrong.
There was a problem hiding this comment.
Looks good to me. I plan to merge when I have time to watch the buildbots afterwards.
Sorry, something went wrong.
| 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.
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 a problem hiding this comment.
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 a problem hiding this comment.
Let's discuss that in https://bugs.python.org/issue39824
Sorry, something went wrong.
There was a problem hiding this comment.
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 a problem hiding this comment.
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.
| Back | FazBrowse Home | New Git URL |
https://bugs.python.org/issue1635741