Uh oh!
There was an error while loading. Please reload this page.
gh-94808: Cover %p in PyUnicode_FromFormat - #96677
Conversation
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.
I think a regex test would be better here.
sobolevn
commented
Sep 8, 2022
Good idea, thank you. |
| 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.
What does this case test? I don't see what it adds over the previous case.
There was a problem hiding this comment.
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.
Aren't the additional arguments ignored though, because there is only one %p in the format string?
There was a problem hiding this comment.
I agree, tests can be better :)
Can you please take a look at the updated version?
It now has both:
- Extra types
- Ignored arguments
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.