STINNER Victor added the comment:
"""
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
---
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue26204>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com