summaryrefslogtreecommitdiffstats
path: root/Lib/dataclasses.py
diff options
context:
space:
mode:
authorNikita Sobolev <mail@sobolevn.me>2023-04-17 23:33:22 (GMT)
committerGitHub <noreply@github.com>2023-04-17 23:33:22 (GMT)
commitb57f55c23e15654e9dd77680ff1462603e360b76 (patch)
tree29a6455de3cd2cc12b786b472f4ba9ca433de7e0 /Lib/dataclasses.py
parentd83faf7f1ba2de95e98e3eeb5ce9009d9cd62192 (diff)
downloadcpython-b57f55c23e15654e9dd77680ff1462603e360b76.zip
cpython-b57f55c23e15654e9dd77680ff1462603e360b76.tar.gz
cpython-b57f55c23e15654e9dd77680ff1462603e360b76.tar.bz2
gh-103449: Fix a bug in dataclass docstring generation (#103454)
Diffstat (limited to 'Lib/dataclasses.py')
-rw-r--r--Lib/dataclasses.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/dataclasses.py b/Lib/dataclasses.py
index 4026c8b..a73cdc2 100644
--- a/Lib/dataclasses.py
+++ b/Lib/dataclasses.py
@@ -1128,8 +1128,13 @@ def _process_class(cls, init, repr, eq, order, unsafe_hash, frozen,
if not getattr(cls, '__doc__'):
# Create a class doc-string.
- cls.__doc__ = (cls.__name__ +
- str(inspect.signature(cls)).replace(' -> None', ''))
+ try:
+ # In some cases fetching a signature is not possible.
+ # But, we surely should not fail in this case.
+ text_sig = str(inspect.signature(cls)).replace(' -> None', '')
+ except (TypeError, ValueError):
+ text_sig = ''
+ cls.__doc__ = (cls.__name__ + text_sig)
if match_args:
# I could probably compute this once