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: dis.dis gives different results if Ctrl-C is pressed
Type: Stage:
Components: Library (Lib) Versions: Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: benjamin.peterson, ivank, rhettinger
Priority: low Keywords:

Created on 2010-04-15 01:00 by ivank, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (5)
msg103161 - (view) Author: ivank (ivank) Date: 2010-04-15 01:00
If you run
>>> dis.dis(lambda: 99**1000003)
and press Ctrl-C immediately, you'll see the numbers without constant folding:
  1           0 LOAD_CONST               1 (99)
              3 LOAD_CONST               2 (1000003)
              6 BINARY_POWER        
              7 RETURN_VALUE        

If you wait long enough instead (don't press Ctrl-C), you'll see a very big number.

It seems strange to do two different things. Perhaps the KeyboardInterrupt should be rethrown instead?
msg103167 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2010-04-15 01:24
Probably due to the fact that the peepholer avoids constant folding when any exception happens.
msg103169 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2010-04-15 01:29
> Probably due to the fact that the peepholer 
> avoids constant folding when any exception happens.

Yes.  And that is a feature, not a bug.

It would better though if the keyboard interrupt was not swallowed.
msg103170 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2010-04-15 01:33
2010/4/14 Raymond Hettinger <report@bugs.python.org>:
>
> Raymond Hettinger <rhettinger@users.sourceforge.net> added the comment:
>
>> Probably due to the fact that the peepholer
>> avoids constant folding when any exception happens.
>
> Yes.  And that is a feature, not a bug.
>
> It would better though if the keyboard interrupt was not swallowed.

Agreed on both points.
msg114644 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2010-08-22 08:40
Fixed in r84256.
Don't think this needs to be backported.
History
Date User Action Args
2022-04-11 14:56:59adminsetgithub: 52650
2010-08-22 08:40:32rhettingersetstatus: open -> closed
resolution: fixed
messages: + msg114644

versions: + Python 3.2, - Python 2.6, Python 2.7
2010-04-15 01:33:01benjamin.petersonsetmessages: + msg103170
2010-04-15 01:29:57rhettingersetassignee: rhettinger

messages: + msg103169
nosy: + rhettinger
2010-04-15 01:24:47benjamin.petersonsetpriority: low
nosy: + benjamin.peterson
messages: + msg103167

2010-04-15 01:00:01ivankcreate