pypa / pypa/setuptools

Generated scripts can be written in a bogus encoding

Open
#1,246 10 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug help wanted Needs Investigation
Dominant language
Python
Stars
2.9k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
1

Description

https://github.com/pypa/setuptools/blob/118edbb2b715c96620b51018c1d28e81f2318053/setuptools/command/easy_install.py#L836-L837

open's encoding argument, when unspecified, uses locale.getpreferredencoding , which is not necessarily UTF-8. However, the generated script doesn't include an encoding cookie and can contain non-ASCII data if, say, the shebang path contains non-ASCII components. Either always open the file with encoding='utf-8' or write out an encoding cookie.

This has resulted in an issue filed on a different project: https://github.com/pypa/pipenv/issues/1265

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in setuptools/command/easy_install.py at lines 836-837 and inspect how generated scripts are opened and written. Verify the result with a non-ASCII shebang path under a non-UTF-8 locale; the work is done when generated scripts remain valid regardless of the locale encoding.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.