Terry J. Reedy added the comment:
While I am closing this as a duplicate, I will use some of your patch,
including one test, and credit you as well.
Switching from 5-tuples to 2-tuples, as in one of your test cases, is not
currently a supported use case, Compat currently re-iterates the entire token
list and that does not work if some tokens have already been processed. While
iter(iterable) makes your toy example pass, switching still does not work
because of the problem of initializing compat.
indents = []
This could only work with switching by making it a instance attribute which is
also updated in the 5-tuple case. It is needed in tokenize also to support tab
indents (#20383) but would only need to be an attribute instead of a local to
support switching.
startline = token[0] in (NEWLINE, NL) (my replacement for 3 lines)
This is odd as the the file starts at the start of a line whether or not the
first token is \n. On the other hand, the initial value of startline is
irrelevant as long as it has some value because it is irrelevant until there
has been an indent. It would also have to become an attribute to support
switching and then it would be relevant since indents might not be initially
empty. But I do not currently see the need for a tuple length switching feature.
prevstring = False
This does not matter even if wrong since it only means adding a space.
----------
assignee: eric.snow -> terry.reedy
nosy: +terry.reedy
resolution: -> duplicate
status: open -> closed
versions: -Python 3.2
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue16224>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com