Issue34084
Created on 2018-07-10 11:37 by xiang.zhang, last changed 2022-04-11 14:59 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 8242 | closed | vstinner, 2018-07-11 09:24 | |
| PR 8259 | closed | vstinner, 2018-07-11 21:22 | |
| PR 8262 | merged | serhiy.storchaka, 2018-07-12 07:15 | |
| PR 8423 | merged | miss-islington, 2018-07-23 20:41 | |
| PR 8424 | merged | miss-islington, 2018-07-23 20:42 | |
| Messages (13) | |||
|---|---|---|---|
| msg321381 - (view) | Author: Xiang Zhang (xiang.zhang) * ![]() |
Date: 2018-07-10 11:37 | |
While reviewing PR8222, I found `err_ret->text` is assigned a not malloced string, but it will finally get freed in `err_input`. |
|||
| msg321382 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2018-07-10 11:41 | |
I expected it should be easy to reproduce a crash, but I failed to find an example. |
|||
| msg321418 - (view) | Author: STINNER Victor (vstinner) * ![]() |
Date: 2018-07-11 09:24 | |
This issue is related to bpo-34080. |
|||
| msg321420 - (view) | Author: STINNER Victor (vstinner) * ![]() |
Date: 2018-07-11 09:33 | |
> 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 |
|||
| msg321421 - (view) | Author: STINNER Victor (vstinner) * ![]() |
Date: 2018-07-11 09:43 | |
Oh, this easter egg is tested by Lib/test/test_flufl.py. |
|||
| msg321425 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2018-07-11 09:48 | |
Could you add a test in test_flufl.py that will fail with not patched code? This issue and issue34080 look unrelated to me. They can be fixed independently. |
|||
| msg321429 - (view) | Author: STINNER Victor (vstinner) * ![]() |
Date: 2018-07-11 10:13 | |
> Could you add a test in test_flufl.py that will fail with not patched code?
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):
err_ret->text = "with Barry as BDFL, use '<>' "
"instead of '!='";
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*:
err_ret->text = "with Barry as BDFL, use '<>' "
"instead of '!='";
> This issue and issue34080 look unrelated to me. They can be fixed independently.
In practice, both issues are related and it seems easier to me to fix them both at the same time ;-)
|
|||
| msg321487 - (view) | Author: Barry A. Warsaw (barry) * ![]() |
Date: 2018-07-11 17:05 | |
AFAICT, that future only works in the REPL. |
|||
| msg321522 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2018-07-12 07:22 | |
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. |
|||
| msg321525 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2018-07-12 08:03 | |
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. |
|||
| msg322256 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2018-07-23 20:41 | |
New changeset aba24ff3601ddc86b85e01880a8be596fb799287 by Serhiy Storchaka in branch 'master': bpo-34084: Fix setting an error message for the "Barry as BDFL" easter egg. (GH-8262) https://github.com/python/cpython/commit/aba24ff3601ddc86b85e01880a8be596fb799287 |
|||
| msg322270 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2018-07-23 22:41 | |
New changeset 220afffb683af1ba9e04c37535cfaa41348e9ebb 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) https://github.com/python/cpython/commit/220afffb683af1ba9e04c37535cfaa41348e9ebb |
|||
| msg322271 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2018-07-23 22:41 | |
New changeset ec729d5407adafaae566136448ef0551bb29c070 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) https://github.com/python/cpython/commit/ec729d5407adafaae566136448ef0551bb29c070 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:03 | admin | set | github: 78265 |
| 2018-07-24 08:09:32 | serhiy.storchaka | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2018-07-23 22:41:51 | serhiy.storchaka | set | messages: + msg322271 |
| 2018-07-23 22:41:31 | serhiy.storchaka | set | messages: + msg322270 |
| 2018-07-23 20:42:20 | miss-islington | set | pull_requests: + pull_request7950 |
| 2018-07-23 20:41:20 | miss-islington | set | pull_requests: + pull_request7949 |
| 2018-07-23 20:41:13 | serhiy.storchaka | set | messages: + msg322256 |
| 2018-07-12 08:03:34 | serhiy.storchaka | set | messages: + msg321525 |
| 2018-07-12 07:22:31 | serhiy.storchaka | set | messages: + msg321522 |
| 2018-07-12 07:15:13 | serhiy.storchaka | set | pull_requests: + pull_request7795 |
| 2018-07-11 21:22:04 | vstinner | set | pull_requests: + pull_request7792 |
| 2018-07-11 17:05:29 | barry | set | messages: + msg321487 |
| 2018-07-11 10:13:52 | vstinner | set | messages: + msg321429 |
| 2018-07-11 09:48:56 | serhiy.storchaka | set | messages: + msg321425 |
| 2018-07-11 09:43:55 | vstinner | set | messages: + msg321421 |
| 2018-07-11 09:33:44 | vstinner | set | messages: + msg321420 |
| 2018-07-11 09:24:54 | vstinner | set | messages: + msg321418 |
| 2018-07-11 09:24:29 | vstinner | set | keywords:
+ patch stage: patch review pull_requests: + pull_request7775 |
| 2018-07-11 01:59:39 | xiang.zhang | set | nosy:
+ vstinner |
| 2018-07-10 11:41:30 | serhiy.storchaka | set | nosy:
+ barry |
| 2018-07-10 11:41:14 | serhiy.storchaka | set | messages: + msg321382 |
| 2018-07-10 11:38:12 | xiang.zhang | set | title: possible free statically allocated string -> possible free statically allocated string in compiler when easter egg on |
| 2018-07-10 11:37:01 | xiang.zhang | create | |
