-
Notifications
You must be signed in to change notification settings - Fork 137
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
Don't die while serializing a stack trace if __repr__ throws #102
Conversation
Nice! @coryvirok @brianr can we review this and get it merged? (It looks good to me). |
Very nice. Can you add a test which throws an Exception in E.g. class CustomUnicodeRepr(object):
def __str__(self):
return SNOWMAN
def __repr__(self):
assert False I think we will need to handle For that, I would use the |
@coryvirok Did you mean that the exception should throw a class UnStringableException(Exception):
def __str__(self):
return SNOWMAN.decode()
class CustomRepr(object):
def __repr__(self):
raise UnStringableException() Is that what you were going for? (It didn't raise with just |
Ah, yes. That is what I'm looking for. Although, I don't think you need to do the |
Oh the joys of Python 2 and Unicode. Here's an example of how we can break things: >>> SNOWMAN = b'\xe2\x98\x83'
>>> SNOWMAN_UNICODE = SNOWMAN.decode('utf8')
>>> class Foo(Exception):
... def __init__(self):
... super(Foo, self).__init__(SNOWMAN_UNICODE)
...
>>> f = Foo()
>>> str(f)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2603' in position 0: ordinal not in range(128) |
Hmm.
So I just wrote my own thing that catches any kind of exception in |
Oops, looks like we crossed wires a bit! I see what the problem is--you were supplying Anyway, I think my point 2 (and general robustness considerations) still make me lean towards the |
Your implementation looks good. Is this ready to be merged and released? |
As far as I know, yes! |
Don't die while serializing a stack trace if __repr__ throws
Released v0.11.5 |
As discussed in #101.