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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-113537: support loads str in plistlib.loads #113582
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.
plistlib supports two formats for the plist file: XML and Binary. Accepting strings for input is only useful for the XML format.
The loads implementation should assert that fmt == FMT_XML when the value is a string and raise ValueError when it is not. This also needs to be tested.
|
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 |
Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
Updated, but I think raising a |
I agree. |
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.
Getting there!
The PR looks good at this point, just some minor changes.
Lib/plistlib.py
Outdated
| msg = "value must be bytes-like oebject when fmt is FMT_BINARY" | ||
| raise TypeError(msg) |
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.
| msg = "value must be bytes-like oebject when fmt is FMT_BINARY" | |
| raise TypeError(msg) | |
| raise TypeError("value must be bytes-like object when fmt is FMT_BINARY") |
The msg variable is not necessary (also fixes a typo in the message itself)
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.
Thanks for the review, I fixed the typo, but kept the msg variable. It's here to make the line length shorter than 80.
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 still don't like introducing a variable for the message here. You could do this instead:
raise TypeError(
"value must be bytes-like object when fmt is FMT_BINARY"
)If I counted correctly this just about fits into 80 characters. Alternatively split the string:
raise TypeError(
"value must be bytes-like object "
"when fmt is FMT_BINARY"
)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.
Got it, updated.
Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
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.
Thanks for the PR!
|
Thanks for the view! |
strtype parameter inplistlib.loads聽#113537馃摎 Documentation preview 馃摎: https://cpython-previews--113582.org.readthedocs.build/