summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2021-11-03 17:59:05 -0400
committerJason R. Coombs <jaraco@jaraco.com>2021-11-03 17:59:05 -0400
commit30f070eeb27a6477314a03fecbd7e4cc3ac4fd9e (patch)
treea3f710f0e4b897708c85e59ec895ac08c18d1403
parentdfbbf11be13ecf11f8ed7c1f00f7adba8e425afc (diff)
downloadpython-setuptools-git-30f070eeb27a6477314a03fecbd7e4cc3ac4fd9e.tar.gz
Move warning definition above implicit behavior on import. Fixes #2846.
-rw-r--r--changelog.d/2486.misc.rst1
-rw-r--r--pkg_resources/__init__.py18
2 files changed, 10 insertions, 9 deletions
diff --git a/changelog.d/2486.misc.rst b/changelog.d/2486.misc.rst
new file mode 100644
index 00000000..6a2c4438
--- /dev/null
+++ b/changelog.d/2486.misc.rst
@@ -0,0 +1 @@
+Move PkgResourcesDeprecationWarning above implicitly-called function so that it's in the namespace when version warnings are generated in an environment that contains them.
diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py
index 3aafe652..4aece3c4 100644
--- a/pkg_resources/__init__.py
+++ b/pkg_resources/__init__.py
@@ -3244,6 +3244,15 @@ def _initialize(g=globals()):
)
+class PkgResourcesDeprecationWarning(Warning):
+ """
+ Base class for warning about deprecations in ``pkg_resources``
+
+ This class is not derived from ``DeprecationWarning``, and as such is
+ visible by default.
+ """
+
+
@_call_aside
def _initialize_master_working_set():
"""
@@ -3282,12 +3291,3 @@ def _initialize_master_working_set():
# match order
list(map(working_set.add_entry, sys.path))
globals().update(locals())
-
-
-class PkgResourcesDeprecationWarning(Warning):
- """
- Base class for warning about deprecations in ``pkg_resources``
-
- This class is not derived from ``DeprecationWarning``, and as such is
- visible by default.
- """