[issue12032] Tools/Scripts/crlv.py needs updating for python 3+
Stephen Ferg
report at bugs.python.org
Sun May 8 18:55:31 CEST 2011
New submission from Stephen Ferg <zuulixia at ferg.org>:
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
===================================================================
----------
components: Demos and Tools
messages: 135531
nosy: stephen_ferg
priority: normal
severity: normal
status: open
title: Tools/Scripts/crlv.py needs updating for python 3+
type: crash
versions: Python 3.2
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12032>
_______________________________________
More information about the Python-bugs-list
mailing list