classification
Title: TypeError in pathfix.py
Type: behavior Stage:
Components: Demos and Tools Versions: Python 3.1
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: amcnabb, benjamin.peterson
Priority: normal Keywords: patch

Created on 2009-09-25 20:07 by amcnabb, last changed 2009-09-25 20:58 by benjamin.peterson. This issue is now closed.

Files
File name Uploaded Description Edit
python-3.1.1-pathfix.patch amcnabb, 2009-09-25 20:07 patch which fixes pathfix.py
Messages (2)
msg93134 - (view) Author: Andrew McNabb (amcnabb) Date: 2009-09-25 20:07
Tools/scripts/pathfix.py crashes with a TypeError:

Traceback (most recent call last):
  File "Tools/scripts/pathfix.py", line 149, in <module>
    main()
  File "Tools/scripts/pathfix.py", line 54, in main
    if recursedown(arg): bad = 1
  File "Tools/scripts/pathfix.py", line 82, in recursedown
    elif ispython(name):
  File "Tools/scripts/pathfix.py", line 64, in ispython
    return ispythonprog.match(name) >= 0
TypeError: unorderable types: NoneType() >= int()

It looks like an easy fix would be to change line 64 from:

    return ispythonprog.match(name) >= 0

to:

    return bool(ispythonprog.match(name))

After making this change, I got another crash, this time due to a
UnicodeDecodeError.  Apparently, the file
(Demo/distutils/test2to3/setup.py) has a character encoded in ISO-8859.
 Since pathfix.py is only concerned with ASCII text in the first line of
a file, it seems that it should probably operate on bytes instead of
unicode strings.

By the way, it's a little odd (but not technically invalid) that the
format string on line 146 is: '#! %s\n'.  I would normally expect to see
no whitespace: '#!%s\n'.

Anyway, I'm attaching a patch that fixes addresses all of the above
issues and which seems to make pathfix.py work for all files in the
Python 3.1.1 source tree.
msg93141 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-09-25 20:58
Thanks for the patch! Fixed in r75062.
History
Date User Action Args
2009-09-25 20:58:20benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg93141

resolution: fixed
2009-09-25 20:30:32amcnabbsettype: crash -> behavior
2009-09-25 20:07:57amcnabbcreate