This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gdr@garethrees.org
Recipients benjamin.peterson, daniel.urban, docs@python, eric.snow, ezio.melotti, gdr@garethrees.org, meador.inge, sandro.tosi, serhiy.storchaka, takluyver, yselivanov
Date 2014-02-06.15:50:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1391701803.43.0.924025145822.issue12691@psf.upfronthosting.co.za>
In-reply-to
Content
I did some research on the cause of this issue. The assertion was
added in this change by Jeremy Hylton in August 2006:
<https://mail.python.org/pipermail/python-checkins/2006-August/055812.html>
(The corresponding Mercurial commit is here:
<http://hg.python.org/cpython/rev/cc992d75d5b3#l217.25>).

At that point I believe the assertion was reasonable. I think it would
have been triggered by backslash-continued lines, but otherwise it
worked.

But in this change <http://hg.python.org/cpython/rev/51e24512e305> in
March 2008 Trent Nelson applied this patch by Michael Foord
<http://bugs.python.org/file9741/tokenize_patch.diff> to implement PEP
263 and fix issue719888. The patch added ENCODING tokens to the output
of tokenize.tokenize(). The ENCODING token is always generated with
row number 0, while the first actual token is generated with row
number 1. So now every token stream from tokenize.tokenize() sets off
the assertion.

The lack of a test case for tokenize.untokenize() in "full" mode meant
that it was (and is) all too easy for someone to accidentally break it
like this.
History
Date User Action Args
2014-02-06 15:50:03gdr@garethrees.orgsetrecipients: + gdr@garethrees.org, benjamin.peterson, ezio.melotti, meador.inge, daniel.urban, sandro.tosi, docs@python, eric.snow, takluyver, serhiy.storchaka, yselivanov
2014-02-06 15:50:03gdr@garethrees.orgsetmessageid: <1391701803.43.0.924025145822.issue12691@psf.upfronthosting.co.za>
2014-02-06 15:50:03gdr@garethrees.orglinkissue12691 messages
2014-02-06 15:50:03gdr@garethrees.orgcreate