diff options
| author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-04-23 15:40:52 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-23 15:40:52 (GMT) |
| commit | ec29d0c0916af129eaafb0ad392449ca173309ed (patch) | |
| tree | 72456ff062f4499f73d1ecf25c428c7f0b3e3429 /Lib/dataclasses.py | |
| parent | 6e25228b2e8bd9556b879c629ee20876271bf7da (diff) | |
| download | cpython-ec29d0c0916af129eaafb0ad392449ca173309ed.zip cpython-ec29d0c0916af129eaafb0ad392449ca173309ed.tar.gz cpython-ec29d0c0916af129eaafb0ad392449ca173309ed.tar.bz2 | |
[3.11] gh-103449: Fix a bug in dataclass docstring generation (GH-103454) (#103599)
Diffstat (limited to 'Lib/dataclasses.py')
| -rw-r--r-- | Lib/dataclasses.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/dataclasses.py b/Lib/dataclasses.py index 221ea2b..a7e0547 100644 --- a/Lib/dataclasses.py +++ b/Lib/dataclasses.py @@ -1092,8 +1092,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 |
