fn.py icon indicating copy to clipboard operation
fn.py copied to clipboard

Recursion error with flatten and unicodes

Open gabrielpjordao opened this issue 10 years ago • 1 comments

Hey, I get recursion errors on Python 2.7 while executing the following code:

list(flatten([ ['a', u'c'], ['a', 'b'] ]))

I think the issue is here (https://github.com/kachayev/fn.py/blob/master/fn/iters.py#L224), but as I couldn't take a deeper look at it yet, I'm just creating the issue to let you guys know.

gabrielpjordao avatar Nov 18 '14 21:11 gabrielpjordao

Looks like the current implementation would only work in Python 3.

The unicode in u'c' is causing the issue in your case since unicode and str are two different things in Python 2. There is basestring from which both of these inherit, but using that would only work in Python 2 again.

microamp avatar Nov 18 '14 22:11 microamp