mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-72249: Include the module name in the repr of partial object (GH-101910)
Co-authored-by: Anilyka Barry <vgr255@live.ca>
This commit is contained in:
parent
f082a05c67
commit
8f5be78bce
4 changed files with 27 additions and 18 deletions
|
@ -303,13 +303,13 @@ class partial:
|
|||
|
||||
@recursive_repr()
|
||||
def __repr__(self):
|
||||
qualname = type(self).__qualname__
|
||||
cls = type(self)
|
||||
qualname = cls.__qualname__
|
||||
module = cls.__module__
|
||||
args = [repr(self.func)]
|
||||
args.extend(repr(x) for x in self.args)
|
||||
args.extend(f"{k}={v!r}" for (k, v) in self.keywords.items())
|
||||
if type(self).__module__ == "functools":
|
||||
return f"functools.{qualname}({', '.join(args)})"
|
||||
return f"{qualname}({', '.join(args)})"
|
||||
return f"{module}.{qualname}({', '.join(args)})"
|
||||
|
||||
def __reduce__(self):
|
||||
return type(self), (self.func,), (self.func, self.args,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue