Text of bugs.python.org › issue4628 as Styx crawled it on Nov 19, 2026. The page may have changed since. Only its words are kept, without pictures or layout.

Open the live page

Issue 4628: No universal newline support for compile() when using bytes - Python tracker

Python Home About News Documentation Downloads Community Foundation Developer's Guide Issue Tracker Issues Search Random Issue Summaries Issues with patch Easy issues Stats User Administration User List Committer List Help Tracker Documentation Tracker Development Report Tracker Problem Issue4628 ➜ 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.

Created on 2008-12-11 06:54 by brett.cannon , last changed 2022-04-11 14:56 by admin . This issue is now closed . Messages (4) msg77596 - (view) Author: Brett Cannon (brett.cannon) * Date: 2008-12-11 06:54 Passing in bytes to compile() works well for letting the parser handle the decoding of a file when an encoding is specified, but it doesn't take care of universal newlines:: >>> source = b'a = 1\r\nb = 2\r\n' >>> compile(source, '<test>', 'exec') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<test>", line 1 a = 1 ^ SyntaxError: invalid syntax msg83847 - (view) Author: STINNER Victor (vstinner) * Date: 2009-03-20 01:58 This problem is not new. exec() in Python 2.x doesn't accept \r\n newlines.

See also related(?) issue: #5524 msg84127 - (view) Author: STINNER Victor (vstinner) * Date: 2009-03-24 23:44 See also related issue: #4377 (tokenize.detect_encoding() and Mac newline). msg95164 - (view) Author: Benjamin Peterson (benjamin.peterson) * Date: 2009-11-12 23:40 Finally got around to fixing this. r76230 History Date User Action Args 2022-04-11 14:56:42 admin set github: 48878 2009-11-12 23:40:16 benjamin.peterson set status: open -> closed nosy: + benjamin.peterson messages: + msg95164 resolution: fixed 2009-03-24 23:44:28 vstinner set messages: + msg84127 2009-03-21 10:51:36 vstinner link issue4282 dependencies 2009-03-21 10:48:16 vstinner link issue5524 dependencies 2009-03-20 01:58:31 vstinner set nosy: + vstinner messages: + msg83847 2008-12-11 06:54:06 brett.cannon create Supported by The Python Software Foundation , Powered by Roundup Copyright © 1990-2022, Python Software Foundation Legal Statements