Re: Cannot marshal objects
> Because the marshaling is happening in the guts of xmlrpc. Okay, I misunderstood your original message. You used the word "marshal" (and the xmlrpc error did as well). I thought you were referring to the marshal module. I didn't understand (and ignored) the references to the xmlrpc module. In Python 3, the Marshaller class has migrated into the xmlrpc.client module. Your code worked for me in 3.8. Note, however, that this is not going to round trip properly. You will stuff in a Decimal object at one end and get out a double at the other end. Recent versions support unmarshalling to Decimal objects in the Unmarshaller class. I don't know why the Marshaller class doesn't accept Decimal objects for serialization. You could try this: def dump_decimal(self, value, write): write("") write(str(value)) write("\n") xmlrpc.client.Marshaller.dispatch[decimal.Decimal] = dump_decimal I used the "ex:" prefix based on this document: http://ws.apache.org/xmlrpc/types.html YMMV. The tag name understood by the Unmarshaller class doesn't include that prefix. Skip -- https://mail.python.org/mailman/listinfo/python-list
Re: Cannot marshal objects
On 11/27/20 4:05 PM, Skip Montanaro wrote: I am getting this error. I assume you mean the email subject. It doesn't work in 3.8 either: Yes I do and that's too bad. but that's not surprising to me. The marshal module is more-or-less meant to serialize Python byte code. Pickle is more generally used for object serialization. Why not use it? Because the marshaling is happening in the guts of xmlrpc. I may have solved it anyway. The code I was running was spitting out that error but I think it was actually happening in the server that it was connecting to. I just added that same code to the server. Have to wait until Monday to test. I will update the list if it fixes it. -- D'Arcy J.M. Cain Vybe Networks Inc. A unit of Excelsior Solutions Corporation - Propelling Business Forward http://www.VybeNetworks.com/ IM:da...@vybenetworks.com VoIP: sip:da...@vybenetworks.com OpenPGP_signature Description: OpenPGP digital signature -- https://mail.python.org/mailman/listinfo/python-list
Re: Cannot marshal objects
> I am getting this error. I assume you mean the email subject. It doesn't work in 3.8 either: >>> import decimal >>> d = decimal.Decimal(3.5) >>> d Decimal('3.5') >>> import marshal >>> marshal.dumps(d) Traceback (most recent call last): File "", line 1, in ValueError: unmarshallable object but that's not surprising to me. The marshal module is more-or-less meant to serialize Python byte code. Pickle is more generally used for object serialization. Why not use it? >>> import pickle, decimal >>> d = decimal.Decimal(3.5) >>> pickle.dumps(d) b'\x80\x04\x95!\x00\x00\x00\x00\x00\x00\x00\x8c\x07decimal\x94\x8c\x07Decimal\x94\x93\x94\x8c\x033.5\x94\x85\x94R\x94.' That's meant more for serialization of data objects. Skip -- https://mail.python.org/mailman/listinfo/python-list
Cannot marshal objects
I am getting this error. I found this recipe to fix it: from xmlrpclib import Marshaller from decimal import Decimal def dump_decimal(self, value, write): write("") write(str(value)) write("\n") Marshaller.dispatch[Decimal] = dump_decimal That seems to be for Python 2. I am running Python 3.5 (I know but I am stuck there for the moment). I tried changing the import to "from xmlrpcl.client import Marshaller" which didn't raise an error but the problem still persists. Do I need to do something different for Python 3? TIA. -- D'Arcy J.M. Cain Vybe Networks Inc. A unit of Excelsior Solutions Corporation - Propelling Business Forward http://www.VybeNetworks.com/ IM:da...@vybenetworks.com VoIP: sip:da...@vybenetworks.com OpenPGP_signature Description: OpenPGP digital signature -- https://mail.python.org/mailman/listinfo/python-list