Repository navigation
On Python 3.13.0a6+, use the %T format in exception messages - #17
Merged
Merged
Conversation
That avoids the responsibility for a possible raise in Py_TYPE(args[...])->tp_name when the GIL is disabled. Related to fedora-python#16
frenzymadness
left a comment
Member
There was a problem hiding this comment.
This is good as is and it works as expected.
One idea for improvement: What about having a helper like:
/* Set a TypeError complaining that argument `argno` (named `argname`) must be
* a string rather than the type of `obj`. Uses the %T format on Python
* 3.13.0a6+, falling back to tp_name on older versions. */
static void
set_crypt_type_error(int argno, const char *argname, PyObject *obj)
{
#if PY_VERSION_HEX >= 0x030d00a6
PyErr_Format(
PyExc_TypeError, "crypt argument %d (%s) must be string, not %T",
argno, argname, obj
);
#else
PyErr_Format(
PyExc_TypeError, "crypt argument %d (%s) must be string, not %s",
argno, argname, Py_TYPE(obj)->tp_name
);
#endif
}and then just calling it twice like:
set_crypt_type_error(1, "word", args[0]);and
set_crypt_type_error(2, "salt", args[1]);I have it implemented. Say yes and I'll push it here.
Member
Author
|
yes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
That avoids the responsibility for a possible raise in Py_TYPE(args[...])->tp_name when the GIL is disabled.
Related to #16