New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
possible free statically allocated string in compiler when easter egg on #78265
Comments
While reviewing PR8222, I found |
I expected it should be easy to reproduce a crash, but I failed to find an example. |
This issue is related to bpo-34080. |
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: 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 |
Oh, this easter egg is tested by Lib/test/test_flufl.py. |
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. |
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: if (tok->buf != NULL) {
...
err_ret->text = (char *) PyObject_MALLOC(len + 1); 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 ;-) |
AFAICT, that future only works in the REPL. |
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. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: