Closed jaraco closed 8 years ago
Thanks for this report. At first, I was astonished and confused, but after some investigation, I have some clarity.
The issue appears to be that str.translate
has a special behavior for when the source string is empty:
>>> class Subclass(str):
... pass
...
>>> type(Subclass().translate({}))
<class '__main__.Subclass'>
>>> type(Subclass('val').translate({}))
<class 'str'>
And the jaraco.text.FoldedCase
and irc.strings.IRCFoldedCase
classes are relying on the fact that .lower
returns a simple str
and not a subclass, but this expectation is violated when the input is empty.
Original comment by: Jason R. Coombs
Bypass call to translate if string is empty, avoiding infinite recursion. Fixes #67.
→ <<cset 4f6017247bef>>
Original comment by: Jason R. Coombs
Add test capturing infinite recursion when string is empty. Ref #67.
→ <<cset 09692c895a5b>>
Original comment by: Jason R. Coombs
Released as 13.1.1.
Original comment by: Jason R. Coombs
Great!
Original comment by: Lukas Erlacher
Yo.
I have this stacktracke from an ircbot using the example TestBot:
As you can see in the trace it originates from the on_pubmsg method of TestBot. Seems like the == is getting resolved to the eq itself.
I figured out what triggers it: It's a message starting with a colon ":", which would make a[0] an empty string.