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: UnicodeDecodeError when 2to3 is run on a dir with numpy .npy files
Type: crash Stage:
Components: 2to3 (2.x to 3.x conversion tool) Versions: Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: benjamin.peterson Nosy List: benjamin.peterson, zbysz
Priority: normal Keywords: patch

Created on 2010-11-14 11:34 by zbysz, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
diff.diff zbysz, 2010-11-14 11:34 patch
Messages (2)
msg121188 - (view) Author: Zbyszek Jędrzejewski-Szmek (zbysz) * Date: 2010-11-14 11:34
1. 2to3 should work only only files ending with '.py', but it takes
   anything which has a dot and ends with 'py'. I'm having trouble
   with numpy .npy files.
2. 2to3 tries to decode the file and fails with traceback that is not useful:
   the name of the failing file is not given.

A patch is attached.

% ls *.npy|head -n1
S_18_7000_899811b572b309161cbb34f185b82fb618ed81da.npy

% 2to3-3.2 /usr/local/bin/2to3-3.2 .
RefactoringTool: Skipping implicit fixer: buffer
RefactoringTool: Skipping implicit fixer: idioms
RefactoringTool: Skipping implicit fixer: set_literal
RefactoringTool: Skipping implicit fixer: ws_comma
Traceback (most recent call last):
  File "/usr/local/bin/2to3-3.2", line 6, in <module>
    sys.exit(main("lib2to3.fixes"))
  File "/usr/local/lib/python3.2/lib2to3/main.py", line 172, in main
    options.processes)
  File "/usr/local/lib/python3.2/lib2to3/refactor.py", line 699, in refactor
    items, write, doctests_only)
  File "/usr/local/lib/python3.2/lib2to3/refactor.py", line 294, in refactor
    self.refactor_dir(dir_or_file, write, doctests_only)
  File "/usr/local/lib/python3.2/lib2to3/refactor.py", line 313, in refactor_dir
    self.refactor_file(fullname, write, doctests_only)
  File "/usr/local/lib/python3.2/lib2to3/refactor.py", line 740, in refactor_file
    *args, **kwargs)
  File "/usr/local/lib/python3.2/lib2to3/refactor.py", line 335, in refactor_file
    input, encoding = self._read_python_source(filename)
  File "/usr/local/lib/python3.2/lib2to3/refactor.py", line 331, in _read_python_source
    return _from_system_newlines(f.read()), encoding
  File "/usr/local/lib/python3.2/codecs.py", line 300, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x93 in position 0: invalid start byte
msg121196 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2010-11-14 15:29
r86464
History
Date User Action Args
2022-04-11 14:57:08adminsetgithub: 54625
2010-11-14 15:29:06benjamin.petersonsetstatus: open -> closed
resolution: fixed
messages: + msg121196
2010-11-14 12:04:03georg.brandlsetassignee: benjamin.peterson

nosy: + benjamin.peterson
2010-11-14 11:34:03zbyszcreate