Fixes #538 . Also completes work begun in PR #539 .
Hopefully all AST node classes are overridable now. Added a few unit tests.
This also addresses an issue where the module_suffix and module_name parameters to create_pattern_object() would be honored on first call and thereafter ignored. This happened because the class overrides were read and cached in a class-level field, so it was shared among all instances of the visitor. That means new visitor instances were using overrides set up for old instances. Unit tests uncovered this problem because the v20 and v21 unit tests use different AST node class overrides. Whoever ran first would set the class overrides and break the unit tests for whoever ran second.
The new implementation does not cache classes at all. It loads the module with the classes, and looks up classes directly on that module without caching anything. Each visitor instance can have a different module instance, so they each can have their own overrides.
Fixes #538 . Also completes work begun in PR #539 .
Hopefully all AST node classes are overridable now. Added a few unit tests.
This also addresses an issue where the
module_suffix
andmodule_name
parameters tocreate_pattern_object()
would be honored on first call and thereafter ignored. This happened because the class overrides were read and cached in a class-level field, so it was shared among all instances of the visitor. That means new visitor instances were using overrides set up for old instances. Unit tests uncovered this problem because the v20 and v21 unit tests use different AST node class overrides. Whoever ran first would set the class overrides and break the unit tests for whoever ran second.The new implementation does not cache classes at all. It loads the module with the classes, and looks up classes directly on that module without caching anything. Each visitor instance can have a different module instance, so they each can have their own overrides.