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

Rmagic: error message when moving an non-existant variable from python to R #2737

Merged
merged 1 commit into from Jan 3, 2013

Conversation

rmcgibbo
Copy link
Contributor

@rmcgibbo rmcgibbo commented Jan 2, 2013

Currently, when you try to push a non-existant python variable to R, you get a KeyError

In [1]: %load_ext rmagic
In [2]: %Rpush sdf

[... traceback ...]

KeyError: u'sdf'

Maybe the error message could be more intuitive? The fact that local variables are stored in a dict (thus generating a KeyError) is kind-of an implementation detail.

In regular python, using an undefined variable name generates a NameError -- perhaps that would also be the appropriate error to raise in this case?

This PR changes the error to:

In [1]: %load_ext rmagic
In [2]: %Rpush sdf

[... traceback ...]

NameError: name 'sdf' is not defined

@takluyver
Copy link
Member

+1, I think this makes sense.

bfroehle added a commit that referenced this pull request Jan 3, 2013
Rmagic: error message when moving an non-existant variable from python to R
@bfroehle bfroehle merged commit 840d0ea into ipython:master Jan 3, 2013
@bfroehle
Copy link
Contributor

bfroehle commented Jan 3, 2013

Thanks.

jenshnielsen added a commit to jenshnielsen/ipython that referenced this pull request Jan 3, 2013
bfroehle added a commit that referenced this pull request Jan 3, 2013
Fix tests for rmagic (KeyError -> NameError).

Caused by #2737.
@rmcgibbo rmcgibbo deleted the rmagic_informative_error branch January 3, 2013 23:48
minrk pushed a commit to minrk/ipython that referenced this pull request Jan 26, 2013
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
Rmagic: error message when moving an non-existant variable from python to R
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
Fix tests for rmagic (KeyError -> NameError).

Caused by ipython#2737.
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

Successfully merging this pull request may close these issues.

None yet

3 participants