Skip to content
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

maximum recursion depth exceeded in width_aware_slice #88

Closed
sshilovsky opened this issue Feb 27, 2016 · 2 comments
Closed

maximum recursion depth exceeded in width_aware_slice #88

sshilovsky opened this issue Feb 27, 2016 · 2 comments

Comments

@sshilovsky
Copy link

>>> FmtStr(u'').width_aware_slice(0)
RuntimeError: maximum recursion depth exceeded

expected:

IndexError
>>> FmtStr(u'').width_aware_slice(slice(0, 100, None))
RuntimeError: maximum recursion depth exceeded

expected:

FmtStr(u'')

curtsies 0.2.6, python 2.7

@thomasballinger
Copy link
Member

Hm that's sure not great.

This is because FmtStr's constructor doesn't take unicode strings, and should not be directly constructed. Instead, use

>>> from curtsies.formatstring import fmtstr
>>> f = fmtstr(u'asdf')
>>> f.width_aware_slice(2)
'd'

However this is very confusing. I'll look at doing a typecheck in the constructor, and at least adding a docstring. There are some typechecks currently in the code that have been commented out because they were killing performance.

If I designed this again I would absolutely use a classmethod for this instead and use something like fmtstr for the constructor.

@thomasballinger
Copy link
Member

Closed because I'm not changing the (poor) api anytime soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants