From a128e0b85ebe3e82480aa4e3c1c55769c8f76632 Mon Sep 17 00:00:00 2001 From: Thomas Pellissier-Tanon Date: Fri, 22 Aug 2025 11:50:40 +0200 Subject: [PATCH 1/7] fill PyTypeInfo::NAME with a Pythonic value --- newsfragments/5352.changed.md | 1 + src/conversions/jiff.rs | 14 +-- src/exceptions.rs | 193 +++++++++++++++++++++++++++------ src/types/any.rs | 3 +- src/types/boolobject.rs | 2 +- src/types/bytearray.rs | 2 +- src/types/bytes.rs | 2 +- src/types/capsule.rs | 2 +- src/types/code.rs | 3 +- src/types/complex.rs | 1 + src/types/datetime.rs | 15 ++- src/types/dict.rs | 4 + src/types/float.rs | 1 + src/types/frame.rs | 1 + src/types/frozenset.rs | 2 + src/types/function.rs | 4 +- src/types/genericalias.rs | 3 +- src/types/list.rs | 2 +- src/types/mappingproxy.rs | 1 + src/types/memoryview.rs | 2 +- src/types/mod.rs | 26 ++--- src/types/module.rs | 2 +- src/types/num.rs | 2 +- src/types/pysuper.rs | 3 +- src/types/range.rs | 2 +- src/types/set.rs | 2 + src/types/slice.rs | 1 + src/types/string.rs | 2 +- src/types/traceback.rs | 1 + src/types/tuple.rs | 2 +- src/types/typeobject.rs | 2 +- src/types/weakref/reference.rs | 1 + 32 files changed, 230 insertions(+), 74 deletions(-) create mode 100644 newsfragments/5352.changed.md diff --git a/newsfragments/5352.changed.md b/newsfragments/5352.changed.md new file mode 100644 index 00000000000..d69732d3df2 --- /dev/null +++ b/newsfragments/5352.changed.md @@ -0,0 +1 @@ +fill `PyTypeInfo::NAME` with Pythonic values (e.g. BasedException) instead of C ones (e.g. PyBasedException) \ No newline at end of file diff --git a/src/conversions/jiff.rs b/src/conversions/jiff.rs index fd2503646c0..01eba1988d2 100644 --- a/src/conversions/jiff.rs +++ b/src/conversions/jiff.rs @@ -533,31 +533,31 @@ mod tests { let none = py.None().into_bound(py); assert_eq!( none.extract::().unwrap_err().to_string(), - "TypeError: 'NoneType' object cannot be converted to 'PyDelta'" + "TypeError: 'NoneType' object cannot be converted to 'timedelta'" ); assert_eq!( none.extract::().unwrap_err().to_string(), - "TypeError: 'NoneType' object cannot be converted to 'PyTzInfo'" + "TypeError: 'NoneType' object cannot be converted to 'tzinfo'" ); assert_eq!( none.extract::().unwrap_err().to_string(), - "TypeError: 'NoneType' object cannot be converted to 'PyTzInfo'" + "TypeError: 'NoneType' object cannot be converted to 'tzinfo'" ); assert_eq!( none.extract::