Josh Rosenberg added the comment:

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.

----------
nosy: +josh.r

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29800>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to