-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
bpo-36876: Make some static string literal arrays constant. #15760
Conversation
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, a few formatting nits around whitespace I found.
@@ -3735,7 +3735,7 @@ dec_##MPDFUNC(PyObject *self, PyObject *args, PyObject *kwds) \ | |||
static PyObject * \ | |||
dec_##MPDFUNC(PyObject *self, PyObject *args, PyObject *kwds) \ | |||
{ \ | |||
static char *kwlist[] = {"other", "context", NULL}; \ | |||
static const char *kwlist[] = {"other", "context", 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.
Few other alignment issues like the ones above - probably best to align the newline escapes as above.
When you're done making the requested changes, leave the comment: |
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.
Here are all the alignment issues I found. Hopefully the "suggestions" are the right number of spaces.
@@ -1278,7 +1278,7 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict) | |||
HANDLE fh = 0; | |||
int access = (access_mode)ACCESS_DEFAULT; | |||
DWORD flProtect, dwDesiredAccess; | |||
static char *keywords[] = { "fileno", "length", | |||
static const char *keywords[] = { "fileno", "length", |
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.
Next two lines are also misaligned.
@@ -8976,7 +8976,7 @@ posix_sendfile(PyObject *self, PyObject *args, PyObject *kwdict) | |||
struct sf_hdtr sf; | |||
int flags = 0; | |||
/* Beware that "in" clashes with Python's own "in" operator keyword */ | |||
static char *keywords[] = {"out", "in", | |||
static const char *keywords[] = {"out", "in", | |||
"offset", "count", |
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.
Alignment here again.
@@ -9092,7 +9092,7 @@ posix_sendfile(PyObject *self, PyObject *args, PyObject *kwdict) | |||
#else | |||
Py_ssize_t count; | |||
PyObject *offobj; | |||
static char *keywords[] = {"out", "in", | |||
static const char *keywords[] = {"out", "in", |
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.
Alignment again.
@@ -1024,7 +1024,7 @@ get_source_line(PyObject *module_globals, int lineno) | |||
static PyObject * | |||
warnings_warn_explicit(PyObject *self, PyObject *args, PyObject *kwds) | |||
{ | |||
static char *kwd_list[] = {"message", "category", "filename", "lineno", | |||
static const char *kwd_list[] = {"message", "category", "filename", "lineno", | |||
"module", "registry", "module_globals", |
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.
Alignment here again.
Changing It is possible to change the API, but it is long a complex process. It is a separate issue. Adding consts in |
Note also that you can add two See #15824 for changes in |
Co-Authored-By: Paul Ganssle <p.ganssle@gmail.com>
Co-Authored-By: Paul Ganssle <p.ganssle@gmail.com>
Co-Authored-By: Paul Ganssle <p.ganssle@gmail.com>
Co-Authored-By: Paul Ganssle <p.ganssle@gmail.com>
Co-Authored-By: Paul Ganssle <p.ganssle@gmail.com>
Hmm, this won't work out. |
@serhiy-storchaka, could you, please, elaborate on
At the time the lack of const causes problems i. e. when compiling in MSVC standard conformance mode (which is default for |
This gives us guarantees about immutability.
https://bugs.python.org/issue36876