-
Notifications
You must be signed in to change notification settings - Fork 597
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
RecursionError when unpickling message object #804
Comments
This is fixed in The problem is that diff --git i/can/message.py w/can/message.py
index f85218f..1675e49 100644
--- i/can/message.py
+++ w/can/message.py
@@ -54,6 +54,8 @@ class Message(object):
# this entire method (as well as the _dict attribute in __slots__ and the __setattr__ method)
# can be removed in 4.0
# this method is only called if the attribute was not found elsewhere, like in __slots__
+ if key not in self.__slots__:
+ raise AttributeError
try:
warnings.warn("Custom attributes of messages are deprecated and will be removed in 4.0", DeprecationWarning)
return self._dict[key] @hardbyte, would you prefer a fix similar to this diff, or should we just backport the removal from |
__getattr__ incorrectly assumes that self._dict always exists. However, if self._dict doesn't exist, the function attempts to call __getattr__ again, which results in infinite recursion when serializing the object via pickle. This fixes the implementation of __getattr__ and adds a test to exercise pickling/unpickling the Message. Fixes hardbyte#804
__getattr__ incorrectly assumes that self._dict always exists. However, if self._dict doesn't exist, the function attempts to call __getattr__ again, which results in infinite recursion when serializing the object via pickle. This fixes the implementation of __getattr__ and adds a test to exercise pickling/unpickling the Message. Fixes #804
Add a test that exercises pickling/unpickling of a Message. Addresses hardbyte#804
Add a test that exercises pickling/unpickling of a Message. Addresses #804
The change has been merged in the As such, closing this out. The fix will be available when |
Python 3.7.5
python-can 3.3.2
To hand over messages to another process I intended to use multiprocessing.JoinableQueue.
I stumbled over a RecursionError and tracked it down to the pickleing that is used to serialize the objects (see example code).
The error occurs when calling loads() on the serialized message.
I'm not a python expert and found some clues regarding the __getattr__ method. Maybe a custom __getattr__ method is needed for the message objects?
Is there another way to hand over the emssage objects to another process?
Console output:
The text was updated successfully, but these errors were encountered: