This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author josh.r
Recipients MSeifert, josh.r
Date 2017-03-13.17:51:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1489427480.01.0.994558400361.issue29800@psf.upfronthosting.co.za>
In-reply-to
Content
I feel like adding a type check to partial_repr might not be the correct fix here. If PyUnicode_FromFormat returned NULL and set an exception here, then the existing code would work as written (raising an exception, but not segfaulting).

Alternatively, if the code in question used %S for the key instead of %U, it would also work as written (not raising an exception or segfaulting).

It's extremely strange to have something accepted, then raise exceptions in the repr of all places, and adding extra special purpose code for that specific purpose seems odd, to say the least.

I think I'd be in favor of using %S personally, since %U should only be used when you have absolute guarantees that the object is a Unicode object, which we can't give here. Sure, an invalid state passes without notice in the repr, but I'm not sure that bothers me so much; if they actually try to call the invalid partial they'll get the TypeError they deserve at a time when the type finally matters.
History
Date User Action Args
2017-03-13 17:51:20josh.rsetrecipients: + josh.r, MSeifert
2017-03-13 17:51:20josh.rsetmessageid: <1489427480.01.0.994558400361.issue29800@psf.upfronthosting.co.za>
2017-03-13 17:51:19josh.rlinkissue29800 messages
2017-03-13 17:51:19josh.rcreate