Skip to content

Unable to use profile under bpython #554

Open
@vaygr

Description

@vaygr

Hi,

It seems there's something wrong with namespaces?
I'm trying to use profile/cProfile under bpython:

>>> import cProfile
>>> def func():
...     pass
... 
>>> cProfile.run('func()')
         2 function calls in 0.000 seconds

   Ordered by: standard name

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000    0.000    0.000 <string>:1(<module>)
        1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Prof
iler' objects}


Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/usr/lib/python2.7/cProfile.py", line 29, in run
    prof = prof.run(statement)
  File "/usr/lib/python2.7/cProfile.py", line 135, in run
    return self.runctx(cmd, dict, dict)
  File "/usr/lib/python2.7/cProfile.py", line 140, in runctx
    exec cmd in globals, locals
  File "<string>", line 1, in <module>
NameError: name 'func' is not defined

Though under plain interpreter it works just well:

>>> import cProfile
>>> def func():
...     pass
... 
>>> cProfile.run('func()')
         3 function calls in 0.000 seconds

   Ordered by: standard name

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000    0.000    0.000 <stdin>:1(func)
        1    0.000    0.000    0.000    0.000 <string>:1(<module>)
        1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects} 

or am I missing something?

The version is 0.14.2.

Interesting thing is: it was just fine with 0.13.2 as well as with default interpreter.

p.s. probably because of new curtsies frontend. If I run that code in 'bpython-curses', everything goes smoothly.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions