Skip to content

No universal newline support for compile() when using bytes #48878

Closed

Description

@brettcannon
BPO 4628
Nosy @brettcannon, @vstinner, @benjaminp

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2009-11-12.23:40:16.739>
created_at = <Date 2008-12-11.06:54:06.688>
labels = ['interpreter-core', 'type-bug']
title = 'No universal newline support for compile() when using bytes'
updated_at = <Date 2009-11-12.23:40:16.733>
user = 'https://github.com/brettcannon'

bugs.python.org fields:

activity = <Date 2009-11-12.23:40:16.733>
actor = 'benjamin.peterson'
assignee = 'none'
closed = True
closed_date = <Date 2009-11-12.23:40:16.739>
closer = 'benjamin.peterson'
components = ['Interpreter Core']
creation = <Date 2008-12-11.06:54:06.688>
creator = 'brett.cannon'
dependencies = []
files = []
hgrepos = []
issue_num = 4628
keywords = []
message_count = 4.0
messages = ['77596', '83847', '84127', '95164']
nosy_count = 3.0
nosy_names = ['brett.cannon', 'vstinner', 'benjamin.peterson']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'needs patch'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue4628'
versions = ['Python 3.0']

Activity

  1. brettcannon commented on Dec 11, 2008

    @brettcannon
    MemberAuthor

    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
  2. added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)
    type-bugAn unexpected behavior, bug, or error
    on Dec 11, 2008
  3. vstinner commented on Mar 20, 2009

    @vstinner
    Member

    This problem is not new. exec() in Python 2.x doesn't accept \r\n
    newlines.

    See also related(?) issue: bpo-5524

  4. vstinner commented on Mar 24, 2009

    @vstinner
    Member

    See also related issue: bpo-4377 (tokenize.detect_encoding() and Mac
    newline).

  5. benjaminp commented on Nov 12, 2009

    @benjaminp
    Contributor

    Finally got around to fixing this. r76230

  6. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions