-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
LLDP-MIB - Cannot create a consistent method resolution #90
Comments
Similar to #91, this is a bug in PySMI where it should further analyze the generated types and avoid duplicate inheritance. While the bugfix won't come soon, the manual workaround is also simple,
BTW, please switch from |
Close it now as won't work on it in near future. |
We ran into this issue too, with the MIB compilation step in our application after switching to Python 3.12. Manually fixing the .py file was no full work-around, because we generate the .py files on application startup in our Docker container, based on a plugin system (where each plugin can provide extra MIBs when required). Therefore, I automated the process of fixing the code, by leveraging the Python As possible inspiration for others that run into the same issue, here the gist of the method in our compiler that takes care of fixing the generate pysnmp MIB files that are stored in the import ast
from pathlib import Path
class VisitorThatFixesMroIssue(ast.NodeTransformer):
def __init__(self) -> None:
super().__init__()
self.did_fix_code = False
def visit_ClassDef(self, node: ast.ClassDef) -> ast.AST:
base_names = [base.id for base in node.bases if isinstance(base, ast.Name)]
if base_names == ['TextualConvention', 'DisplayString']:
node.bases = [node.bases[1]]
self.did_fix_code = True
return self.generic_visit(node)
def fix_mib_py_file(file_path: Path) -> None:
tree = ast.parse(source=file_path.read_text())
visitor = VisitorThatFixesMroIssue()
visitor.visit(tree)
if visitor.did_fix_code:
file_path.write_text(ast.unparse(tree)) Just an idea A quick fix for the pysmi code, might be to apply the above change right from the code generating template at https://github.com/lextudio/pysmi/blob/main/pysmi/codegen/templates/pysnmp/mib-definitions.j2#L219
|
Should have been fixed in PySMI release 1.5. |
Yes, I can confirm that it works for the issues that I ran into. |
Hello, |
Environment
Steps to Reproduce
Expected Behavior
LLDP-MIB::lldpRemTable
is resolved and the table entries are returned.For example (using linux command
snmptable
):Observed Behavior
A load error is occured with root cause the following python error:
The root cause is the
TypeError: Cannot create a consistent method resolution
, which indicates an inheritance issue.Please note that when using another MIB, such as
IF-MIB::ifTable
, the resolution works correctly and no errors occur.The text was updated successfully, but these errors were encountered: