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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions IPython/extensions/rmagic.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,14 @@ def Rpush(self, line, local_ns=None):
try:
val = local_ns[input]
except KeyError:
val = self.shell.user_ns[input]
try:
val = self.shell.user_ns[input]
except KeyError:
# reraise the KeyError as a NameError so that it looks like
# the standard python behavior when you use an unnamed
# variable
raise NameError("name '%s' is not defined" % input)

self.r.assign(input, self.pyconverter(val))

@skip_doctest
Expand Down Expand Up @@ -511,7 +518,10 @@ def R(self, line, cell=None, local_ns=None):
try:
val = local_ns[input]
except KeyError:
val = self.shell.user_ns[input]
try:
val = self.shell.user_ns[input]
except KeyError:
raise NameError("name '%s' is not defined" % input)
self.r.assign(input, self.pyconverter(val))

png_argdict = dict([(n, getattr(args, n)) for n in ['units', 'height', 'width', 'bg', 'pointsize']])
Expand Down