Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-94808: Cover %p in PyUnicode_FromFormat#96677
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
sobolevn commented Sep 8, 2022 • edited by bedevere-bot
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by bedevere-bot
Uh oh!
There was an error while loading. Please reload this page.
sobolevn commented Sep 8, 2022 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
And we got a failure: MacOS passes locally and on CI, but other platforms do not. Windows: Ubuntu: I think it is better to remove |
kumaraditya303 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.
I think a regex test would be better here.
sobolevn commented Sep 8, 2022
Good idea, thank you. |
Lib/test/test_unicode.py Outdated
| self.assertIsInstance(p_format1, str) | ||
| self.assertRegex(p_format1, p_format_regex) | ||
| p_format2=PyUnicode_FromFormat(b'repr=%p', '123456', None, b'xyz') |
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.
What does this case test? I don't see what it adds over the previous case.
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.
It has:
- Multiple arguments (while
p_format1only has one arg) - All arguments have different types
- New types are tested:
bytesandNone
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.
Aren't the additional arguments ignored though, because there is only one %p in the format string?
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 agree, tests can be better :)
Can you please take a look at the updated version?
It now has both:
- Extra types
- Ignored arguments
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!
sobolevn commented Oct 6, 2022
From https://github.com/python/cpython/actions/runs/3200613350/jobs/5227726848 This is quite interesting. Is |
JelleZijlstra commented Oct 6, 2022
Interesting! I think that comes from libc since I can't find code in CPython that would do this. |
sobolevn commented Oct 6, 2022
From https://pubs.opengroup.org/onlinepubs/009695399/functions/fprintf.html
I think it is better to just leave Related discussions: |
JelleZijlstra commented Oct 6, 2022
I think ctypes translates None into NULL, which is reasonable. |
Uh oh!
There was an error while loading. Please reload this page.
miss-islington commented Oct 7, 2022
Thanks @sobolevn for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11. |
miss-islington commented Oct 7, 2022
Sorry @sobolevn and @JelleZijlstra, I had trouble checking out the |
bedevere-bot commented Oct 7, 2022
GH-98032 is a backport of this pull request to the 3.10 branch. |
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> (cherry picked from commit 72c166a) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
miss-islington commented Oct 7, 2022
Thanks @sobolevn for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11. |
bedevere-bot commented Oct 7, 2022
GH-98033 is a backport of this pull request to the 3.11 branch. |
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> (cherry picked from commit 72c166a) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
bedevere-bot commented Oct 7, 2022
|
JelleZijlstra commented Oct 7, 2022
I guess the pointers are shorter on s390. I'll adjust the regex. |
JelleZijlstra commented Oct 7, 2022
bedevere-bot commented Oct 7, 2022
|
bedevere-bot commented Oct 7, 2022
|
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Source:
cpython/Objects/unicodeobject.c
Lines 2531 to 2552 in 4f523a7
Internet says that some systems can return representation with
0x, some with0X, and some with none. It is reflected in the implementation, but cannot be reflected in tests.