Reduce the direct access to tp_name which is not part of the limited API
Refs #1125
This commit is contained in:
parent
bd12d89a3e
commit
d93a5e308f
|
@ -38,10 +38,7 @@ macro_rules! impl_exception_boilerplate {
|
||||||
|
|
||||||
impl std::fmt::Debug for $name {
|
impl std::fmt::Debug for $name {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
use $crate::AsPyPointer;
|
let type_name = self.get_type().name();
|
||||||
let py_type_name =
|
|
||||||
unsafe { std::ffi::CStr::from_ptr((*(*self.as_ptr()).ob_type).tp_name) };
|
|
||||||
let type_name = py_type_name.to_string_lossy();
|
|
||||||
f.debug_struct(&*type_name)
|
f.debug_struct(&*type_name)
|
||||||
// TODO: print out actual fields!
|
// TODO: print out actual fields!
|
||||||
.finish()
|
.finish()
|
||||||
|
@ -50,10 +47,7 @@ macro_rules! impl_exception_boilerplate {
|
||||||
|
|
||||||
impl std::fmt::Display for $name {
|
impl std::fmt::Display for $name {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
use $crate::AsPyPointer;
|
let type_name = self.get_type().name();
|
||||||
let py_type_name =
|
|
||||||
unsafe { std::ffi::CStr::from_ptr((*(*self.as_ptr()).ob_type).tp_name) };
|
|
||||||
let type_name = py_type_name.to_string_lossy();
|
|
||||||
write!(f, "{}", type_name)?;
|
write!(f, "{}", type_name)?;
|
||||||
if let Ok(s) = self.str() {
|
if let Ok(s) = self.str() {
|
||||||
write!(f, ": {}", &s.to_string_lossy())
|
write!(f, ": {}", &s.to_string_lossy())
|
||||||
|
|
Loading…
Reference in a new issue