You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
possible free statically allocated string in compiler when easter egg on #78265
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" :-(
PR 8262 fixes the intended setting of error message for the "Barry as BDFL" easter egg.
>>> from__future__import barry_as_FLUFL
>>> 1!=2
File "<stdin>", line 1
1 != 2
^
SyntaxError: with Barry as BDFL, use '<>' instead of '!='
But there is other problem. As was exposed in the private communication with Victor and Barry, this easter egg works only in REPL (or if explicitly pass __future__.CO_FUTURE_BARRY_AS_BDFL to compile()). I'll try to fix this too.
The problem is that 'from __future__ import' is parsed after converting the sources to the AST. But this flag affects the behavior of the tokenizer, before an AST is created.
New changeset aba24ff by Serhiy Storchaka in branch 'master': bpo-34084: Fix setting an error message for the "Barry as BDFL" easter egg. (GH-8262) aba24ff
New changeset 220afff by Serhiy Storchaka (Miss Islington (bot)) in branch '3.7': bpo-34084: Fix setting an error message for the "Barry as BDFL" easter egg. (GH-8262) (GH-8423) 220afff
New changeset ec729d5 by Serhiy Storchaka (Miss Islington (bot)) in branch '3.6': bpo-34084: Fix setting an error message for the "Barry as BDFL" easter egg. (GH-8262) (GH-8424) ec729d5
Activity
zhangyangyu commentedon Jul 10, 2018
While reviewing PR8222, I found
err_ret->textis assigned a not malloced string, but it will finally get freed inerr_input.[-]possible free statically allocated string[/-][+]possible free statically allocated string in compiler when easter egg on[/+]serhiy-storchaka commentedon Jul 10, 2018
I expected it should be easy to reproduce a crash, but I failed to find an example.
vstinner commentedon Jul 11, 2018
This issue is related to bpo-34080.
vstinner commentedon Jul 11, 2018
I don't understand how parsetok.c is supposed to handle "from __future__ import barry_as_FLUFL":
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:
---
Maybe we need a test for the easter egg. Or maybe we should remove it? :-p
vstinner commentedon Jul 11, 2018
Oh, this easter egg is tested by Lib/test/test_flufl.py.
serhiy-storchaka commentedon Jul 11, 2018
Could you add a test in test_flufl.py that will fail with not patched code?
This issue and bpo-34080 look unrelated to me. They can be fixed independently.
vstinner commentedon Jul 11, 2018
It seems like PyObject_FREE() is never called with the static string "with Barry as BDFL, use '<>' instead of '!='".
When parsetok() goes to code path (1):
Later, it goes to code path (2) as well:
Hum, I modified my PR to removed *dead code*:
In practice, both issues are related and it seems easier to me to fix them both at the same time ;-)
warsaw commentedon Jul 11, 2018
AFAICT, that future only works in the REPL.
serhiy-storchaka commentedon Jul 12, 2018
PR 8262 fixes the intended setting of error message for the "Barry as BDFL" easter egg.
But there is other problem. As was exposed in the private communication with Victor and Barry, this easter egg works only in REPL (or if explicitly pass __future__.CO_FUTURE_BARRY_AS_BDFL to compile()). I'll try to fix this too.
serhiy-storchaka commentedon Jul 12, 2018
The problem is that 'from __future__ import' is parsed after converting the sources to the AST. But this flag affects the behavior of the tokenizer, before an AST is created.
serhiy-storchaka commentedon Jul 23, 2018
New changeset aba24ff by Serhiy Storchaka in branch 'master':
bpo-34084: Fix setting an error message for the "Barry as BDFL" easter egg. (GH-8262)
aba24ff
serhiy-storchaka commentedon Jul 23, 2018
New changeset 220afff by Serhiy Storchaka (Miss Islington (bot)) in branch '3.7':
bpo-34084: Fix setting an error message for the "Barry as BDFL" easter egg. (GH-8262) (GH-8423)
220afff
serhiy-storchaka commentedon Jul 23, 2018
New changeset ec729d5 by Serhiy Storchaka (Miss Islington (bot)) in branch '3.6':
bpo-34084: Fix setting an error message for the "Barry as BDFL" easter egg. (GH-8262) (GH-8424)
ec729d5