-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add PyObjectPayload trait and use it for PyObject.payload #670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@OddCoincidence any idea why it's failing with a segfault? |
Where are you seeing a segfault? I'm just seeing this in travis:
EDIT: I see it now, not sure why though... |
It's in the pytest tests, |
Okay, so I did some debugging, here's what I found. The new panic!("Error getting inner type: {:?}", obj.typ) but at that point typ: mem::uninitialized(), // ! (So the lesson is basically that So why does that impl fail? Because of this line: let payload: &dyn Any = &self.payload; The concrete type for this trait object is a |
Okay, I fixed it by using an |
Great job figuring that out, by the way; that probably would have taken me an hour. |
Oh boy, now it's a stack overflow. I didn't think this would be that hard. |
@coolreader18 I mentioned this on gitter, but in case you didn't see, I noticed that it only occurs with trace logging enabled, so that may be a good clue to help with troubleshooting this. |
That's interesting, I'll look into that. |
I have hit a similar issue before. It happened when trying to print Debug representation of a recursive value. This wasn't really a problem with the old PyObjectPayload as it only outputted the type of the payload rather than the value itself. |
Ah, so it's probably because the typ of object_type and type_type point to each other, so it's trying to print that and going on forever. Maybe. |
Yes, all the tests that are failing are ones that define some function, and it fails just after tracing with |
Alright, found the culprit: |
The remaining failures are due to recursive objects, e.g. |
If we want a detailed Debug formatting then we kinda do need something similar to that. We probably don't want to use the same guard as it could get weird if it's printed in a repr. |
I think for now it's probably fine to do like we did when we had PyObjectPayload as an enum and just have them be very basic strings, e.g "dict", "list", etc. |
Rather than changing the |
I think we do want to provide good |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me
I'm not sure about the name; I'm willing to change it to pretty much anything but I can't think of anything else right now. The main goal of this is to have a good Debug implementation for PyObject.payload, as discussed in #664.
Edit: this would close #664.