Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
55c206ab
Commit
55c206ab
authored
Sep 02, 2012
by
Zbigniew Jędrzejewski-Szmek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug with argparse.Parser.parse_args(*args)
parent
af3f3a7f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletion
+22
-1
Lib/argparse.py
Lib/argparse.py
+4
-1
Lib/test/test_argparse.py
Lib/test/test_argparse.py
+18
-0
No files found.
Lib/argparse.py
View file @
55c206ab
...
@@ -1709,9 +1709,12 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
...
@@ -1709,9 +1709,12 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
return
args
return
args
def
parse_known_args
(
self
,
args
=
None
,
namespace
=
None
):
def
parse_known_args
(
self
,
args
=
None
,
namespace
=
None
):
# args default to the system args
if
args
is
None
:
if
args
is
None
:
# args default to the system args
args
=
_sys
.
argv
[
1
:]
args
=
_sys
.
argv
[
1
:]
else
:
# make sure that args are mutable
args
=
list
(
args
)
# default Namespace built from parser defaults
# default Namespace built from parser defaults
if
namespace
is
None
:
if
namespace
is
None
:
...
...
Lib/test/test_argparse.py
View file @
55c206ab
...
@@ -4565,6 +4565,24 @@ class TestMessageContentError(TestCase):
...
@@ -4565,6 +4565,24 @@ class TestMessageContentError(TestCase):
class
TestParseKnownArgs
(
TestCase
):
class
TestParseKnownArgs
(
TestCase
):
def
test_arguments_tuple
(
self
):
parser
=
argparse
.
ArgumentParser
()
parser
.
parse_args
(())
def
test_arguments_list
(
self
):
parser
=
argparse
.
ArgumentParser
()
parser
.
parse_args
([])
def
test_arguments_tuple_positional
(
self
):
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'x'
)
parser
.
parse_args
((
'x'
,))
def
test_arguments_list_positional
(
self
):
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'x'
)
parser
.
parse_args
([
'x'
])
def
test_optionals
(
self
):
def
test_optionals
(
self
):
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'--foo'
)
parser
.
add_argument
(
'--foo'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment