[Python-checkins] (no subject)
Rémi Lapeyre
webhook-mailer at python.org
Fri Jun 5 18:00:49 EDT 2020
To: python-checkins at python.org
Subject: bpo-40862: Raise TypeError when const is given to
argparse.BooleanOptionalAction (GH-20623)
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
https://github.com/python/cpython/commit/b084d1b97e369293d2d2bc0791e2135822c9=
23a8
commit: b084d1b97e369293d2d2bc0791e2135822c923a8
branch: master
author: R=C3=A9mi Lapeyre <remi.lapeyre at lenstra.fr>
committer: GitHub <noreply at github.com>
date: 2020年06月05日T15:00:42-07:00
summary:
bpo-40862: Raise TypeError when const is given to argparse.BooleanOptionalAct=
ion (GH-20623)
files:
M Lib/argparse.py
M Lib/test/test_argparse.py
diff --git a/Lib/argparse.py b/Lib/argparse.py
index 2677ef63e9e54..2fb1da59f942c 100644
--- a/Lib/argparse.py
+++ b/Lib/argparse.py
@@ -857,7 +857,6 @@ class BooleanOptionalAction(Action):
def __init__(self,
option_strings,
dest,
- const=3DNone,
default=3DNone,
type=3DNone,
choices=3DNone,
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py
index e82a0c39c21a8..22cae626ccc29 100644
--- a/Lib/test/test_argparse.py
+++ b/Lib/test/test_argparse.py
@@ -700,6 +700,14 @@ class TestBooleanOptionalAction(ParserTestCase):
('--no-foo --foo', NS(foo=3DTrue)),
]
=20
+ def test_const(self):
+ # See bpo-40862
+ parser =3D argparse.ArgumentParser()
+ with self.assertRaises(TypeError) as cm:
+ parser.add_argument('--foo', const=3DTrue, action=3Dargparse.Boo=
leanOptionalAction)
+
+ self.assertIn("got an unexpected keyword argument 'const'", str(cm.e=
xception))
+
class TestBooleanOptionalActionRequired(ParserTestCase):
"""Tests BooleanOptionalAction required"""
=20
More information about the Python-checkins
mailing list