Skip to content

fix for #10327 : replacing support for get_ipython().magic() - #10638

Merged
takluyver merged 6 commits into
ipython:masterfrom
adityausathe:master
Jun 9, 2017
Merged

takluyver merged 6 commits into
ipython:masterfrom
adityausathe:master

Conversation

@adityausathe

Copy link
Copy Markdown
Contributor

There was no direct calls made to get_ipython().run_line_magic(), instead we were calling get_ipython().magic() first which calls get_ipython().run_line_magic() from it's body. That was the reason hist -t showing get_ipython().magic() instead of get_ipython().run_line_magic() because that's what was happening in there.

I replaced calls to get_ipython().magic() by get_ipython().run_line_magic(). But, there are some tests in IPython/core/tests/.. which still make calls to get_ipython().magic(). I haven't changed them.
#10327

@adityausathe

adityausathe commented Jun 4, 2017 •

Copy link
Copy Markdown
Contributor Author

It seems that the tests should also need to be changed in order to accommodate the changes. The checks are failing at those points. Are we changing the test cases?
@Carreau
@takluyver

@Carreau

Carreau commented Jun 5, 2017

Copy link
Copy Markdown
Member

Hi there, thanks you probably want to synchronize with #10612 which is also trying to update this.
Yes the test need to be updated, but we need to make sure get_ipython().magic() still works at least until it is removed.

@adityausathe

Copy link
Copy Markdown
Contributor Author

Summary:

  • Replaced direct calls to get_ipython().magic() with get_ipython().run_line_magic()
  • Updated test cases to accommodate the change.
  • Added backward compatibility support for get_ipython().magic(), by updating stack_depth

@Carreau
@takluyver

@srinivasreddy srinivasreddy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. thanks.

Comment thread IPython/core/interactiveshell.py Outdated
magic_kind=magic_kind, magic_name=magic_name)

def run_line_magic(self, magic_name, line):
def run_line_magic(self, magic_name, line, back_compat=False):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make the parameter _stack_depth=1 rather than back_compat=False - that's a bit clearer about what it means. The leading underscore would suggest that it's not for normal use.

[(u'a =% who', "a = get_ipython().magic({u}'who')"),
(u'b = %who', "b = get_ipython().magic({u}'who')"),
(u'c= %ls', "c = get_ipython().magic({u}'ls')"),
[(u'a =% who', "a = get_ipython().run_line_magic({u}'who', {u}'')"),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So long as we're targeting IPython 6.x, we can get rid of the {u} things in the tests - that's for Python 2 compatibility, which we've dropped now.

@adityausathe

Copy link
Copy Markdown
Contributor Author

@takluyver
Thanks for the feedback.
Incorporated suggested changes.

@takluyver takluyver added this to the 6.2 milestone Jun 9, 2017
@takluyver
takluyver merged commit c05f400 into ipython:master Jun 9, 2017
@takluyver

Copy link
Copy Markdown
Member

Thanks

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.

4 participants