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

binhex() creates files with mixed line endings #73752

Closed
serhiy-storchaka opened this issue Feb 15, 2017 · 5 comments
Closed

binhex() creates files with mixed line endings #73752

serhiy-storchaka opened this issue Feb 15, 2017 · 5 comments
Labels
3.8 only security fixes 3.9 only security fixes 3.10 only security fixes OS-mac type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 29566
Nosy @ronaldoussoren, @ned-deily, @serhiy-storchaka, @miss-islington
PRs
  • bpo-29566: binhex.binhex now consitently writes MacOS 9 line endings. #23059
  • [3.8] bpo-29566: binhex.binhex now consitently writes MacOS 9 line endings. (GH-23059) #23070
  • [3.9] bpo-29566: binhex.binhex now consitently writes MacOS 9 line endings. (GH-23059) #23071
  • 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 2020-11-01.09:10:25.413>
    created_at = <Date 2017-02-15.12:21:05.573>
    labels = ['OS-mac', 'type-bug', '3.8', '3.9', '3.10']
    title = 'binhex() creates files with mixed line endings'
    updated_at = <Date 2020-11-01.09:39:48.083>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2020-11-01.09:39:48.083>
    actor = 'miss-islington'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-11-01.09:10:25.413>
    closer = 'ronaldoussoren'
    components = ['macOS']
    creation = <Date 2017-02-15.12:21:05.573>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 29566
    keywords = ['patch']
    message_count = 5.0
    messages = ['287849', '380056', '380121', '380123', '380124']
    nosy_count = 4.0
    nosy_names = ['ronaldoussoren', 'ned.deily', 'serhiy.storchaka', 'miss-islington']
    pr_nums = ['23059', '23070', '23071']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue29566'
    versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

    @serhiy-storchaka
    Copy link
    Member Author

    binhex.binhex() creates files with mixed line endings in Python 3. The header line '(This file must be converted with BinHex 4.0)' is separated from the data by LFs, but the data is split for lines by CRs.

    >>> import binhex
    >>> with open('inp', 'wb') as f: f.write(bytes(range(256)))
    ... 
    256
    >>> binhex.binhex('inp', 'outp')
    >>> for line in open('outp', 'rb').read().splitlines(True): print(repr(line))
    ... 
    b'(This file must be converted with BinHex 4.0)\r'
    b'\r'
    b':!fPZF!!rN!J!N!3"!*!&*VF!!3)$"!8\'"`J*#JX-$3i2%"%5%a39&KFB\'4SE("d\n'
    b'H(b!K)L-N*5BR+#NU+b`Y,Lm`-6)c0$8f0cJj1MXm26ir3%&#3d4&4NG)58T,6%e\n'
    b'16e"48P0899CA@&PD@eaGAPpJB@*MC\'9QCfKTDQYXE@J[F(&bFh4eGRGiHATlI(e\n'
    b'qIi#"JS1%KBD(L)Q+Lib0MSq3!*\'5Nj59PTHBQCUER*fHRk#KSU1NTDDRU+QUUkb\n'
    b'YVUq`XE+cY,@fYlLjZVZm[Ekr`-(#`m6&aXI)bFV,c-h1cp$4dY28eGEAf0RDfpc\n'
    b'GhYrJiH,Mj1AQjqMTkZ[XlHl[m2(bmr6ep[IiqIVlr2hqrhj9!!!:\n'

    In Python 2 the output file was file object usually opened in text mode. Newline characters were translated to platform-depending line endings: CRLF on Windows, LF on classic Mac OS. In Python 2 the output file is binary stream that doesn't do any newline translations.

    The last related commit is 34a042d with Guido's message "This is the last time I fix binhex. If it breaks again it goes in the dustbin."

    @serhiy-storchaka serhiy-storchaka added 3.7 (EOL) end of life OS-mac type-bug An unexpected behavior, bug, or error labels Feb 15, 2017
    @ronaldoussoren
    Copy link
    Contributor

    I've added a PR that changes the line ending to "\r" in encoded data.

    Not very useful now that binhex is deprecated, but this allows us to close this issue.

    @ronaldoussoren ronaldoussoren added 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes and removed 3.7 (EOL) end of life labels Oct 31, 2020
    @miss-islington
    Copy link
    Contributor

    New changeset 2165cea by Ronald Oussoren in branch 'master':
    bpo-29566: binhex.binhex now consitently writes MacOS 9 line endings. (GH-23059)
    2165cea

    @miss-islington
    Copy link
    Contributor

    New changeset 39a56e5 by Miss Skeleton (bot) in branch '3.8':
    [3.8] bpo-29566: binhex.binhex now consitently writes MacOS 9 line endings. (GH-23059) (GH-23070)
    39a56e5

    @miss-islington
    Copy link
    Contributor

    New changeset 3defcba by Miss Skeleton (bot) in branch '3.9':
    [3.9] bpo-29566: binhex.binhex now consitently writes MacOS 9 line endings. (GH-23059) (GH-23071)
    3defcba

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes 3.9 only security fixes 3.10 only security fixes OS-mac type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants