-
-
Notifications
You must be signed in to change notification settings - Fork 205
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
Cannot Pickle DisplayString & other objects that use TextualConvention #100
Comments
Can you please try pickling with the this pyasn1 branch and let me know if this helps? The relevant discussion is here. |
I still seem to be having the same issue after changing to the devel-0.4.1 branch of pyasn1. For some context, I'm pickling those objects when they are returned by |
I was able to recreate this just via this snippet:
Which produces the same error: I was able to pickle both BitString and NamedValues from pyasn1. |
I'd attribute this to
May be we should have |
Thank you for your response. I've since realised that it would probably make more sense to use your ASN.1 library to encode and decode the data as described here as data is transmitted in those formats for SNMP and the only objects I'm interested in (de)serializing are values from PySNMP to be transmitted via SNMP. I can't seem to work out how this is being done in PySNMP. The problem I am currently having is when trying to deserialize a 'SysUpTime' object. It seems to be encoded fine, however when I try to decode it an exception is thrown. I think I have misunderstood how this should work, but cannot seem to find any encoding/decoding of these objects within PySNMP itself.
I have tried not providing the asn1Spec argument but receive an error. Based on your example and the comments in the PyASN.1 code my intuition was that I should provide an instance of a SysUpTime object. For testing purposes I provided What I'm looking for is a way to take an object that is some derivative of ASN.1, serialize it for storage, and then later deserialize it (without needing to know the original class of the object if possible). Can you help me find a good approach to serialize and deserialize instances of these objects? |
I think you are on the right track here! Yes, you need to pass Can you please either paste a minimal reproducer or reveal the traceback? Your pseudocode looks good to me (except this minor nitpick |
Thanks for the reassurance! I've found that I'm not having this issue for other objects, it seems to work for DisplayString.
I have a suspicion that the strange passing and usage of the standard MibInstrum in a different, custom, MibInstrum is causing it. Although the different behaviour for different objects makes me unsure. |
The problematic request: However this works fine: |
It's entirely possible that what I'm trying to achieve is completely insane, or the wrong approach, if so then I do apologise.
I have tried Pickle but it fails on DisplayString objects.
Is there any way I can serialise and deserialize these objects, to store them in a file, without needing to know which type I have (i.e. DisplayString, TruthValue, etc)?
The text was updated successfully, but these errors were encountered: