This repository was archived by the owner on Oct 1, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
This repository was archived by the owner on Oct 1, 2025. It is now read-only.
Improve affix_stack error on Affix file / class name mismatch #63
Copy link
Copy link
Open
Description
If the file containing an Affix component class is not named class name (in lower case) + .r2py, then calling affix_stack.find_and_register_affix might succeed importing, but fail registering internally the component, and throw a rather unspecific KeyError.
In the code leading to the traceback below,
transparenttcprelayaffix.r2pydefines aclass Transparent_TCPRelayAffix;- the user code tries to instantiate an Affix stack including
TransparentTCPRelayAffix(which yields the filename when.lowered, but is not the class name), and - when
affix_stack.find_and_register_affixtries to copy the Affix's_context, that context (named after the class) doesn't exist, resulting in theKeyError.
It would be a good idea to check for this mismatch, and raise a more descriptive error message. (I assume a developer running unit tests would catch it very early on in the development, and trivially correct this mistake).
Uncaught exception!
---
Following is a full traceback, and a user traceback.
The user traceback excludes non-user modules. The most recent call is displayed last.
Full debugging traceback:
"repy.py", line 154, in execute_namespace_until_completion
"/private/tmp/affix/RUNNABLE/virtual_namespace.py", line 117, in evaluate
"/private/tmp/affix/RUNNABLE/safe.py", line 588, in safe_run
"dylink.r2py", line 546, in <module>
"dylink.r2py", line 407, in dylink_dispatch
"dylink.r2py", line 520, in evaluate
"/private/tmp/affix/RUNNABLE/virtual_namespace.py", line 117, in evaluate
"/private/tmp/affix/RUNNABLE/safe.py", line 588, in safe_run
"test-ttr.r2py", line 5, in <module>
"affix_stack.r2py", line 32, in __init__
"affix_stack.r2py", line 133, in build_stack
"affix_stack.r2py", line 218, in find_and_register_affix
"/private/tmp/affix/RUNNABLE/safe.py", line 678, in __getitem__
User traceback:
"dylink.r2py", line 546, in <module>
"dylink.r2py", line 407, in dylink_dispatch
"dylink.r2py", line 520, in evaluate
"test-ttr.r2py", line 5, in <module>
"affix_stack.r2py", line 32, in __init__
"affix_stack.r2py", line 133, in build_stack
"affix_stack.r2py", line 218, in find_and_register_affix
Exception (with type 'exceptions.KeyError'): 'Transparent_TCPRelayAffix'
Metadata
Metadata
Assignees
Labels
No labels