[issue34084] possible free statically allocated string in compiler when easter egg on
STINNER Victor
report at bugs.python.org
Wed Jul 11 05:33:45 EDT 2018
STINNER Victor <vstinner at redhat.com> added the comment:
> I expected it should be easy to reproduce a crash, but I failed to find an example.
I don't understand how parsetok.c is supposed to handle "from __future__ import barry_as_FLUFL":
* Parser/parsetok.c tests (ps->p_flags & CO_FUTURE_BARRY_AS_BDFL)
* Python/future.c uses "if (strcmp(feature, FUTURE_BARRY_AS_BDFL) == 0) { ff->ff_features |= CO_FUTURE_BARRY_AS_BDFL; }"
* Python/pythonrun.c: PARSER_FLAGS() copies CO_FUTURE_BARRY_AS_BDFL flag as PyPARSE_BARRY_AS_BDFL
The only way to use "<>" operator seems to pass explicitly CO_FUTURE_BARRY_AS_BDFL flag to compile() flags, which is not the convenient way to use "from __future__ import barry_as_FLUFL" :-(
Code:
---
import inspect
CO_FUTURE_BARRY_AS_BDFL = 0x40000
flags = CO_FUTURE_BARRY_AS_BDFL
code = "print(1 <> 2)"
try:
compile(code, "filename", "exec", flags=0)
except SyntaxError:
print("ok")
else:
raise Exception("SyntaxError expected")
compile(code, "filename", "exec", flags=flags)
print("ok")
---
Maybe we need a test for the easter egg. Or maybe we should remove it? :-p
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34084>
_______________________________________
More information about the Python-bugs-list
mailing list