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

Source file not found for magics #1799

Closed
fperez opened this issue May 31, 2012 · 7 comments · Fixed by #1845
Closed

Source file not found for magics #1799

fperez opened this issue May 31, 2012 · 7 comments · Fixed by #1845
Labels
Milestone

Comments

@fperez
Copy link
Member

fperez commented May 31, 2012

After the refactoring of the magics, the display of their source files stopped working:

Type:       Magic function
Base Class: <type 'instancemethod'>
String Form:<bound method ExecutionMagics.run of <IPython.core.magics.execution.ExecutionMagics object at 0x90daf2c>>
Namespace:  IPython internal
File:       Dynamically generated function. No source code available.
@fperez
Copy link
Member Author

fperez commented May 31, 2012

The problem is that these magics are now created via a decorator, and we need to introspect into that in order to find the source file.

@takluyver
Copy link
Member

If the decorator sets the __wrapped__ attribute on the functions it creates, our introspection should go and look that up.

@fperez
Copy link
Member Author

fperez commented May 31, 2012

Yup, that's what we need to do. Haven't had the chance to write the code yet, so feel free to beat me to the punch :)

@bfroehle
Copy link
Contributor

I don't seem to be able to reproduce this. :(

@fperez
Copy link
Member Author

fperez commented Jun 4, 2012

@bfroehle, what do you get if you type run? in a plain ipython? Specifically, what does the 'file' field say for you? In my case it's:

File:       Dynamically generated function. No source code available.

and that's the problem. It should be able to find it...

@bfroehle
Copy link
Contributor

bfroehle commented Jun 4, 2012

@fperez: Aha, yes, it says "No source code available."

But run?? does produce a listing of the source:


String Form:<bound method ExecutionMagics.run of <IPython.core.magics.execution.ExecutionMagics object at 0x2e13990>>
Namespace:  IPython internal
File:       Dynamically generated function. No source code available.
Definition: run(self, parameter_s='', runner=None, file_finder=<function get_py_filename at 0x269b230>)
Source:
    @skip_doctest
    @line_magic
    def run(self, parameter_s='', runner=None,
                  file_finder=get_py_filename):
        """Run the named file inside IPython as a program.

        Usage:\\
          %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]

        Parameters after the filename are passed as command-line arguments to
        the program (put in sys.argv). Then, control returns to IPython's
        prompt.

        This is similar to running at a system prompt:\\
          $ python file args\\
        but with the advantage of giving you IPython's tracebacks, and of

@fperez
Copy link
Member Author

fperez commented Jun 4, 2012

Ah, ok, I do see that as well. But #1845 fixes everything to show the correct path (plus refactoring old code and adding tests).

@fperez fperez closed this as completed in 44b8121 Jun 11, 2012
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
Fixes to inspection machinery for magics

Now that magics are generated via decorators, the inspection machinery wasn't finding data about them such as source code. Fixes that along with some refactoring, cleanup and test additions.

Closes ipythongh-1799.
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.

3 participants