-
-
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
Changes from 3 commits
45f0bcc
9faf155
ad127bd
0213fab
111a173
af4ba72
cb76e61
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 |
|---|---|---|
|
|
@@ -2807,6 +2807,19 @@ def check_format(expected, format, *args): | |
| check_format('repr=abc', | ||
| b'repr=%V', 'abc', b'xyz') | ||
|
|
||
| # test %p | ||
| # We cannot test the exact result, | ||
| # because it returns a hex representation of a C pointer, | ||
| # which is going to be different each time. But, we can test the format. | ||
| p_format_regex = r'0x[a-zA-Z0-9]{8,}' | ||
| p_format1 = PyUnicode_FromFormat(b'%p', 'abc') | ||
| self.assertIsInstance(p_format1, str) | ||
| self.assertRegex(p_format1, p_format_regex) | ||
|
|
||
| p_format2 = PyUnicode_FromFormat(b'repr=%p', '123456', None, b'xyz') | ||
|
||
| self.assertIsInstance(p_format2, str) | ||
| self.assertRegex(p_format2, p_format_regex) | ||
|
|
||
| # Test string decode from parameter of %s using utf-8. | ||
| # b'\xe4\xba\xba\xe6\xb0\x91' is utf-8 encoded byte sequence of | ||
| # '\u4eba\u6c11' | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.