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

Improve affix_stack error on Affix file / class name mismatch #63

Open
choksi81 opened this issue Oct 30, 2014 · 0 comments
Open

Improve affix_stack error on Affix file / class name mismatch #63

choksi81 opened this issue Oct 30, 2014 · 0 comments

Comments

@choksi81
Copy link
Contributor

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.r2py defines a class 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_affix tries to copy the Affix's _context, that context (named after the class) doesn't exist, resulting in the KeyError.

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'
@aaaaalbert aaaaalbert changed the title tcprelayaffix throws strange error on mismatch of File & Affix component name Improve affix_stack error on Affix file / class name mismatch Oct 31, 2014
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

1 participant