-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-106078: Move static objects related to CONTEXTVAR
to the decimal module global state
#106395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fix build error with flag `--without-decimal-contextvar`
CONTEXTVAR
to decimal module global stateCONTEXTVAR
to the decimal module global state
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.sh BTW, do we have a CI pipeline that tests build with different compile options, such as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of moving the entire struct, you can use forward declarations for the needed types.
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 |
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: struct PyDecContextObject;
typedef struct {
...
struct PyDecContextObject *cached_context;
...
} decimal_state;
typedef struct PyDecContextObject {
PyObject_HEAD
mpd_context_t ctx;
PyObject *traps;
PyObject *flags;
int capitals;
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:
|
I don't know if your solution is to move the
Thanks! I prefer to add names to these structures :) |
Co-authored-by: Erlend E. Aasland <[email protected]>
Co-authored-by: Erlend E. Aasland <[email protected]>
Co-authored-by: Erlend E. Aasland <[email protected]>
Co-authored-by: Erlend E. Aasland <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally with ./configure --without-decimal-contextvar
. LGTM.
Move following objects related to the
CONTEXTVAR
to decimal module global state._decimal
extension module #106078