You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# This will only ever match in Python 2 since str_class is str in
# Python 3.
eliftype(thing) ==str:
self.append(unicode(thing)) # noqa: F821 undefined name 'unicode'
In a pdb shell (running latest python 2.7) I get the following output:
(Pdb) ll204defgrow(self, thing):
205"""Make the list longer, appending for unicode, extending otherwise."""206iftype(thing) ==str_class:
207self.append(thing)
208209# This will only ever match in Python 2 since str_class is str in210# Python 3.211eliftype(thing) ==str:
212self.append(unicode(thing)) # noqa: F821 undefined name 'unicode'213214else:
215# Recursively expand to a flat list; may deserve a C accelerator at216# some point.217forelementinthing:
218->self.grow(element)
(Pdb) str<type'str'>
(Pdb) str_class<type'unicode'>
(Pdb) type(thing)
<class'future.types.newstr.newstr'>
(Pdb) isinstance(thing, str)
False
(Pdb) isinstance(thing, str_class)
True
I suspect just changing the type(thing) == str_class lines to isinstance(type, str_class) will fix the issue.
The text was updated successfully, but these errors were encountered:
If you give
strlist.grow
a subclass ofstr
,strlist.grow
will infinitely recurse.This has come up because of changes using
futurize.builtins.str
made in an effort to make sourcecode compatible with python 2 and python 3.It looks like the very strict type checks here are to blame:
pybars3/pybars/_compiler.py
Lines 191 to 197 in 7a8bd6d
In a pdb shell (running latest python 2.7) I get the following output:
I suspect just changing the
type(thing) == str_class
lines toisinstance(type, str_class)
will fix the issue.The text was updated successfully, but these errors were encountered: