[issue29213] python -m venv activate.bat has weird mix of line endings

Vinay Sajip report at bugs.python.org
Wed Jan 11 13:23:00 EST 2017


Vinay Sajip added the comment:

Although we don't currently have binaries under venv/scripts, that might change in the future. The logic could be changed to:

    with open(srcfile, 'rb') as f:
        data = f.read()
    if not srcfile.endswith('.exe'):
        try:
            data = data.decode('utf-8')
            data = self.replace_variables(data, context)
            data = data.encode('utf-8')
        except UnicodeError as e:
            data = None
            logger.warning('unable to copy script %r, '
                           'may be binary: %s', srcfile, e)
    if data is not None:
        with open(dstfile, 'wb') as f:
            f.write(data)
        shutil.copymode(srcfile, dstfile)

All the files in the nt subdirectory have CRLF endings, and the above should preserve them (whatever they are).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29213>
_______________________________________


More information about the Python-bugs-list mailing list