-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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
Conversation
|
@Haypo, thanks for your PR! By analyzing the history of the files in this pull request, we identified @mdickinson, @Yhg1s and @serhiy-storchaka to be potential reviewers. |
Misc/NEWS
Outdated
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.
Unicode instead → Unicode string
bytes string → byte string [or bytes object if you prefer]
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.
Fixed
Doc/library/struct.rst
Outdated
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.
3.6 → 3.7
I think either “byte string” or “bytes object” would read better.
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.
Maybe use just str and bytes? There is nothing specific to the Unicode standard here.
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.
Fixed, I used "str" and "bytes" types.
|
@vadmium, @serhiy-storchaka: I updated my PR to take in account your remarks. Would you mind to review my PR again, please? |
serhiy-storchaka
left a 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.
Since this change breaks backward compatibility, it should be documented in What's New.
What is the result of the discussion on Python-Dev?
Misc/NEWS
Outdated
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 think :class: is not needed.
Modules/_struct.c
Outdated
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.
Why not make s_format an instance of str?
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 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 comment
The 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.
No answer: https://mail.python.org/pipermail/python-dev/2017-March/147688.html |
Ok, done. The change is now documented in the changelog (Misc/NEWS), twice in What's New in Python 3.7 (struct module and Porting to Python 3.7), and in struct documentation. I don't think that you can document it more :-) Seriously, I don't think that anyone rely on the exact type of struct.Struct.format. If someone cares, it will be trivial to notice, and also likely trivial to fix the code. |
serhiy-storchaka
left a 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.
LGTM, but add a reference to the issue and wait yet short time for a reaction on Python-Dev.
Doc/whatsnew/3.7.rst
Outdated
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.
Add a reference to issue.
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.
ok, done
Doc/whatsnew/3.7.rst
Outdated
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.
Actually I'm not sure that mentioning this change here is needed. This is not a new feature.
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.
ok, removed
Lib/test/test_struct.py
Outdated
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.
|
@serhiy-storchaka: "LGTM, but add a reference to the issue and wait yet short time for a reaction on Python-Dev." Serhiy wrote an email to my old thread: @ncoghlan wrote "As long as it's noted in the "Porting to Python 3.7" section of the 3.7 What's New guide, this seems like a sensible change to me." It's the case, I added an entry to Porting to Python 3.7. I will wait until Friday (June 23) evening. |
It's today. I began by rebasing my change. |
No description provided.