Skip to content
This repository

- There is a bug when running the profiler in the magic command (prun) with python3 #901

Closed
wants to merge 1 commit into from

3 participants

Alcides Viamontes E Thomas Kluyver Fernando Perez
Alcides Viamontes E
%run -p <...> . And this is an attempt to solve it.

I'm not sure if this is the correct way to handle it.

Regards.

Alcides Viamontes E - There is a bug when running the profiler in the magic command
    %run -p <...> . And this is an attempt to solve it.
687bebd
Alcides Viamontes E

Oh, I didn't notice this is the wrong repos! My apologies!

Alcides Viamontes E dsign closed this October 19, 2011
Thomas Kluyver takluyver reopened this October 19, 2011
Thomas Kluyver
Collaborator

It's OK, this actually is the right place for it now. After 0.11, we merged the Python 3 support in, so this code (which will become 0.12) should now install on Python 2 or Python 3.

I think this looks like a pretty sound approach.

Fernando Perez
Owner

@takluyver, I'll leave it up to you to review/merge this one, since it's on the py3 territory. Let me know if you want a 2nd look on anything. @dsign, thanks for the contribution!

Thomas Kluyver
Collaborator

It looks fine, I'm just going to run a few tests before I merge it. Actually, it's probably a good candidate for adding an automated test. @dsign, do you want to do that? Have a look in IPython/core/tests/test_run.py. It needn't be complex, just check that doing %run -p succeeds.

Alcides Viamontes E

No problem, I will take care of it.

Thomas Kluyver
Collaborator

Great, thanks.

Alcides Viamontes E

Any hints as how to run a particular case in the test suite? The full test runs more or less o,k, but for individual tests I keep getting something about

global name 'get_ipython' is not defined

thanks in advance.

Alcides Viamontes E dsign closed this October 20, 2011
Thomas Kluyver takluyver reopened this October 20, 2011
Thomas Kluyver
Collaborator

Yes, there's some awkward trickery we do to inject get_ipython into the builtin namespace for the test suite. There's a way to specify it in the options to iptest, something like iptest IPython.core.tests.test_run:test_run_p. I normally just specify the package: iptest IPython.core, which takes a few seconds to run the tests.

Alcides Viamontes E dsign closed this October 21, 2011
Alcides Viamontes E

Please follow up on:

#916

I had deleted the original branch :-(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Oct 19, 2011
Alcides Viamontes E - There is a bug when running the profiler in the magic command
    %run -p <...> . And this is an attempt to solve it.
687bebd
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 5 additions and 1 deletion. Show diff stats Hide diff stats

  1. 6  IPython/core/magic.py
6  IPython/core/magic.py
@@ -1382,7 +1382,11 @@ def magic_prun(self, parameter_s ='',user_mode=1,
1382 1382
                 return
1383 1383
 
1384 1384
             arg_str = 'execfile(filename,prog_ns)'
1385  
-            namespace = locals()
  1385
+            namespace = {
  1386
+                'execfile': self.shell.safe_execfile,
  1387
+                'filename': filename,
  1388
+                'prog_ns': prog_ns
  1389
+            } 
1386 1390
 
1387 1391
         opts.merge(opts_def)
1388 1392
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.