-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-35384: The repr of ctypes.CArgObject no longer fail for non-ascii character. #10863
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
bpo-35384: The repr of ctypes.CArgObject no longer fail for non-ascii character. #10863
Conversation
Modules/_ctypes/callproc.c
Outdated
@@ -514,8 +522,8 @@ PyCArg_repr(PyCArgObject *self) | |||
break; | |||
|
|||
default: | |||
sprintf(buffer, "<cparam '%c' at %p>", | |||
self->tag, self); | |||
sprintf(buffer, "<cparam %02x' at %p>", |
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.
Looks as if this change accidentally removed the opening apostrophe.
sprintf(buffer, "<cparam %02x' at %p>", | |
sprintf(buffer, "<cparam '%02x' at %p>", |
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 the opposite. I have forgot to remove the closing apostrophe.
Modules/_ctypes/callproc.c
Outdated
self->tag, self->value.c); | ||
break; | ||
if ((unsigned char)self->value.c < 128 | ||
&& _PyUnicode_IsPrintable(self->value.c) |
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.
Is printability the right test here? Tab, newline, carriage return, vertical tab, form feed are all printable but probably don't make sense in this context.
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.
'\t'.isprintable()
returns False.
Modules/_ctypes/callproc.c
Outdated
break; | ||
if ((unsigned char)self->value.c < 128 | ||
&& _PyUnicode_IsPrintable(self->value.c) | ||
&& self->value.c != '\'') |
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.
Is the goal here to make the output look like a syntactically valid Python string? If so, you should also exclude backslash.
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.
Good catch. Yes, the goal here to make the output look like a syntactically valid Python or C.
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6, 3.7. |
GH-10983 is a backport of this pull request to the 3.7 branch. |
…i character. (pythonGH-10863) (cherry picked from commit 3ffa8b9) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
GH-10984 is a backport of this pull request to the 3.6 branch. |
…i character. (pythonGH-10863) (cherry picked from commit 3ffa8b9) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7. |
GH-10985 is a backport of this pull request to the 3.7 branch. |
…i character. (pythonGH-10863) (cherry picked from commit 3ffa8b9) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
https://bugs.python.org/issue35384