Skip to content
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

Sensor breaks with pyasn1 package #23

Closed
elgris opened this issue Sep 19, 2017 · 2 comments
Closed

Sensor breaks with pyasn1 package #23

elgris opened this issue Sep 19, 2017 · 2 comments

Comments

@elgris
Copy link
Contributor

elgris commented Sep 19, 2017

Basically, you can find the suspect here:

meter.py

...
    def collect_modules(self):
        try:
            m = sys.modules
            r = {}
            for k in m:
                if m[k]:
                    d = m[k].__dict__
                    if "version" in d and d["version"]:
                        r[k] = self.jsonable(d["version"])
                    elif "__version__" in d and d["__version__"]:
                        r[k] = self.jsonable(d["__version__"])
                    else:
                        r[k] = "builtin"

            return r
        except Exception as e:
            l.error("collect_modules: ", str(e))

            return None
...

Following line of code fails if module pyasn1 is being processed:

if "version" in d and d["version"]

exception thrown is pyasn1.error.PyAsn1Error: Uninitialized ASN.1 value ("__nonzero__" attribute looked up)

This problem came from package pysnmp which imports pyasn1

Snippet to reproduce

You can reproduce this problem with a small snippet

import sys
from pysnmp.entity.rfc3413.oneliner import cmdgen

m = sys.modules
r = {}
for k in m:
    if m[k]:
        d = m[k].__dict__
        if "version" in d and d["version"]:
            r[k] = d["version"]
        elif "__version__" in d and d["__version__"]:
            r[k] = d["__version__"]
        else:
            r[k] = "builtin"
print(r)
@elgris
Copy link
Contributor Author

elgris commented Sep 19, 2017

Just in case: pyasn1-0.3.5 was used

@pglombardo
Copy link
Contributor

Thanks @elgris - this was very helpful. Fixed in #24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants