Commit 0591364
committed
gh-130821: Add type information to error messages for remaining magic methods
Add type information to error messages for __getnewargs__,
__getnewargs_ex__, __hash__, and __init__ when they return the wrong
type. This is a follow-up to GH-130835, which fixed similar
inconsistencies for other magic methods.
Error messages now use the format 'Type.__method__() must return ...'
consistently, replacing the old format that used '%.200s' for type
names and lacked the type prefix.
Changes:
- __getnewargs_ex__: 'should return' -> '%T.__getnewargs_ex__() must return'
- __getnewargs__: 'should return' -> '%T.__getnewargs__() must return'
- __hash__: '__hash__ method should return an integer' -> '%T.__hash__() must return an integer, not %T'
- __init__: 'should return None' -> 'must return None' with %T format1 parent 645f5c4 commit 0591364
6 files changed
Lines changed: 26 additions & 22 deletions
File tree
- Misc/NEWS.d/next/Core_and_Builtins
- Modules/_testinternalcapi
- Objects
- Python
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7908 | 7908 | | |
7909 | 7909 | | |
7910 | 7910 | | |
7911 | | - | |
7912 | | - | |
| 7911 | + | |
| 7912 | + | |
7913 | 7913 | | |
7914 | 7914 | | |
7915 | 7915 | | |
7916 | 7916 | | |
7917 | 7917 | | |
7918 | | - | |
7919 | | - | |
| 7918 | + | |
| 7919 | + | |
7920 | 7920 | | |
7921 | 7921 | | |
7922 | 7922 | | |
| |||
7928 | 7928 | | |
7929 | 7929 | | |
7930 | 7930 | | |
7931 | | - | |
7932 | | - | |
| 7931 | + | |
| 7932 | + | |
7933 | 7933 | | |
7934 | 7934 | | |
7935 | 7935 | | |
7936 | 7936 | | |
7937 | 7937 | | |
7938 | 7938 | | |
7939 | 7939 | | |
7940 | | - | |
7941 | | - | |
| 7940 | + | |
| 7941 | + | |
7942 | 7942 | | |
7943 | 7943 | | |
7944 | 7944 | | |
| |||
7959 | 7959 | | |
7960 | 7960 | | |
7961 | 7961 | | |
7962 | | - | |
7963 | | - | |
| 7962 | + | |
| 7963 | + | |
7964 | 7964 | | |
7965 | 7965 | | |
7966 | 7966 | | |
| |||
10713 | 10713 | | |
10714 | 10714 | | |
10715 | 10715 | | |
| 10716 | + | |
| 10717 | + | |
| 10718 | + | |
10716 | 10719 | | |
10717 | | - | |
10718 | | - | |
10719 | 10720 | | |
10720 | 10721 | | |
10721 | 10722 | | |
| |||
10975 | 10976 | | |
10976 | 10977 | | |
10977 | 10978 | | |
10978 | | - | |
10979 | | - | |
| 10979 | + | |
| 10980 | + | |
10980 | 10981 | | |
10981 | 10982 | | |
10982 | 10983 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4251 | 4251 | | |
4252 | 4252 | | |
4253 | 4253 | | |
4254 | | - | |
4255 | | - | |
| 4254 | + | |
| 4255 | + | |
4256 | 4256 | | |
4257 | 4257 | | |
4258 | 4258 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments