This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: hotshot.runctx: builtins missing
Type: enhancement Stage: patch review
Components: Interpreter Core Versions: Python 3.2
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: BreamoreBoy, jneb, vdupras
Priority: normal Keywords: patch

Created on 2005-02-23 13:21 by jneb, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
hotshot_builtins_globals.diff vdupras, 2008-02-19 13:58
Messages (6)
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) (Python triager) 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) (Python triager) Date: 2008-02-19 12:57
oh crap here goes my ego... pasted the wrong line.
msg62562 - (view) Author: Virgil Dupras (vdupras) (Python triager) 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.
msg110431 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-07-16 12:33
I can't see any sense running with this as hotshot is not documented in py3k and is marked as unsupported in py2k docs.
msg110814 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-07-19 22:23
Closing as noone has responded.
History
Date User Action Args
2022-04-11 14:56:09adminsetgithub: 41618
2010-07-19 22:23:56BreamoreBoysetstatus: pending -> closed
resolution: wont fix
messages: + msg110814
2010-07-16 12:33:41BreamoreBoysetstatus: open -> pending
versions: + Python 3.2, - Python 2.7
nosy: + BreamoreBoy

messages: + msg110431
2009-02-15 23:49:55ajaksu2setkeywords: + patch
stage: patch review
type: enhancement
versions: + Python 2.7, - Python 2.3
2008-02-19 13:58:20vduprassetfiles: + hotshot_builtins_globals.diff
messages: + msg62562
2008-02-19 12:57:00vduprassetmessages: + msg62560
2008-02-19 12:55:52vduprassetnosy: + vdupras
messages: + msg62559
2005-02-23 13:21:39jnebcreate