Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
1ca45a52
Kaydet (Commit)
1ca45a52
authored
Kas 01, 2010
tarafından
Steven Bethard
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix bug 9352 where characters were being lost in parsing some short options
üst
65095990
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
7 deletions
+31
-7
argparse.py
Lib/argparse.py
+7
-7
test_argparse.py
Lib/test/test_argparse.py
+24
-0
No files found.
Lib/argparse.py
Dosyayı görüntüle @
1ca45a52
...
...
@@ -1794,13 +1794,13 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
chars
=
self
.
prefix_chars
if
arg_count
==
0
and
option_string
[
1
]
not
in
chars
:
action_tuples
.
append
((
action
,
[],
option_string
))
for
char
in
self
.
prefix_chars
:
option_string
=
char
+
explicit_arg
[
0
]
explicit_arg
=
explicit_arg
[
1
:]
or
None
optionals_map
=
self
.
_option_string_actions
if
option_string
in
optionals_map
:
action
=
optionals_map
[
option_string
]
break
char
=
option_string
[
0
]
option_string
=
char
+
explicit_arg
[
0
]
new_
explicit_arg
=
explicit_arg
[
1
:]
or
None
optionals_map
=
self
.
_option_string_actions
if
option_string
in
optionals_map
:
action
=
optionals_map
[
option_string
]
explicit_arg
=
new_explicit_arg
else
:
msg
=
_
(
'ignored explicit argument
%
r'
)
raise
ArgumentError
(
action
,
msg
%
explicit_arg
)
...
...
Lib/test/test_argparse.py
Dosyayı görüntüle @
1ca45a52
...
...
@@ -465,6 +465,30 @@ class TestOptionalsAlternatePrefixCharsAddedHelp(ParserTestCase):
(
'/ba +f'
,
NS
(
f
=
True
,
bar
=
None
,
baz
=
42
))
]
class
TestOptionalsAlternatePrefixCharsMultipleShortArgs
(
ParserTestCase
):
"""Verify that Optionals must be called with their defined prefixes"""
parser_signature
=
Sig
(
prefix_chars
=
'+-'
,
add_help
=
False
)
argument_signatures
=
[
Sig
(
'-x'
,
action
=
'store_true'
),
Sig
(
'+y'
,
action
=
'store_true'
),
Sig
(
'+z'
,
action
=
'store_true'
),
]
failures
=
[
'-w'
,
'-xyz'
,
'+x'
,
'-y'
,
'+xyz'
,
]
successes
=
[
(
''
,
NS
(
x
=
False
,
y
=
False
,
z
=
False
)),
(
'-x'
,
NS
(
x
=
True
,
y
=
False
,
z
=
False
)),
(
'+y -x'
,
NS
(
x
=
True
,
y
=
True
,
z
=
False
)),
(
'+yz -x'
,
NS
(
x
=
True
,
y
=
True
,
z
=
True
)),
]
class
TestOptionalsShortLong
(
ParserTestCase
):
"""Test a combination of single- and double-dash option strings"""
...
...
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