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: Error on importing getopt
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.10
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: eric.smith, lemburg, rizqirizqi23, serhiy.storchaka
Priority: normal Keywords:

Created on 2021-11-03 06:00 by rizqirizqi23, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
OnPaste.20211103-125049.png rizqirizqi23, 2021-11-03 06:00 Bug
OnPaste.20211103-202914.png rizqirizqi23, 2021-11-03 13:37
Messages (11)
msg405582 - (view) Author: Mgs M Rizqi Fadhlurrahman (rizqirizqi23) Date: 2021-11-03 06:00
It looks like there is a breaking change related to python 3.10.0 implementation that impacted getopt package.

https://docs.python.org/3/library/getopt.html
https://github.com/python/cpython/blob/3.10/Lib/getopt.py

Steps to reproduce:
1. Run python 3.10.0
2. Type `import getopt`
3. The error shows up

I already tried python 3.9.7 and it's still working as expected.
msg405590 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-11-03 09:09
What error?
msg405599 - (view) Author: Mgs M Rizqi Fadhlurrahman (rizqirizqi23) Date: 2021-11-03 09:45
Screenshot attached

https://bugs.python.org/file50422/OnPaste.20211103-125049.png
msg405600 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-11-03 10:19
Could you please provide an output as a text?
msg405602 - (view) Author: Mgs M Rizqi Fadhlurrahman (rizqirizqi23) Date: 2021-11-03 10:51
Here:

```
Python 3.10.0 (default, Oct 30 2021, 15:16:25) [GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import getopt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mgsrizqi/.pyenv/versions/3.10.0/lib/python3.10/getopt.py", line 4
    function (including the special meanings of arguments of the form `-'
                                                                        ^
SyntaxError: unterminated string literal (detected at line 4)
>>>
```
msg405604 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2021-11-03 11:14
Could you please provide more details regarding the OS, whether you compiled
Python yourself and the env settings you used ?

Thanks,
-- 
Marc-Andre Lemburg
eGenix.com
msg405605 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-11-03 11:16
It looks strange. The line containing "function (including the special meanings of arguments of the form `-'" is a part of a multiline string literal, so there should not be such error. And it is line 4, not line 3 as in your traceback.
msg405611 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2021-11-03 11:55
I'm guessing the first line of getopt.py got deleted somehow.

@rizqirizqi23: what do the first 10 lines of /home/mgsrizqi/.pyenv/versions/3.10.0/lib/python3.10/getopt.py look like?

How did you install python?
msg405614 - (view) Author: Mgs M Rizqi Fadhlurrahman (rizqirizqi23) Date: 2021-11-03 13:37
@eric.smith Wow you're right! Somehow the """ got deleted. (screenshot attached)

It can run normally now after I added the """ back.

More details:
I'm using Ubuntu 18.04.2.
I installed python 3.10.0 using pyenv by running: `pyenv install 3.10.0`
msg405616 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2021-11-03 13:40
I'm going to close this, since I don't think it's a bug in python, but rather in the user's setup.
msg405617 - (view) Author: Mgs M Rizqi Fadhlurrahman (rizqirizqi23) Date: 2021-11-03 13:44
OK, thank you for the answers. Sorry for the false alarm.
History
Date User Action Args
2022-04-11 14:59:52adminsetgithub: 89861
2021-11-03 13:44:36rizqirizqi23setmessages: + msg405617
2021-11-03 13:40:30eric.smithsetstatus: open -> closed
type: crash -> behavior
messages: + msg405616

resolution: works for me
stage: resolved
2021-11-03 13:37:59rizqirizqi23setfiles: + OnPaste.20211103-202914.png

messages: + msg405614
2021-11-03 11:55:51eric.smithsetnosy: + eric.smith
messages: + msg405611
2021-11-03 11:16:59serhiy.storchakasetmessages: + msg405605
2021-11-03 11:14:18lemburgsetnosy: + lemburg
messages: + msg405604
2021-11-03 10:51:05rizqirizqi23setmessages: + msg405602
2021-11-03 10:19:17serhiy.storchakasetmessages: + msg405600
2021-11-03 09:45:34rizqirizqi23setmessages: + msg405599
2021-11-03 09:09:11serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg405590
2021-11-03 06:00:18rizqirizqi23create