pysnmp
pysnmp copied to clipboard
ASN.1 source path containing \U char in Windows OS
Upon using the addAsn1MibSource function to compile a custom asn1 mib file, the compiled file will be placed by default in %HOMEPATH%\PySNMP Configuration\mibs the HOMEPATH defaults to:
drive:\Users<username>, so the builder.py generates the following error:
`SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 240-241: truncated \UXXXXXXXX escape`
Manually adding a second slash to the compiled mib file solves the issue (Before the U): .... ASN.1 source _file://C:\\Users...<mib_path> ....
Thank you for reporting this issue!
Did I get it right, that the Python file being generated (i.e. MIB) is failing to be parsed because of unescaped unicode code (i.e. \U) in it?
That's correct. I've also noticed (although not affecting the correct functionality in any way) that the mib compiler probably also fails to detect the host, platform... because there are question marks in those fields in the compiled mib
Produced by pysmi-0.4.0 at Wed Sep 18 11:29:25 2019
On host ? platform ? version ? by user ?
The same mib compiled on a linux system does not have those question marks.
I can reproduce this issue and it seems that mibdump works badly with Windows path. This requires significant changes in pysmi module.