pysnmp icon indicating copy to clipboard operation
pysnmp copied to clipboard

ASN.1 source path containing \U char in Windows OS

Open kingUnique opened this issue 6 years ago • 3 comments
trafficstars

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> ....

kingUnique avatar Sep 18 '19 07:09 kingUnique

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?

etingof avatar Sep 23 '19 17:09 etingof

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.

kingUnique avatar Sep 24 '19 09:09 kingUnique

I can reproduce this issue and it seems that mibdump works badly with Windows path. This requires significant changes in pysmi module.

lextm avatar Feb 12 '23 16:02 lextm