-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-21071: struct.Struct.format type is now str #845
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -374,6 +374,9 @@ Extension Modules | |
Library | ||
------- | ||
|
||
- bpo-21071: struct.Struct.format type is now :class:`str` instead of | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think |
||
:class:`bytes`. | ||
|
||
- bpo-29212: Fix concurrent.futures.thread.ThreadPoolExecutor threads to have | ||
a non repr() based thread name by default when no thread_name_prefix is | ||
supplied. They will now identify themselves as "ThreadPoolExecutor-y_n". | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1957,8 +1957,8 @@ s_pack_into(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames | |
static PyObject * | ||
s_get_format(PyStructObject *self, void *unused) | ||
{ | ||
Py_INCREF(self->s_format); | ||
return self->s_format; | ||
return PyUnicode_FromStringAndSize(PyBytes_AS_STRING(self->s_format), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not make There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to write minimum changes. I expect that most of the code is written to work with C strings char*, not with Python Unicode strings. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW I already did this in my format-str.patch. I was able to get a char* out of the string with PyUnicode_AsUTF8. |
||
PyBytes_GET_SIZE(self->s_format)); | ||
} | ||
|
||
static PyObject * | ||
|
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.
IMO,
self.assertIsInstance(s.format, str)
would be better to understand (for future readers) the behavior change.