Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError in pathfix.py #51248

Closed
amcnabb mannequin opened this issue Sep 25, 2009 · 2 comments
Closed

TypeError in pathfix.py #51248

amcnabb mannequin opened this issue Sep 25, 2009 · 2 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@amcnabb
Copy link
Mannequin

amcnabb mannequin commented Sep 25, 2009

BPO 6999
Nosy @benjaminp
Files
  • python-3.1.1-pathfix.patch: patch which fixes pathfix.py
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2009-09-25.20:58:20.709>
    created_at = <Date 2009-09-25.20:07:57.117>
    labels = ['type-bug']
    title = 'TypeError in pathfix.py'
    updated_at = <Date 2009-09-25.20:58:20.699>
    user = 'https://bugs.python.org/amcnabb'

    bugs.python.org fields:

    activity = <Date 2009-09-25.20:58:20.699>
    actor = 'benjamin.peterson'
    assignee = 'none'
    closed = True
    closed_date = <Date 2009-09-25.20:58:20.709>
    closer = 'benjamin.peterson'
    components = ['Demos and Tools']
    creation = <Date 2009-09-25.20:07:57.117>
    creator = 'amcnabb'
    dependencies = []
    files = ['14975']
    hgrepos = []
    issue_num = 6999
    keywords = ['patch']
    message_count = 2.0
    messages = ['93134', '93141']
    nosy_count = 2.0
    nosy_names = ['amcnabb', 'benjamin.peterson']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue6999'
    versions = ['Python 3.1']

    @amcnabb
    Copy link
    Mannequin Author

    amcnabb mannequin commented Sep 25, 2009

    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.

    @amcnabb amcnabb mannequin added type-crash A hard crash of the interpreter, possibly with a core dump type-bug An unexpected behavior, bug, or error and removed type-crash A hard crash of the interpreter, possibly with a core dump labels Sep 25, 2009
    @benjaminp
    Copy link
    Contributor

    Thanks for the patch! Fixed in r75062.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant