yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #89403
[Bug 1982426] Re: Python3.11: "glance-manage" crashes
Reviewed: https://review.opendev.org/c/openstack/glance/+/850589
Committed: https://opendev.org/openstack/glance/commit/76abb227addf1ae44813527084d1ceb7f36af606
Submitter: "Zuul (22348)"
Branch: master
commit 76abb227addf1ae44813527084d1ceb7f36af606
Author: Cyril Roelandt <cyril@xxxxxxxxxx>
Date: Thu Jul 21 00:16:20 2022 +0200
glance-manage: fix crash under Python3.11
In Python3.11, the argparse module became stricter. While the following
code was fine in previous versions, it will now raise an
argparse.ArgumentError because we added the same subparser twice:
import argparse
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(title='Commands')
subparsers.add_parser('foo')
subparsers.add_parser('foo')
subparsers.add_parser('bar')
parser.parse_args()
This mistake was silently ignore in Python3.10, which explains why this
was never an issue for glance-manage.
Closes-Bug: #1982426
Change-Id: I3a88ab5d2e67a1553f03b0b8ba44efbef976ffb0
** Changed in: glance
Status: In Progress => Fix Released
--
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to Glance.
https://bugs.launchpad.net/bugs/1982426
Title:
Python3.11: "glance-manage" crashes
Status in Glance:
Fix Released
Bug description:
Removing a lot of the output since Launchpad is not going to format it
properly anyway:
$ glance-manage -h
...
argparse.ArgumentError: argument command: conflicting subparser: db_version
This happens because the argparse module became stricter in Python3.11 and prevents us from adding the same subparser twice:
$ cat parser.py
import argparse
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(title='Commands')
subparsers.add_parser('foo')
subparsers.add_parser('foo')
subparsers.add_parser('bar')
parser.parse_args()
$ python3.10 parser.py
$ python3.11 parser.py
Traceback (most recent call last):
File "/tmp/parser.py", line 6, in <module>
subparsers.add_parser('foo')
File "/usr/lib/python3.11/argparse.py", line 1197, in add_parser
raise ArgumentError(self, _('conflicting subparser: %s') % name)
argparse.ArgumentError: argument {foo}: conflicting subparser: foo
$
To manage notifications about this bug go to:
https://bugs.launchpad.net/glance/+bug/1982426/+subscriptions
References