Open
Description
setuptools version
70.0.0
Python version
N/A
OS
N/A
Additional environment information
N/A
Description
In setuptools 70, Requirement.parse
raises a different (private) exception class coming out of the _vendor
path rather than the extern
path. This means that there is no way for a caller of that method to catch the raised exception without reaching into the _vendor
directory.
This was changed by e999582, if I understand correctly.
Expected behavior
The exception class is not changed, or the class of the exception raised is publicly accessible.
How to Reproduce
- Create a file with the following contents:
import warnings
warnings.simplefilter("ignore", Warning)
import setuptools
import pkg_resources # noqa
from pkg_resources.extern.packaging.requirements import ( # noqa
InvalidRequirement as ErrorFromExtern,
)
from pkg_resources._vendor.packaging.requirements import ( # noqa
InvalidRequirement as ErrorFromVendor,
)
try:
pkg_resources.Requirement.parse("a b")
except Exception as e:
print(setuptools.__version__)
print(" ", e.__class__)
print(" ", isinstance(e, ErrorFromExtern))
print(" ", isinstance(e, ErrorFromVendor))
- Run this file in an environment with setuptools 70.0.0 and then in an environment with setuptools==69.5.1.
- See the different class of the exception.
Output
69.5.1
<class 'pkg_resources.extern.packaging.requirements.InvalidRequirement'>
True
False
70.0.0
<class 'pkg_resources._vendor.packaging.requirements.InvalidRequirement'>
False
True