Issue1149798
Created on 2005-02-23 13:21 by jneb, last changed 2009-02-15 23:49 by ajaksu2.
|
msg60676 - (view) |
Author: Jurjen N.E. Bos (jneb) |
Date: 2005-02-23 13:21 |
|
We start with a boring example.
>>> import profile
>>> profile.Profile().runctx('print len',{},{})
<built-in function len>
<profile.Profile instance at 0x3c9ccd8>
No news here. But if we do exactly the same using hotshot, we
get:
>>> import hotshot
>>> hotshot.Profile('/tmp/hs').runctx('print len',{},{})
Traceback (most recent call last):
File "<input>", line 1, in ?
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
python2.4/hotshot/__init__.py", line 65, in runctx
self._prof.runcode(code, globals, locals)
File "<string>", line 1, in ?
NameError: name 'len' is not defined
The following workaround works:
>>> hotshot.Profile('/tmp/hs').runctx('print len',{'__builtins__':
__builtins__},{})
<built-in function len>
<hotshot.Profile instance at 0x3cba6e8>
But I don't believe this is the way hotshot is supposed to work.
This is on Mac Python, IDE, both 2.3 and 2.4, but I think that
doesn't matter at all!
- Jurjen
|
|
msg62559 - (view) |
Author: Virgil Dupras (vdupras) |
Date: 2008-02-19 12:55 |
|
Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04)
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import hotshot
>>> hotshot.Profile('/tmp/hs').runctx('print len',{'__builtins__':
... __builtins__},{})
<built-in function len>
<hotshot.Profile instance at 0x6a940>
>>>
Can we close this now?
|
|
msg62560 - (view) |
Author: Virgil Dupras (vdupras) |
Date: 2008-02-19 12:57 |
|
oh crap here goes my ego... pasted the wrong line.
|
|
msg62562 - (view) |
Author: Virgil Dupras (vdupras) |
Date: 2008-02-19 13:58 |
|
Well, since I brought that issue back, I might as well supply a patch. So
if indeed it is decided that hotshot.Profile.runctx() should have
__builtins__ in its globals by default, here is it.
|
|
| Date |
User |
Action |
Args |
| 2009-02-15 23:49:55 | ajaksu2 | set | keywords:
+ patch stage: patch review type: feature request versions:
+ Python 2.7, - Python 2.3 |
| 2008-02-19 13:58:20 | vdupras | set | files:
+ hotshot_builtins_globals.diff messages:
+ msg62562 |
| 2008-02-19 12:57:00 | vdupras | set | messages:
+ msg62560 |
| 2008-02-19 12:55:52 | vdupras | set | nosy:
+ vdupras messages:
+ msg62559 |
| 2005-02-23 13:21:39 | jneb | create | |
|