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 fails on one letter strings.
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: James.Lu, r.david.murray, vstinner
Priority: normal Keywords:

Created on 2013-07-17 15:26 by James.Lu, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (6)
msg193233 - (view) Author: James Lu (James.Lu) * Date: 2013-07-17 15:26
dis.dis fails on one letter strings.
dis.dis("t")
Traceback (most recent call last):
  File "<pyshell#26>", line 1, in <module>
    dis.dis("t")
  File "C:\python 25\lib\dis.py", line 44, in dis
    disassemble_string(x)
  File "C:\python 25\lib\dis.py", line 111, in disassemble_string
    labels = findlabels(code)
  File "C:\python 25\lib\dis.py", line 165, in findlabels
    oparg = ord(code[i]) + ord(code[i+1])*256
IndexError: string index out of range
msg193238 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-07-17 16:00
NB: This is only a bug in python2.
msg193248 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-07-17 20:29
I don't understand why do you consider IndexError as an issue. Do you expect another exception? b"t" is not a valid bytecode.
msg193254 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-07-17 21:30
Haypo: it gives a result on python3.
msg193255 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-07-17 21:35
> Haypo: it gives a result on python3.

It is a new feature of Python 3.2: see issue #6507.

New features are no more added to Python 2, so you now have a good reason to upgrade to Python 3 ;-)
msg193256 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-07-17 21:55
Ah, yes, I see that you are correct.
History
Date User Action Args
2022-04-11 14:57:48adminsetgithub: 62682
2013-07-17 21:55:37r.david.murraysetstatus: open -> closed
type: crash -> enhancement
messages: + msg193256

resolution: out of date
stage: resolved
2013-07-17 21:35:41vstinnersetmessages: + msg193255
2013-07-17 21:30:25r.david.murraysetmessages: + msg193254
2013-07-17 20:29:10vstinnersetnosy: + vstinner
messages: + msg193248
2013-07-17 16:00:22r.david.murraysetnosy: + r.david.murray
messages: + msg193238
2013-07-17 15:26:08James.Lucreate