Skip to content

AttributeError: module 'warnings' has no attribute 'UserWarning' when installing package with multi-line description #2539

@greschd

Description

@greschd

When installing a package with a multi-line description with the latest setuptools version (51.3.2), I get the following error:

      File "/home/greschd/.virtualenvs/tmp-9b3743628834a12/lib/python3.8/site-packages/setuptools/dist.py", line 125, in single_line
        warnings.UserWarning("newlines not allowed and will break in the future")
    AttributeError: module 'warnings' has no attribute 'UserWarning'

This seems to be related to the discussion in #1390, and specifically the change in #2538, because UserWarning is a built-in global, not part of the warnings module:

>>> import warnings
>>> warnings.UserWarning
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'warnings' has no attribute 'UserWarning'
>>> UserWarning
<class 'UserWarning'>
>>> 

The fix should be very straightforward, using warnings.warn instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions