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
Further limited API fixes #5798
Conversation
da-woods
commented
Nov 5, 2023
- A bunch of tests enabled (mostly already working)
- (some) fstrings work.
- cython.array works
- assorted other small fixes
1. A bunch of tests enabled (mostly already working) 2. (some) fstrings work. 3. cython.array works 4. assorted other small fixes
@@ -409,12 +409,12 @@ def make_length_call(): | |||
PyBytes_AS_STRING_func_type = PyrexTypes.CFuncType( | |||
PyrexTypes.c_char_ptr_type, [ | |||
PyrexTypes.CFuncTypeArg("s", Builtin.bytes_type, None) | |||
]) | |||
], exception_value="NULL") |
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.
I'd quite like some way to enable the exception check only when a macro is defined (to avoid generating the code on non-limited api cases). Probably an improvement for the future rather than this PR though.
and a few other small tweaks
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.
Looks good overall, comments below.
#else | ||
base = PyTuple_GetItem(bases, i); | ||
if (!base) goto error; | ||
#endif |
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.
We should incref base
if we "avoid borrowed refs". We do too many operations below to keep it as a borrowed reference for all that time.
#if CYTHON_ASSUME_SAFE_MACROS | ||
#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) | ||
#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) | ||
#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) | ||
#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) | ||
#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) | ||
#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) | ||
#else | ||
#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AsString(s)) | ||
#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AsString(s)) | ||
#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AsString(s)) | ||
#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AsString(s)) | ||
#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AsString(s)) | ||
#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AsString(s)) | ||
#endif |
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.
I do hope that we actually do error checking on these. We didn't need it before, so it seems worth taking a look.
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.
The two I've used in Optimize.py have error checking (because I added it). For their use in PyrexTypes.py, they have error checking because self.exception_value = NULL
(
cython/Cython/Compiler/PyrexTypes.py
Line 2683 in bcc22ca
self.exception_value = "NULL" |
Co-authored-by: scoder <stefan_ml@behnel.de>
and enable a couple more tests
It isn't actually usable because it cimports other modules but it does build without warning. Changes are mainly to string handling (because that's the nature of parsing). Depends on cython#5841 and cython#5798 to actually build, but the PR itself doesn't depend on those
It isn't actually usable because it cimports other modules but it does build without warning. Changes are mainly to string handling (because that's the nature of parsing). Depends on cython#5841 and cython#5798 to actually build, but the PR itself doesn't depend on those