mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Issue #19927: Add __eq__ to path-based loaders in importlib.
This commit is contained in:
parent
78194cd4e9
commit
d749c7ae68
6 changed files with 698 additions and 621 deletions
|
@ -1559,6 +1559,13 @@ class FileLoader:
|
|||
self.name = fullname
|
||||
self.path = path
|
||||
|
||||
def __eq__(self, other):
|
||||
return (self.__class__ == other.__class__ and
|
||||
self.__dict__ == other.__dict__)
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self.name) ^ hash(self.path)
|
||||
|
||||
@_check_name
|
||||
def load_module(self, fullname):
|
||||
"""Load a module from a file."""
|
||||
|
@ -1653,6 +1660,13 @@ class ExtensionFileLoader:
|
|||
self.name = name
|
||||
self.path = path
|
||||
|
||||
def __eq__(self, other):
|
||||
return (self.__class__ == other.__class__ and
|
||||
self.__dict__ == other.__dict__)
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self.name) ^ hash(self.path)
|
||||
|
||||
@_check_name
|
||||
def load_module(self, fullname):
|
||||
"""Load an extension module."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue