Uh oh!
There was an error while loading. Please reload this page.
gh-106078: Move static objects related to CONTEXTVAR to the decimal module global state - #106395
Conversation
Fix build error with flag `--without-decimal-contextvar`
CONTEXTVAR to decimal module global stateCONTEXTVAR to the decimal module global stateCharlieZhao95
commented
Jul 4, 2023
I executed the build and unit tests locally as follows. The result looks good. # build
./configure --without-decimal-contextvar
make
# unittest
./python -m test test_decimal
cd ./Modules/_decimal/tests
./runall-memorydebugger.shBTW, do we have a CI pipeline that tests build with different compile options, such as |
CharlieZhao95
commented
Jul 4, 2023
erlend-aasland
left a comment
There was a problem hiding this comment.
Instead of moving the entire struct, you can use forward declarations for the needed types.
bedevere-bot
commented
Jul 4, 2023
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 |
CharlieZhao95
commented
Jul 4, 2023
This is an alias for an anonymous struct. We cannot forward declare anonymous structs or typedefs :( A solution is to name these structs. For example: structPyDecContextObject;
typedefstruct {
...
structPyDecContextObject*cached_context;
...
} decimal_state;
typedefstructPyDecContextObject {
PyObject_HEADmpd_context_tctx;
PyObject*traps;
PyObject*flags;
intcapitals;
PyThreadState*tstate;
} PyDecContextObject;There is no harm and now you can forward declare it. |
It's no hinder that the structs are anonymous. C has solutions for that as well. Let me know if you need a hint. Alternatively, add a name to them. There is no harm in that, and it is quite normal throughout the code base. Examples:
|
CharlieZhao95
commented
Jul 4, 2023
I don't know if your solution is to move the
Thanks! I prefer to add names to these structures :) |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
erlend-aasland
left a comment
There was a problem hiding this comment.
Tested locally with ./configure --without-decimal-contextvar. LGTM.
Move following objects related to the
CONTEXTVARto decimal module global state._decimalextension module #106078