This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Tools/Scripts/crlf.py needs updating for python 3+
Type: behavior Stage: resolved
Components: Demos and Tools Versions: Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: eric.araujo Nosy List: eric.araujo, python-dev, stephen_ferg
Priority: normal Keywords:

Created on 2011-05-08 16:55 by stephen_ferg, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (4)
msg135531 - (view) Author: Stephen Ferg (stephen_ferg) Date: 2011-05-08 16:55
I think this is a consequence of the new Unicode support in Python 3+

Here is code copied from C:\Python32\Tools\Scripts\crlf.py (on windows)
==================================================================
    for filename in os.listdir("."):
        if os.path.isdir(filename):
            print(filename, "Directory!")
            continue
        data = open(filename, "rb").read()
        if '\0' in data:
            print(filename, "Binary!")
            continue
        newdata = data.replace("\r\n", "\n")
        if newdata != data:
            print(filename)

===================================================================

When run, it produces this (run under the PyCharm debugger)

===================================================================
C:\Python32\python.exe C:/pydev/zob/zobtest.py
Traceback (most recent call last):
  File "C:/pydev/zob/zobtest.py", line 134, in <module>
    x() 
  File "C:/pydev/zob/zobtest.py", line 126, in x
    if '\0' in data:
TypeError: Type str doesn't support the buffer API

Process finished with exit code 1
===================================================================

Removing the test for "\0" produces this:
===================================================================
C:\Python32\python.exe C:/pydev/zob/zobtest.py
Traceback (most recent call last):
  File "C:/pydev/zob/zobtest.py", line 131, in <module>
    x()  
  File "C:/pydev/zob/zobtest.py", line 126, in x
    newdata = data.replace("\r\n", "\n")
TypeError: expected an object with the buffer interface

Process finished with exit code 1
===================================================================
msg135555 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-05-08 23:29
New changeset f94d74c85dcb by Victor Stinner in branch 'default':
Close #12032: Fix scripts/crlf.py for Python 3
http://hg.python.org/cpython/rev/f94d74c85dcb
msg141790 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-08-08 15:56
This needs porting to 3.2.
msg141978 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-08-12 17:56
New changeset 47ffb957921d by Éric Araujo in branch '3.2':
Update crlf and lfcr scripts for 3.x bytes semantics (#12032).
http://hg.python.org/cpython/rev/47ffb957921d
History
Date User Action Args
2022-04-11 14:57:17adminsetgithub: 56241
2011-08-12 17:57:45eric.araujosetstatus: open -> closed
assignee: eric.araujo
resolution: fixed
2011-08-12 17:56:02python-devsetmessages: + msg141978
2011-08-08 15:56:58eric.araujosetstatus: closed -> open

nosy: + eric.araujo
messages: + msg141790

resolution: fixed -> (no value)
2011-08-05 11:37:17r.david.murraylinkissue12694 superseder
2011-08-05 11:36:12r.david.murraysettype: crash -> behavior
title: Tools/Scripts/crlv.py needs updating for python 3+ -> Tools/Scripts/crlf.py needs updating for python 3+
2011-05-08 23:29:32python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg135555

resolution: fixed
stage: resolved
2011-05-08 16:55:28stephen_fergcreate