[New-bugs-announce] [issue18873] "Encoding" detected in non-comment lines

Paul Bonser report at bugs.python.org
Thu Aug 29 01:50:28 CEST 2013


New submission from Paul Bonser:

lib2to3.pgen2.tokenize:detect_encoding looks for the regex "coding[:=]\s*([-\w.]+)" in the first two lines of the file without first checking if they are comment lines.

You can get 2to3 to fail with "SyntaxError: unknown encoding: 0" with a single line file:

    coding=0

A simple fix would be to check that the line is a comment before trying to look up the encoding from that line.

----------
components: 2to3 (2.x to 3.x conversion tool)
messages: 196435
nosy: Paul.Bonser
priority: normal
severity: normal
status: open
title: "Encoding" detected in non-comment lines
type: crash
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18873>
_______________________________________


More information about the New-bugs-announce mailing list