classification
Title: refleak on SyntaxError in function parameter annotation
Type: Stage: resolved
Components: Interpreter Core Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, ncoghlan, python-dev, yselivanov
Priority: high Keywords: patch

Created on 2015-07-22 22:09 by yselivanov, last changed 2015-07-23 06:15 by yselivanov. This issue is now closed.

Files
File name Uploaded Description Edit
compile.patch yselivanov, 2015-07-22 22:09 review
compile2.patch yselivanov, 2015-07-23 06:05 review
Messages (6)
msg247153 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2015-07-22 22:09
A simple way of reproducing the issue is to try to compile the following piece of code with refleaks check mode on:

   def foo(a:(yield)): pass

Since '(yield)' expression is outside of a function, it will trigger a SyntaxError.

There is a subtle bug in compile.c though, specifically in compiler_visit_argannotation method; it should return -1 in case of error, but the VISIT macro it uses returns 0 on errors.

Attached patch uses 'compiler_visit_expr' directly returning correct error code.
msg247164 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2015-07-23 04:03
I would prefer that compiler_visit_argannotation[s] be fixed to use the normal calling convention.
msg247171 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2015-07-23 06:05
> I would prefer that compiler_visit_argannotation[s] be fixed to use the normal calling convention.

Agree, new patch attached.
msg247172 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2015-07-23 06:08
Seems fine to me.
msg247173 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-07-23 06:14
New changeset b5a7f529b4ac by Yury Selivanov in branch '3.5':
Issue #24687: Plug refleak on SyntaxError in function parameters annotations.
https://hg.python.org/cpython/rev/b5a7f529b4ac

New changeset cf91ae981afd by Yury Selivanov in branch 'default':
Merge 3.5 (Issue #24687)
https://hg.python.org/cpython/rev/cf91ae981afd
msg247174 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2015-07-23 06:15
Thanks, Benjamin!
History
Date User Action Args
2015-07-23 06:15:17yselivanovsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2015-07-23 06:15:04yselivanovsetmessages: + msg247174
2015-07-23 06:14:39python-devsetnosy: + python-dev
messages: + msg247173
2015-07-23 06:08:25benjamin.petersonsetmessages: + msg247172
2015-07-23 06:05:54yselivanovsetfiles: + compile2.patch

messages: + msg247171
2015-07-23 04:03:35benjamin.petersonsetmessages: + msg247164
2015-07-22 22:09:17yselivanovcreate