This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: bad input crashes py_compile library
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.10, Python 3.9, Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Gregory Shevchenko, Kaoru Esashika, berker.peksag, hubide, miss-islington, nanjekyejoannah, pablogsal
Priority: normal Keywords: easy, patch

Created on 2019-11-07 06:53 by Kaoru Esashika, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 17134 merged Gregory Shevchenko, 2019-11-12 22:02
PR 17725 merged miss-islington, 2019-12-28 02:53
PR 21617 merged berker.peksag, 2020-07-25 20:22
PR 21618 merged miss-islington, 2020-07-25 20:44
Messages (9)
msg356173 - (view) Author: Kaoru Esashika (Kaoru Esashika) Date: 2019-11-07 06:53
How to reproduction:
Step 1: make bad source code
Step 2: run "python -m py_compile bad_source_code.py"
Step 3: errors printed

It seems that this problem is introduced at issue 22640 (commit https://github.com/python/cpython/commit/2e33ecd7c9b0cac3efc6fcbdd4547fd086b4e2d1)
and it have not fixed yet.

variable 'quiet' is not defined in main function as far as I can see.

```
Traceback (most recent call last):
  File "c:\users\<USERNAME>\.scoop\apps\python\3.8.0\Lib\py_compile.py", line 144, in compile
    code = loader.source_to_code(source_bytes, dfile or file,
  File "<frozen importlib._bootstrap_external>", line 846, in source_to_code
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "c:/Users/<USERNAME>/AppData/Local/Temp/flycheckrIYLj4/test.py", line 25
    def calc_entropy(self):
    ^
IndentationError: expected an indented block

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\<USERNAME>\.scoop\apps\python\3.8.0\Lib\py_compile.py", line 209, in main
    compile(filename, doraise=True)
  File "c:\users\<USERNAME>\.scoop\apps\python\3.8.0\Lib\py_compile.py", line 150, in compile
    raise py_exc
__main__.PyCompileError: Sorry: IndentationError: expected an indented block (c:/Users/<USERNAME>/AppData/Local/Temp/flycheckrIYLj4/test.py, line 25)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\<USERNAME>\.scoop\apps\python\3.8.0\Lib\runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\<USERNAME>\.scoop\apps\python\3.8.0\Lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "c:\users\<USERNAME>\.scoop\apps\python\3.8.0\Lib\py_compile.py", line 218, in <module>
    sys.exit(main())
  File "c:\users\<USERNAME>\.scoop\apps\python\3.8.0\Lib\py_compile.py", line 213, in main
    if quiet < 2:
NameError: name 'quiet' is not defined

```
msg358925 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2019-12-28 02:53
New changeset 98f0f04b5016e63561d313a3446b7b58f2c12611 by Pablo Galindo (Batuhan Taşkaya) in branch 'master':
bpo-38731: Fix function signature of quiet in docs (GH-17719)
https://github.com/python/cpython/commit/98f0f04b5016e63561d313a3446b7b58f2c12611
msg358927 - (view) Author: miss-islington (miss-islington) Date: 2019-12-28 02:58
New changeset 04c1efe5acc89b6f3f2c208604a1c35641e8a380 by Miss Islington (bot) in branch '3.8':
bpo-38731: Fix function signature of quiet in docs (GH-17719)
https://github.com/python/cpython/commit/04c1efe5acc89b6f3f2c208604a1c35641e8a380
msg372907 - (view) Author: Hubert Pineault (hubide) Date: 2020-07-03 06:24
The bug is still there in python 3.8.4rc1
It has nothing to do with the doc.

As pointed by Kaoru, it is introduced in line 200 of commit 2e33ecd7c9b0cac3efc6fcbdd4547fd086b4e2d1

see this comment, also by Kaoru:
https://github.com/python/cpython/commit/2e33ecd7c9b0cac3efc6fcbdd4547fd086b4e2d1#r35842880
msg372933 - (view) Author: Joannah Nanjekye (nanjekyejoannah) * (Python committer) Date: 2020-07-03 14:00
The regression is tracked here: https://bugs.python.org/issue40456

And a PR is under review here: https://github.com/python/cpython/pull/17134

Also, this issue is a duplicate to this: https://bugs.python.org/issue40456

One of these should be closed.
msg372953 - (view) Author: Hubert Pineault (hubide) Date: 2020-07-03 19:33
Thanks Joannah, I confirm this is a duplicate of https://bugs.python.org/issue40456

The issue is better tracked in 40456, so you can close here.
msg374276 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2020-07-25 19:58
New changeset daff39070e7ea71b0ba49d9150ac7a210a125682 by Gregory Schevchenko in branch 'master':
bpo-38731: Add --quiet option to py_compile CLI (GH-17134)
https://github.com/python/cpython/commit/daff39070e7ea71b0ba49d9150ac7a210a125682
msg374277 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2020-07-25 20:43
New changeset 2024d7aca100c3faa9c6730aba3de5f0528750be by Berker Peksag in branch '3.9':
bpo-38731: Fix NameError in command-line interface of py_compile (GH-21617)
https://github.com/python/cpython/commit/2024d7aca100c3faa9c6730aba3de5f0528750be
msg374278 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2020-07-25 21:03
New changeset 949cf93f8ee27c37650483458f0aa3e295011ef6 by Miss Islington (bot) in branch '3.8':
bpo-38731: Fix NameError in command-line interface of py_compile (GH-21617)
https://github.com/python/cpython/commit/949cf93f8ee27c37650483458f0aa3e295011ef6
History
Date User Action Args
2022-04-11 14:59:22adminsetgithub: 82912
2020-07-25 21:05:08berker.peksagsetstatus: open -> closed
stage: patch review -> resolved
resolution: fixed
versions: + Python 3.9, Python 3.10
2020-07-25 21:03:53berker.peksagsetmessages: + msg374278
2020-07-25 20:44:03miss-islingtonsetpull_requests: + pull_request20760
2020-07-25 20:43:52berker.peksagsetmessages: + msg374277
2020-07-25 20:22:11berker.peksagsetpull_requests: + pull_request20759
2020-07-25 19:58:56berker.peksagsetmessages: + msg374276
2020-07-25 19:17:47berker.peksaglinkissue40456 superseder
2020-07-03 19:33:32hubidesetmessages: + msg372953
2020-07-03 14:00:22nanjekyejoannahsetmessages: + msg372933
2020-07-03 06:24:07hubidesetnosy: + hubide

messages: + msg372907
versions: - Python 3.9
2020-03-22 12:15:50xtreaklinkissue40037 superseder
2020-02-24 21:23:14SilentGhostlinkissue39743 superseder
2019-12-28 02:58:52miss-islingtonsetnosy: + miss-islington
messages: + msg358927
2019-12-28 02:53:14miss-islingtonsetpull_requests: + pull_request17169
2019-12-28 02:53:07pablogsalsetnosy: + pablogsal
messages: + msg358925
2019-12-27 22:06:55BTaskayasetpull_requests: - pull_request17163
2019-12-27 21:40:45BTaskayasetpull_requests: + pull_request17163
2019-11-12 22:02:42Gregory Shevchenkosetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request16644
2019-11-12 17:09:11serhiy.storchakasetkeywords: + easy
2019-11-12 14:17:51Gregory Shevchenkosetnosy: + Gregory Shevchenko
2019-11-07 08:54:31xtreaksetnosy: + nanjekyejoannah
2019-11-07 08:18:15berker.peksagsetnosy: + berker.peksag
stage: needs patch
type: crash -> behavior

versions: + Python 3.9
2019-11-07 06:53:38Kaoru Esashikacreate