Skip to content

Incorrect regex to strip sys.argv[0] from extension and suffix on Windows #3233

@pombredanne

Description

@pombredanne

The regex at

sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
is likely incorrect:

  1. It does not handle the common case where the generated console script is named xxx-script.py
  2. Yet on the other hand, since for wheels there are no -script.py generated on Windows (only an exe), checking for pyw is actually useless IMHO

FWIW, the regex is the same as in distlib here:
https://bitbucket.org/pypa/distlib/src/6ada86eea2700f10edcd81f831139c6ae20edb74/distlib/scripts.py?at=default&fileviewer=file-view-default#scripts.py-55

The bug was found by @dstufft through pallets/click#365

Metadata

Metadata

Assignees

No one assigned

    Labels

    auto-lockedOutdated issues that have been locked by automation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions