Message258977
"""
Will the following code compile OK? What will it compile to?
if 1:
42
"""
compile OK: what do you mean? This code doesn't make any sense to me :-)
Currently text strings statements are ignored:
---
>>> def f():
... if 1:
... "abc"
...
>>> import dis
>>> dis.dis(f)
3 0 LOAD_CONST 0 (None)
3 RETURN_VALUE
---
But byte strings emit a LOAD_CONST+POP_TOP:
---
>>> def g():
... if 1:
... b'bytes'
...
>>> dis.dis(g)
3 0 LOAD_CONST 1 (b'bytes')
3 POP_TOP
4 LOAD_CONST 0 (None)
7 RETURN_VALUE
---
With my patch, all constants statements will be ignored. Example with my patch:
---
>>> def h():
... if 1:
... b'bytes'
...
>>> import dis; dis.dis(h)
3 0 LOAD_CONST 0 (None)
3 RETURN_VALUE
--- |
|
Date |
User |
Action |
Args |
2016-01-26 22:05:19 | vstinner | set | recipients:
+ vstinner, serhiy.storchaka, yselivanov |
2016-01-26 22:05:19 | vstinner | set | messageid: <1453845919.69.0.439646073362.issue26204@psf.upfronthosting.co.za> |
2016-01-26 22:05:19 | vstinner | link | issue26204 messages |
2016-01-26 22:05:19 | vstinner | create | |
|