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
50dc1a23
Commit
50dc1a23
authored
Mar 21, 2011
by
Éric Araujo
Browse files
Options
Browse Files
Download
Plain Diff
Branch merge
parents
f1a9d82e
eda5583b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
9 deletions
+13
-9
Doc/c-api/import.rst
Doc/c-api/import.rst
+2
-2
Lib/getopt.py
Lib/getopt.py
+8
-7
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Doc/c-api/import.rst
View file @
50dc1a23
...
@@ -112,7 +112,7 @@ Importing Modules
...
@@ -112,7 +112,7 @@ Importing Modules
.. c:function:: PyObject* PyImport_AddModule(const char *name)
.. c:function:: PyObject* PyImport_AddModule(const char *name)
Similar to :c:func:`PyImport_AddModuleObject`, but the name is a
n
UTF-8
Similar to :c:func:`PyImport_AddModuleObject`, but the name is a UTF-8
encoded string instead of a Unicode object.
encoded string instead of a Unicode object.
...
@@ -237,7 +237,7 @@ Importing Modules
...
@@ -237,7 +237,7 @@ Importing Modules
.. c:function:: int PyImport_ImportFrozenModule(char *name)
.. c:function:: int PyImport_ImportFrozenModule(char *name)
Similar to :c:func:`PyImport_ImportFrozenModuleObject`, but the name is a
n
Similar to :c:func:`PyImport_ImportFrozenModuleObject`, but the name is a
UTF-8 encoded string instead of a Unicode object.
UTF-8 encoded string instead of a Unicode object.
...
...
Lib/getopt.py
View file @
50dc1a23
...
@@ -19,7 +19,7 @@ option involved with the exception.
...
@@ -19,7 +19,7 @@ option involved with the exception.
# Gerrit Holl <gerrit@nl.linux.org> moved the string-based exceptions
# Gerrit Holl <gerrit@nl.linux.org> moved the string-based exceptions
# to class-based exceptions.
# to class-based exceptions.
#
#
# Peter
Ã
strand <astrand@lysator.liu.se> added gnu_getopt().
# Peter
Å
strand <astrand@lysator.liu.se> added gnu_getopt().
#
#
# TODO for gnu_getopt():
# TODO for gnu_getopt():
#
#
...
@@ -34,6 +34,7 @@ option involved with the exception.
...
@@ -34,6 +34,7 @@ option involved with the exception.
__all__
=
[
"GetoptError"
,
"error"
,
"getopt"
,
"gnu_getopt"
]
__all__
=
[
"GetoptError"
,
"error"
,
"getopt"
,
"gnu_getopt"
]
import
os
import
os
from
gettext
import
gettext
as
_
class
GetoptError
(
Exception
):
class
GetoptError
(
Exception
):
opt
=
''
opt
=
''
...
@@ -153,10 +154,10 @@ def do_longs(opts, opt, longopts, args):
...
@@ -153,10 +154,10 @@ def do_longs(opts, opt, longopts, args):
if
has_arg
:
if
has_arg
:
if
optarg
is
None
:
if
optarg
is
None
:
if
not
args
:
if
not
args
:
raise
GetoptError
(
'option --%s requires argument'
%
opt
,
opt
)
raise
GetoptError
(
_
(
'option --%s requires argument'
)
%
opt
,
opt
)
optarg
,
args
=
args
[
0
],
args
[
1
:]
optarg
,
args
=
args
[
0
],
args
[
1
:]
elif
optarg
is
not
None
:
elif
optarg
is
not
None
:
raise
GetoptError
(
'option --%s must not have an argument'
%
opt
,
opt
)
raise
GetoptError
(
_
(
'option --%s must not have an argument'
)
%
opt
,
opt
)
opts
.
append
((
'--'
+
opt
,
optarg
or
''
))
opts
.
append
((
'--'
+
opt
,
optarg
or
''
))
return
opts
,
args
return
opts
,
args
...
@@ -166,7 +167,7 @@ def do_longs(opts, opt, longopts, args):
...
@@ -166,7 +167,7 @@ def do_longs(opts, opt, longopts, args):
def
long_has_args
(
opt
,
longopts
):
def
long_has_args
(
opt
,
longopts
):
possibilities
=
[
o
for
o
in
longopts
if
o
.
startswith
(
opt
)]
possibilities
=
[
o
for
o
in
longopts
if
o
.
startswith
(
opt
)]
if
not
possibilities
:
if
not
possibilities
:
raise
GetoptError
(
'option --%s not recognized'
%
opt
,
opt
)
raise
GetoptError
(
_
(
'option --%s not recognized'
)
%
opt
,
opt
)
# Is there an exact match?
# Is there an exact match?
if
opt
in
possibilities
:
if
opt
in
possibilities
:
return
False
,
opt
return
False
,
opt
...
@@ -176,7 +177,7 @@ def long_has_args(opt, longopts):
...
@@ -176,7 +177,7 @@ def long_has_args(opt, longopts):
if
len
(
possibilities
)
>
1
:
if
len
(
possibilities
)
>
1
:
# XXX since possibilities contains all valid continuations, might be
# XXX since possibilities contains all valid continuations, might be
# nice to work them into the error msg
# nice to work them into the error msg
raise
GetoptError
(
'option --%s not a unique prefix'
%
opt
,
opt
)
raise
GetoptError
(
_
(
'option --%s not a unique prefix'
)
%
opt
,
opt
)
assert
len
(
possibilities
)
==
1
assert
len
(
possibilities
)
==
1
unique_match
=
possibilities
[
0
]
unique_match
=
possibilities
[
0
]
has_arg
=
unique_match
.
endswith
(
'='
)
has_arg
=
unique_match
.
endswith
(
'='
)
...
@@ -190,7 +191,7 @@ def do_shorts(opts, optstring, shortopts, args):
...
@@ -190,7 +191,7 @@ def do_shorts(opts, optstring, shortopts, args):
if
short_has_arg
(
opt
,
shortopts
):
if
short_has_arg
(
opt
,
shortopts
):
if
optstring
==
''
:
if
optstring
==
''
:
if
not
args
:
if
not
args
:
raise
GetoptError
(
'option -%s requires argument'
%
opt
,
raise
GetoptError
(
_
(
'option -%s requires argument'
)
%
opt
,
opt
)
opt
)
optstring
,
args
=
args
[
0
],
args
[
1
:]
optstring
,
args
=
args
[
0
],
args
[
1
:]
optarg
,
optstring
=
optstring
,
''
optarg
,
optstring
=
optstring
,
''
...
@@ -203,7 +204,7 @@ def short_has_arg(opt, shortopts):
...
@@ -203,7 +204,7 @@ def short_has_arg(opt, shortopts):
for
i
in
range
(
len
(
shortopts
)):
for
i
in
range
(
len
(
shortopts
)):
if
opt
==
shortopts
[
i
]
!=
':'
:
if
opt
==
shortopts
[
i
]
!=
':'
:
return
shortopts
.
startswith
(
':'
,
i
+
1
)
return
shortopts
.
startswith
(
':'
,
i
+
1
)
raise
GetoptError
(
'option -%s not recognized'
%
opt
,
opt
)
raise
GetoptError
(
_
(
'option -%s not recognized'
)
%
opt
,
opt
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
import
sys
import
sys
...
...
Misc/NEWS
View file @
50dc1a23
...
@@ -81,6 +81,9 @@ Core and Builtins
...
@@ -81,6 +81,9 @@ Core and Builtins
Library
Library
-------
-------
-
Issue
#
11371
:
Mark
getopt
error
messages
as
localizable
.
Patch
by
Filip
Gruszczy
ń
ski
.
-
Issue
#
5537
:
Fix
time2isoz
()
and
time2netscape
()
functions
of
-
Issue
#
5537
:
Fix
time2isoz
()
and
time2netscape
()
functions
of
httplib
.
cookiejar
for
expiration
year
greater
than
2038
on
32
-
bit
systems
.
httplib
.
cookiejar
for
expiration
year
greater
than
2038
on
32
-
bit
systems
.
...
...
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