mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-102947: Improve traceback when calling fields()
on a non-dataclass (#102948)
This commit is contained in:
parent
08254be6c5
commit
baf4eb083c
3 changed files with 15 additions and 1 deletions
|
@ -1248,7 +1248,7 @@ def fields(class_or_instance):
|
|||
try:
|
||||
fields = getattr(class_or_instance, _FIELDS)
|
||||
except AttributeError:
|
||||
raise TypeError('must be called with a dataclass type or instance')
|
||||
raise TypeError('must be called with a dataclass type or instance') from None
|
||||
|
||||
# Exclude pseudo-fields. Note that fields is sorted by insertion
|
||||
# order, so the order of the tuple is as the fields were defined.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue