aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/functools.py
diff options
context:
space:
mode:
authorFurkan Onder <furkanonder@protonmail.com>2024-02-25 23:55:19 +0300
committerGitHub <noreply@github.com>2024-02-25 22:55:19 +0200
commit8f5be78bce95deb338e2e1cf13a0a579b3b42dd2 (patch)
tree1f51737198ead1c7fd607b8fb6452a345b0bd5b3 /Lib/functools.py
parentf082a05c67cc949ccd1a940ecf6721953bbdc34f (diff)
downloadcpython-8f5be78bce95deb338e2e1cf13a0a579b3b42dd2.tar.gz
cpython-8f5be78bce95deb338e2e1cf13a0a579b3b42dd2.zip
gh-72249: Include the module name in the repr of partial object (GH-101910)
Co-authored-by: Anilyka Barry <vgr255@live.ca>
Diffstat (limited to 'Lib/functools.py')
-rw-r--r--Lib/functools.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/functools.py b/Lib/functools.py
index 7045be551c8..601cb8e7c0b 100644
--- a/Lib/functools.py
+++ b/Lib/functools.py
@@ -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,