twine: twine<=3.1.1 bug: `AttributeError: 'NoneType' object has no attribute 'group'`

Your Environment

GitHub Actions workflow

  1. Your operating system: macOS-latest

  2. Version of python you are running:

python.org-provided dmgs for Python 3.8, 3.7, 3.6, 3.5, 2.7

  1. How did you install twine? Did you use your operating system’s package manager or pip or something else?

pip install and via tox (b/c I tried many ways during debugging)

  1. Version of twine you have installed:

v3.1.1

  1. Which package repository are you targeting?

PyPI/TestPyPI but it doesn’t matter in the context of this issue because it’s about twine check, not uploading the dists.

The Issue

So I’m in progress of packaging platform-specific dists. I was building them using pip wheel in a tox env and then running delocate outside. Then I started moving delocate into a toxenv (separate) and after that twine check started spitting out this traceback:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/twine/__main__.py", line 31, in <module>
    sys.exit(main())
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/twine/__main__.py", line 25, in main
    return dispatch(sys.argv[1:])
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/twine/cli.py", line 74, in dispatch
    return main(args.args)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/twine/commands/check.py", line 158, in main
    return check(args.dists)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/twine/commands/check.py", line 121, in check
    warnings, is_ok = _check_file(filename, render_warning_stream)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/twine/commands/check.py", line 73, in _check_file
    package = PackageFile.from_filename(filename, comment=None)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/twine/package.py", line 104, in from_filename
    py_version = meta.py_version
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/twine/wheel.py", line 47, in py_version
    return wheel_info.group("pyver")
AttributeError: 'NoneType' object has no attribute 'group'
Checking dist/*.whl: 
##[error]Process completed with exit code 1.

(here’s that line in src: https://github.com/pypa/twine/blob/3.1.1/twine/wheel.py#L47)

Now, I understand that it looks like a bug in delocate (or/and maybe the isolation that tox creates for it) but still twine should error out more gracefully.

Imagine my surprise when I discovered that this has been “fixed” in master just a day before I started seeing it: https://github.com/pypa/twine/commit/7111240b04f022d5366af7297b9e81c63d76fb6d#diff-c533b522e297bb77ebe6ed9089c754beR48-R51.

I’m not sure if it counts as a fix because it’s a commit that adds annotations and the change looks like a side-effect, plus no tests for this were added. Should it return any when the regex doesn’t match? This is still to be identified.

Steps to Reproduce

This is all I have atm: https://github.com/ansible/pylibssh/runs/625207843?check_suite_focus=true#step:15:68

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (16 by maintainers)

Most upvoted comments

I think the action item would be to add a test case to document such a decision before closing this issue.

There is a test added for it as described in a comment above (https://github.com/pypa/twine/issues/612#issuecomment-620640110). Should this be enough?

This field is basically a freeform text field. Here’s all the current unique values that exist for it on PyPI: https://gist.github.com/di/93019b51582899c294cfd76ee2d0a4a3

The only requirement that PyPI enforces is that this is source for source distributions.

I think in this case we should just pick some default value. In my opinion, “any” is acceptable.