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

sh.py and ipython for python 3.3 #2577

Closed
amoffat opened this issue Nov 14, 2012 · 3 comments · Fixed by #3484
Closed

sh.py and ipython for python 3.3 #2577

amoffat opened this issue Nov 14, 2012 · 3 comments · Fixed by #3484
Labels
Milestone

Comments

@amoffat
Copy link

amoffat commented Nov 14, 2012

Someone using sh.py with ipython ran into the following issue, and I was hoping someone with better working knowledge of ipython's internals could shed some light on what's happening: amoffat/sh/issues/97

sh.py has some magic going on internally, where any attribute access on the module can resolve dynamically to a specific object. This issue only seems to be in ipython for python 3.3, python 2.7 works fine. Anyone have an idea of what could be happening?

Thanks

@takluyver
Copy link
Member

It seems Python 3.2 changed hasattr() to only catch AttributeError, rather than any exception. Here's the mailing list thread and the bug report for it.

I think we should catch this in IPython, but I consider that 'protecting against misbehaving code'. To be a good Python citizen, I think sh should:

  • Catch any special attribute lookups (__x__), and, if there isn't a sensible return value, just raise AttributeError without trying to look them up as program names. This would deal with the first case reported.
  • If attribute access fails because a command can't be found, ideally the error raised should be a subclass of AttributeError.

That would help other tools that try to do introspection as well.

@amoffat
Copy link
Author

amoffat commented Nov 16, 2012

Thanks for the feedback @takluyver, I'll take care of it in sh

@amoffat amoffat closed this as completed Nov 16, 2012
@takluyver takluyver reopened this Nov 16, 2012
@takluyver
Copy link
Member

Reopening, because we'll fix this in IPython as well. Even if code is doing bizarre stuff, it shouldn't be able to crash IPython. And if there's one bit of code in the wild doing this, chances are there are others.

takluyver added a commit to takluyver/ipython that referenced this issue Jun 29, 2013
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants