Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

work around to compile \r\n file #40094

Closed
quiver mannequin opened this issue Mar 28, 2004 · 2 comments
Closed

work around to compile \r\n file #40094

quiver mannequin opened this issue Mar 28, 2004 · 2 comments
Labels
stdlib Python modules in the Lib dir

Comments

@quiver
Copy link
Mannequin

quiver mannequin commented Mar 28, 2004

BPO 924771
Nosy @birkenfeld
Files
  • compile.patch
  • 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 2007-08-23.20:15:47.807>
    created_at = <Date 2004-03-28.06:40:13.000>
    labels = ['library']
    title = 'work around to compile \\r\\n file'
    updated_at = <Date 2007-08-23.20:15:47.805>
    user = 'https://bugs.python.org/quiver'

    bugs.python.org fields:

    activity = <Date 2007-08-23.20:15:47.805>
    actor = 'georg.brandl'
    assignee = 'none'
    closed = True
    closed_date = <Date 2007-08-23.20:15:47.807>
    closer = 'georg.brandl'
    components = ['Library (Lib)']
    creation = <Date 2004-03-28.06:40:13.000>
    creator = 'quiver'
    dependencies = []
    files = ['5899']
    hgrepos = []
    issue_num = 924771
    keywords = ['patch']
    message_count = 2.0
    messages = ['45687', '55198']
    nosy_count = 2.0
    nosy_names = ['georg.brandl', 'quiver']
    pr_nums = []
    priority = 'normal'
    resolution = 'out of date'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue924771'
    versions = ['Python 2.3']

    @quiver
    Copy link
    Mannequin Author

    quiver mannequin commented Mar 28, 2004

    On Unix-like systems, built-in function compile cannot
    compile files that don't use linefeed as an EOL. But there
    are several codes in the library which assume that input
    files use valid EOL characters.
    So when they come across \r\n(or \r) on Unix
    environments, compile causes the parser to raise a
    SyntaxError.

    For example:

    >>> list(file('a.py'))
    ['\r\n']
    >>> import trace
    >>> trace.find_executable_linenos('a.py')
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
      File "/usr/lib/python2.3/trace.py", line 389, in 
    find_executable_linenos
        code = compile(prog, filename, "exec")
      File "a.py", line 1
    ^
    

    SyntaxError: invalid syntax

    Lib/py_compile.py opens files with 'U' option to handle
    file format differences and I think this is the way to go.

    There is one drawback.
    When Python is configured without universal newline
    support, this approach doesn't work :-(

    @quiver quiver mannequin added stdlib Python modules in the Lib dir labels Mar 28, 2004
    @birkenfeld
    Copy link
    Member

    The offending open() call in trace.py is fixed, so closing this.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant