Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
35fa31fa
Commit
35fa31fa
authored
Jul 26, 2017
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use inspect.getmro to inspect the mro. Alternate implementation to that proposed in #1092.
parent
c452f9fd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
10 deletions
+17
-10
CHANGES.rst
CHANGES.rst
+6
-0
pkg_resources/__init__.py
pkg_resources/__init__.py
+11
-10
No files found.
CHANGES.rst
View file @
35fa31fa
v36
.2.4
-------
*
#
1092
:
``
pkg_resources
``
now
uses
``
inspect
.
getmro
``
to
resolve
classes
in
method
resolution
order
.
v36
.2.3
-------
...
...
pkg_resources/__init__.py
View file @
35fa31fa
...
...
@@ -37,6 +37,7 @@ import email.parser
import
tempfile
import
textwrap
import
itertools
import
inspect
from
pkgutil
import
get_importer
try
:
...
...
@@ -2939,20 +2940,20 @@ class Requirement(packaging.requirements.Requirement):
return req
def _get_mro(cls):
"""Get an mro for a type or classic class"""
if not isinstance(cls, type):
class cls(cls, object):
pass
return cls.__mro__[1:]
return cls.__mro__
def _always_object(classes):
"""
Ensure object appears in the mro even
for old-style classes.
"""
if object not in classes:
return classes + (object,)
return classes
def _find_adapter(registry, ob):
"""Return an adapter factory for `ob` from `registry`"""
for t in _get_mro(getattr(ob, '__class__', type(ob))):
types = _always_object(inspect.getmro(getattr(ob, '__class__', type(ob))))
for t in types:
if t in registry:
return registry[t]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment