Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 14eba5f

Browse files
committed
Brench merge
2 parents 47fe5c0 + 4460abe commit 14eba5f

8 files changed

Lines changed: 34 additions & 37 deletions

File tree

Doc/library/argparse.rst

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
===============================================================================
33

44
.. module:: argparse
5-
:synopsis: Command-line option and argument-parsing library.
5+
:synopsis: Command-line option and argument parsing library.
66
.. moduleauthor:: Steven Bethard <[email protected]>
77
.. sectionauthor:: Steven Bethard <[email protected]>
88

@@ -107,7 +107,7 @@ or the :func:`max` function if it was not.
107107
Parsing arguments
108108
^^^^^^^^^^^^^^^^^
109109

110-
:class:`ArgumentParser` parses args through the
110+
:class:`ArgumentParser` parses arguments through the
111111
:meth:`~ArgumentParser.parse_args` method. This will inspect the command line,
112112
convert each arg to the appropriate type and then invoke the appropriate action.
113113
In most cases, this means a simple :class:`Namespace` object will be built up from
@@ -118,7 +118,7 @@ attributes parsed out of the command line::
118118

119119
In a script, :meth:`~ArgumentParser.parse_args` will typically be called with no
120120
arguments, and the :class:`ArgumentParser` will automatically determine the
121-
command-line args from :data:`sys.argv`.
121+
command-line arguments from :data:`sys.argv`.
122122

123123

124124
ArgumentParser objects
@@ -669,11 +669,11 @@ be positional::
669669
action
670670
^^^^^^
671671

672-
:class:`ArgumentParser` objects associate command-line args with actions. These
673-
actions can do just about anything with the command-line args associated with
672+
:class:`ArgumentParser` objects associate command-line arguments with actions. These
673+
actions can do just about anything with the command-line arguments associated with
674674
them, though most actions simply add an attribute to the object returned by
675675
:meth:`~ArgumentParser.parse_args`. The ``action`` keyword argument specifies
676-
how the command-line args should be handled. The supported actions are:
676+
how the command-line arguments should be handled. The supported actions are:
677677

678678
* ``'store'`` - This just stores the argument's value. This is the default
679679
action. For example::
@@ -745,8 +745,8 @@ the Action API. The easiest way to do this is to extend
745745
:meth:`~ArgumentParser.parse_args`. Most actions add an attribute to this
746746
object.
747747

748-
* ``values`` - The associated command-line args, with any type-conversions
749-
applied. (Type-conversions are specified with the type_ keyword argument to
748+
* ``values`` - The associated command-line arguments, with any type conversions
749+
applied. (Type conversions are specified with the type_ keyword argument to
750750
:meth:`~ArgumentParser.add_argument`.
751751

752752
* ``option_string`` - The option string that was used to invoke this action.
@@ -778,7 +778,7 @@ single action to be taken. The ``nargs`` keyword argument associates a
778778
different number of command-line arguments with a single action. The supported
779779
values are:
780780

781-
* N (an integer). N args from the command line will be gathered together into a
781+
* N (an integer). N arguments from the command line will be gathered together into a
782782
list. For example::
783783

784784
>>> parser = argparse.ArgumentParser()
@@ -822,7 +822,7 @@ values are:
822822
Namespace(infile=<_io.TextIOWrapper name='<stdin>' encoding='UTF-8'>,
823823
outfile=<_io.TextIOWrapper name='<stdout>' encoding='UTF-8'>)
824824

825-
* ``'*'``. All command-line args present are gathered into a list. Note that
825+
* ``'*'``. All command-line arguments present are gathered into a list. Note that
826826
it generally doesn't make much sense to have more than one positional argument
827827
with ``nargs='*'``, but multiple optional arguments with ``nargs='*'`` is
828828
possible. For example::
@@ -846,7 +846,7 @@ values are:
846846
usage: PROG [-h] foo [foo ...]
847847
PROG: error: too few arguments
848848

849-
If the ``nargs`` keyword argument is not provided, the number of args consumed
849+
If the ``nargs`` keyword argument is not provided, the number of arguments consumed
850850
is determined by the action_. Generally this means a single command-line arg
851851
will be consumed and a single item (not a list) will be produced.
852852

@@ -864,7 +864,7 @@ the various :class:`ArgumentParser` actions. The two most common uses of it are
864864

865865
* When :meth:`~ArgumentParser.add_argument` is called with option strings
866866
(like ``-f`` or ``--foo``) and ``nargs='?'``. This creates an optional
867-
argument that can be followed by zero or one command-line args.
867+
argument that can be followed by zero or one command-line arguments.
868868
When parsing the command line, if the option string is encountered with no
869869
command-line arg following it, the value of ``const`` will be assumed instead.
870870
See the nargs_ description for examples.
@@ -914,11 +914,11 @@ command-line argument was not present.::
914914
type
915915
^^^^
916916

917-
By default, :class:`ArgumentParser` objects read command-line args in as simple
917+
By default, :class:`ArgumentParser` objects read command-line arguments in as simple
918918
strings. However, quite often the command-line string should instead be
919919
interpreted as another type, like a :class:`float` or :class:`int`. The
920920
``type`` keyword argument of :meth:`~ArgumentParser.add_argument` allows any
921-
necessary type-checking and type-conversions to be performed. Common built-in
921+
necessary type-checking and type conversions to be performed. Common built-in
922922
types and functions can be used directly as the value of the ``type`` argument::
923923

924924
>>> parser = argparse.ArgumentParser()
@@ -938,7 +938,7 @@ writable file::
938938
Namespace(bar=<_io.TextIOWrapper name='out.txt' encoding='UTF-8'>)
939939

940940
``type=`` can take any callable that takes a single string argument and returns
941-
the type-converted value::
941+
the converted value::
942942

943943
>>> def perfect_square(string):
944944
... value = int(string)
@@ -973,7 +973,7 @@ See the choices_ section for more details.
973973
choices
974974
^^^^^^^
975975

976-
Some command-line args should be selected from a restricted set of values.
976+
Some command-line arguments should be selected from a restricted set of values.
977977
These can be handled by passing a container object as the ``choices`` keyword
978978
argument to :meth:`~ArgumentParser.add_argument`. When the command line is
979979
parsed, arg values will be checked, and an error message will be displayed if
@@ -1331,7 +1331,7 @@ An error is produced for arguments that could produce more than one options.
13311331
Beyond ``sys.argv``
13321332
^^^^^^^^^^^^^^^^^^^
13331333

1334-
Sometimes it may be useful to have an ArgumentParser parse args other than those
1334+
Sometimes it may be useful to have an ArgumentParser parse arguments other than those
13351335
of :data:`sys.argv`. This can be accomplished by passing a list of strings to
13361336
:meth:`~ArgumentParser.parse_args`. This is useful for testing at the
13371337
interactive prompt::
@@ -1559,7 +1559,7 @@ FileType objects
15591559

15601560
The :class:`FileType` factory creates objects that can be passed to the type
15611561
argument of :meth:`ArgumentParser.add_argument`. Arguments that have
1562-
:class:`FileType` objects as their type will open command-line args as files
1562+
:class:`FileType` objects as their type will open command-line arguments as files
15631563
with the requested modes and buffer sizes:
15641564

15651565
>>> parser = argparse.ArgumentParser()
@@ -1673,7 +1673,7 @@ Parser defaults
16731673
.. method:: ArgumentParser.set_defaults(**kwargs)
16741674

16751675
Most of the time, the attributes of the object returned by :meth:`parse_args`
1676-
will be fully determined by inspecting the command-line args and the argument
1676+
will be fully determined by inspecting the command-line arguments and the argument
16771677
actions. :meth:`set_defaults` allows some additional
16781678
attributes that are determined without any inspection of the command line to
16791679
be added::

Doc/library/email.policy.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
.. module:: email.policy
55
:synopsis: Controlling the parsing and generating of messages
66

7-
.. versionadded: 3.3
7+
.. versionadded:: 3.3
88

99

1010
The :mod:`email` package's prime focus is the handling of email messages as

Lib/distutils/tests/test_build_py.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from distutils.errors import DistutilsFileError
1111

1212
from distutils.tests import support
13-
from test.support import run_unittest, create_empty_file
13+
from test.support import run_unittest
1414

1515

1616
class BuildPyTestCase(support.TempdirManager,
@@ -71,11 +71,11 @@ def test_empty_package_dir(self):
7171

7272
# create the distribution files.
7373
sources = self.mkdtemp()
74-
create_empty_file(os.path.join(sources, "__init__.py"))
74+
open(os.path.join(sources, "__init__.py"), "w").close()
7575

7676
testdir = os.path.join(sources, "doc")
7777
os.mkdir(testdir)
78-
create_empty_file(os.path.join(testdir, "testfile"))
78+
open(os.path.join(testdir, "testfile"), "w").close()
7979

8080
os.chdir(sources)
8181
old_stdout = sys.stdout

Lib/packaging/tests/test_pypi_xmlrpc.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,14 @@
33
from packaging.pypi.xmlrpc import Client, InvalidSearchField, ProjectNotFound
44

55
from packaging.tests import unittest
6+
from packaging.tests.support import fake_dec
67

78
try:
89
import threading
910
from packaging.tests.pypi_server import use_xmlrpc_server
1011
except ImportError:
1112
threading = None
12-
def use_xmlrpc_server():
13-
def _use(func):
14-
def __use(*args, **kw):
15-
return func(*args, **kw)
16-
return __use
17-
return _use
13+
use_xmlrpc_server = fake_dec
1814

1915

2016
@unittest.skipIf(threading is None, "Needs threading")

Lib/shlex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ def split(s, comments=False, posix=True):
276276
return list(lex)
277277

278278

279-
_find_unsafe = re.compile(r'[^\w\d@%_\-\+=:,\./]').search
279+
_find_unsafe = re.compile(r'[^\w@%\-\+=:,\./]', re.ASCII).search
280280

281281
def quote(s):
282282
"""Return a shell-escaped version of the string *s*."""

Lib/shutil.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def onerror(*args):
267267
names = []
268268
try:
269269
names = os.listdir(path)
270-
except os.error as err:
270+
except os.error:
271271
onerror(os.listdir, path, sys.exc_info())
272272
for name in names:
273273
fullname = os.path.join(path, name)
@@ -280,7 +280,7 @@ def onerror(*args):
280280
else:
281281
try:
282282
os.remove(fullname)
283-
except os.error as err:
283+
except os.error:
284284
onerror(os.remove, fullname, sys.exc_info())
285285
try:
286286
os.rmdir(path)
@@ -323,7 +323,7 @@ def move(src, dst):
323323
raise Error("Destination path '%s' already exists" % real_dst)
324324
try:
325325
os.rename(src, real_dst)
326-
except OSError as exc:
326+
except OSError:
327327
if os.path.isdir(src):
328328
if _destinsrc(src, dst):
329329
raise Error("Cannot move a directory '%s' into itself '%s'." % (src, dst))

Lib/test/test_shlex.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ def testCompat(self):
176176

177177
def testQuote(self):
178178
safeunquoted = string.ascii_letters + string.digits + '@%_-+=:,./'
179-
unsafe = '"`$\\!'
179+
unicode_sample = '\xe9\xe0\xdf' # e + acute accent, a + grave, sharp s
180+
unsafe = '"`$\\!' + unicode_sample
180181

181182
self.assertEqual(shlex.quote(''), "''")
182183
self.assertEqual(shlex.quote(safeunquoted), safeunquoted)

Makefile.pre.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,8 +1330,8 @@ smelly: all
13301330

13311331
# Find files with funny names
13321332
funny:
1333-
find $(DISTDIRS) \
1334-
-o -type d \
1333+
find $(SUBDIRS) $(SUBDIRSTOO) \
1334+
-type d \
13351335
-o -name '*.[chs]' \
13361336
-o -name '*.py' \
13371337
-o -name '*.pyw' \
@@ -1359,7 +1359,7 @@ funny:
13591359
-o -name .hgignore \
13601360
-o -name .bzrignore \
13611361
-o -name MANIFEST \
1362-
-o -print
1362+
-print
13631363

13641364
# Perform some verification checks on any modified files.
13651365
patchcheck:

0 commit comments

Comments
 (0)