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

Add .bat line to .hgeol #61404

Closed
zware opened this issue Feb 14, 2013 · 10 comments
Closed

Add .bat line to .hgeol #61404

zware opened this issue Feb 14, 2013 · 10 comments
Labels
OS-windows type-bug An unexpected behavior, bug, or error

Comments

@zware
Copy link
Member

zware commented Feb 14, 2013

BPO 17202
Nosy @loewis, @birkenfeld, @pitrou, @tjguk, @djc, @ezio-melotti, @briancurtin, @zware
Files
  • batch_eol_fix.diff
  • batch_eol_fix.diff.2
  • 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 2015-04-13.17:15:22.057>
    created_at = <Date 2013-02-14.06:41:26.826>
    labels = ['type-bug', 'OS-windows']
    title = 'Add .bat line to .hgeol'
    updated_at = <Date 2015-04-13.17:15:22.053>
    user = 'https://github.com/zware'

    bugs.python.org fields:

    activity = <Date 2015-04-13.17:15:22.053>
    actor = 'python-dev'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-04-13.17:15:22.057>
    closer = 'python-dev'
    components = ['Windows']
    creation = <Date 2013-02-14.06:41:26.826>
    creator = 'zach.ware'
    dependencies = []
    files = ['29070', '32327']
    hgrepos = []
    issue_num = 17202
    keywords = ['patch']
    message_count = 10.0
    messages = ['182077', '182182', '182187', '192356', '193085', '193099', '201116', '206651', '233357', '240665']
    nosy_count = 10.0
    nosy_names = ['loewis', 'georg.brandl', 'pitrou', 'tim.golden', 'djc', 'ezio.melotti', 'brian.curtin', 'BreamoreBoy', 'python-dev', 'zach.ware']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue17202'
    versions = ['Python 3.4']

    @zware
    Copy link
    Member Author

    zware commented Feb 14, 2013

    Most times (though not all, for some reason) I try to use Doc\make.bat update, it fails with "The system cannot find the batch label specified - update" even though it is obviously there. The reason for this appears to be the fact that the file uses UNIX line endings[1]. As a fix, I think it would make the most sense to add a "**.bat = CRLF" line to .hgeol.

    The attached patch makes that change and includes the changes that that change entails. The complete list of affected files is as follows:

    Doc\make.bat
    Lib\ctypes\macholib\fetch_macholib.bat
    Lib\idlelib\idle.bat
    Modules\_decimal\tests\runall.bat
    PCbuild\build.bat
    PCbuild\build_env.bat
    PCbuild\build_pgo.bat
    PCbuild\build_ssl.bat
    PCbuild\env.bat
    PCbuild\idle.bat
    PCbuild\rt.bat
    Tools\buildbot\build-amd64.bat
    Tools\buildbot\build.bat
    Tools\buildbot\buildmsi.bat
    Tools\buildbot\clean-amd64.bat
    Tools\buildbot\clean.bat
    Tools\buildbot\external-amd64.bat
    Tools\buildbot\external-common.bat
    Tools\buildbot\external.bat
    Tools\buildbot\test-amd64.bat
    Tools\buildbot\test.bat
    Tools\unicode\genwincodecs.bat

    As far as I know, there is no reason to believe that the changes to line endings in these files would cause any change to behavior other than possibly avoid strange and random bugs in their execution, particularly in Doc\make.bat.

    If we don't want to a blanket rule like this, I think we should at least add a rule for Doc\make.bat to convert it to CRLF line endings to avoid the bug with :update.

    Thanks,

    Zach

    [1] http://stackoverflow.com/questions/232651/why-the-system-cannot-find-the-batch-label-specified-is-thrown-even-if-label-e/232674#232674

    @ezio-melotti ezio-melotti added the type-bug An unexpected behavior, bug, or error label Feb 15, 2013
    @ezio-melotti
    Copy link
    Member

    **.bat used to be there, but it was removed in 1762d79eab65.

    I have a very faint memory of some discussion about bat files and EOLs, but the best I could find was:
    http://mail.python.org/pipermail/python-dev/2012-May/119220.html
    http://mail.python.org/pipermail/python-dev/2012-May/119225.html

    This seems to suggest that CRLF shouldn't be necessary.

    There's also an older discussion about adding CRLF for make.bat here (the discussion is actually somewhat unrelated, but back then adding these entries sounded like a good idea): http://mail.python.org/pipermail/python-committers/2011-May/001685.html

    @zware
    Copy link
    Member Author

    zware commented Feb 15, 2013

    This seems to suggest that CRLF shouldn't be necessary.

    It's not necessary on .bat files without labels, but those with labels are subject to the (Windows) bug described in my first message and link.

    Adding an entry specifically for Doc/make.bat and any other batch scripts with labels would be fine as well.

    @zware
    Copy link
    Member Author

    zware commented Jul 5, 2013

    I have recently learned why this issue had seemed transient to me previously: the hg eol extension apparently causes hg to create all files that are not explicitly set to LF or BIN using CRLF on Windows. Thus, this is what happens:

    """
    P:\Python\cpython\Doc>rem In a fresh checkout made with the 'eol' extension disabled:

    P:\Python\cpython\Doc>make.bat update
    The system cannot find the batch label specified - update

    P:\Python\cpython\Doc>cd ..

    P:\Python\cpython>hg up null
    0 files updated, 0 files merged, 3689 files removed, 0 files unresolved

    P:\Python\cpython>hg --config extensions.eol= up default
    3689 files updated, 0 files merged, 0 files removed, 0 files unresolved

    P:\Python\cpython>cd Doc

    P:\Python\cpython\Doc>make.bat update
    Updating 'tools\sphinx':
    At revision 89001.
    Updating 'tools\docutils':
    At revision 89001.
    Updating 'tools\jinja2':
    At revision 89001.
    Updating 'tools\pygments':
    At revision 89001.

    P:\Python\cpython\Doc>
    """

    Thus, a usable workaround is to enable the eol extension in hgrc and make your checkout that way. However, this doesn't help anyone who is trying to build from a tarball; Doc/make.bat will have LF line endings and at least 'update' will not work.

    Perhaps a less extensive change would be to add "**.bat = BIN", and then convert Doc/make.bat to CRLF explicitly?

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Jul 15, 2013

    Zachary: What Windows version do you use? Glen Linderman claims that at least Windows 7 should work fine with cmd files containing only LF, and suggested that this may also be the case on Windows XP.

    Are you using a non-standard command interpreter by any chance?

    @zware
    Copy link
    Member Author

    zware commented Jul 15, 2013

    I'm on 32 bit Windows 7 Pro, SP1, and have also reproduced the issue on 64 bit Windows 7 Home Premium, SP1. I use the standard Command Prompt (cmd.exe) on both.

    @tjguk
    Copy link
    Member

    tjguk commented Oct 24, 2013

    I'm running Win7 and have the same problem, with a fresh checkout and the eol extension disabled. The attached (updated) patch does solve the issue. I can't see any reason not to apply it, even if it's not needed in many cases.

    @zware
    Copy link
    Member Author

    zware commented Dec 19, 2013

    Any objections to proceeding with this?

    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jan 3, 2015

    No objections so proceeding is in order here I take it?

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 13, 2015

    New changeset 019c17a4198a by Zachary Ware in branch '2.7':
    Issue bpo-17202: Add .bat to .hgeol to force them to CRLF.
    https://hg.python.org/cpython/rev/019c17a4198a

    New changeset 640ccb924b5f by Zachary Ware in branch '3.4':
    Issue bpo-17202: Add .bat to .hgeol to force them to CRLF.
    https://hg.python.org/cpython/rev/640ccb924b5f

    New changeset 9b2ea49213fd by Zachary Ware in branch 'default':
    Closes bpo-17202: Merge with 3.4
    https://hg.python.org/cpython/rev/9b2ea49213fd

    @python-dev python-dev mannequin closed this as completed Apr 13, 2015
    @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
    OS-windows type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants