Issue 637906: Allow any file-like object on dis module (original) (raw)

Created on 2002-11-13 18:24 by hyeshik.chang, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
dis-diff.txt hyeshik.chang,2002-11-13 18:24 a patch
Messages (6)
msg41640 - (view) Author: Hyeshik Chang (hyeshik.chang) * (Python committer) Date: 2002-11-13 18:24
This was useful for me to make a restricted environment by disallowing specific opcodes.
msg41641 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-11-13 23:46
Logged In: YES user_id=21627 Can you please elaborate? In what way does is that useful for a restricted environment?
msg41642 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2002-11-14 16:56
Logged In: YES user_id=31435 I'm also missing the connection to restricted environments. If you want to capture dis output (or output from anything else that uses print), the usual way to do it is to assign a StringIO instance (or other file-like object) to sys.stdout before invoking dis.
msg41643 - (view) Author: Hyeshik Chang (hyeshik.chang) * (Python committer) Date: 2002-11-14 18:07
Logged In: YES user_id=55188 Yes. To disallow BINARY_POWER and INPLACE_POWER, I'm hooking sys.stdout now. But, because it isn't thread-safe way, I needed to lock threads whenever I print something to stdout. To make a cheaper solution, I like this patch.
msg41644 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-11-14 20:17
Logged In: YES user_id=21627 So you want to find out whether BINARY_POWER is in the byte code? If so, I suggest that usage of dis.disassemble is inadequate. Instead, you should just copy the essential part of the disassemble loop, and look for an opcode for which dis.opname[opcode] is 'BINARY_POWER'. This will be much faster, and thread-safe.
msg41645 - (view) Author: Hyeshik Chang (hyeshik.chang) * (Python committer) Date: 2002-11-18 05:02
Logged In: YES user_id=55188 Ah. Thank you for your comments. It looks much better than parsing dis's output.
History
Date User Action Args
2022-04-10 16:05:53 admin set github: 37468
2002-11-13 18:24:21 hyeshik.chang create