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

Skip to content

Commit 388c0e2

Browse files
committed
merge heads
2 parents 6d8f744 + 900c292 commit 388c0e2

18 files changed

Lines changed: 176 additions & 37 deletions

File tree

Doc/library/curses.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,17 @@ The module :mod:`curses` defines the following functions:
598598
Only one *ch* can be pushed before :meth:`getch` is called.
599599

600600

601+
.. function:: unget_wch(ch)
602+
603+
Push *ch* so the next :meth:`get_wch` will return it.
604+
605+
.. note::
606+
607+
Only one *ch* can be pushed before :meth:`get_wch` is called.
608+
609+
.. versionadded:: 3.3
610+
611+
601612
.. function:: ungetmouse(id, x, y, z, bstate)
602613

603614
Push a :const:`KEY_MOUSE` event onto the input queue, associating the given

Doc/library/multiprocessing.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -571,9 +571,9 @@ For an example of the usage of queues for interprocess communication see
571571
Return ``True`` if the queue is full, ``False`` otherwise. Because of
572572
multithreading/multiprocessing semantics, this is not reliable.
573573

574-
.. method:: put(item[, block[, timeout]])
574+
.. method:: put(obj[, block[, timeout]])
575575

576-
Put item into the queue. If the optional argument *block* is ``True``
576+
Put obj into the queue. If the optional argument *block* is ``True``
577577
(the default) and *timeout* is ``None`` (the default), block if necessary until
578578
a free slot is available. If *timeout* is a positive number, it blocks at
579579
most *timeout* seconds and raises the :exc:`queue.Full` exception if no
@@ -582,9 +582,9 @@ For an example of the usage of queues for interprocess communication see
582582
available, else raise the :exc:`queue.Full` exception (*timeout* is
583583
ignored in that case).
584584

585-
.. method:: put_nowait(item)
585+
.. method:: put_nowait(obj)
586586

587-
Equivalent to ``put(item, False)``.
587+
Equivalent to ``put(obj, False)``.
588588

589589
.. method:: get([block[, timeout]])
590590

Doc/packaging/setupcfg.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Extending files
7272
---------------
7373

7474
A configuration file can be extended (i.e. included) by other files. For this,
75-
a ``DEFAULT`` section must contain an ``extends`` key which value points to one
75+
a ``DEFAULT`` section must contain an ``extends`` key whose value points to one
7676
or more files which will be merged into the current files by adding new sections
7777
and fields. If a file loaded by ``extends`` contains sections or keys that
7878
already exist in the original file, they will not override the previous values.

Include/unicodeobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ PyAPI_FUNC(Py_ssize_t) PyUnicode_AsWideChar(
608608

609609
/* Convert the Unicode object to a wide character string. The output string
610610
always ends with a nul character. If size is not NULL, write the number of
611-
wide characters (including the nul character) into *size.
611+
wide characters (excluding the null character) into *size.
612612
613613
Returns a buffer allocated by PyMem_Alloc() (use PyMem_Free() to free it)
614614
on success. On error, returns NULL, *size is undefined and raises a

Lib/distutils/command/install_egg_info.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ def run(self):
4040
"Creating "+self.install_dir)
4141
log.info("Writing %s", target)
4242
if not self.dry_run:
43-
f = open(target, 'w')
44-
self.distribution.metadata.write_pkg_file(f)
45-
f.close()
43+
with open(target, 'w', encoding='UTF-8') as f:
44+
self.distribution.metadata.write_pkg_file(f)
4645

4746
def get_outputs(self):
4847
return self.outputs

Lib/distutils/command/sdist.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,10 @@ def read_template(self):
306306

307307
try:
308308
self.filelist.process_template_line(line)
309-
except DistutilsTemplateError as msg:
309+
# the call above can raise a DistutilsTemplateError for
310+
# malformed lines, or a ValueError from the lower-level
311+
# convert_path function
312+
except (DistutilsTemplateError, ValueError) as msg:
310313
self.warn("%s, line %d: %s" % (template.filename,
311314
template.current_line,
312315
msg))

Lib/distutils/dist.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,11 +1010,9 @@ def __init__ (self):
10101010
def write_pkg_info(self, base_dir):
10111011
"""Write the PKG-INFO file into the release tree.
10121012
"""
1013-
pkg_info = open(os.path.join(base_dir, 'PKG-INFO'), 'w')
1014-
try:
1013+
with open(os.path.join(base_dir, 'PKG-INFO'), 'w',
1014+
encoding='UTF-8') as pkg_info:
10151015
self.write_pkg_file(pkg_info)
1016-
finally:
1017-
pkg_info.close()
10181016

10191017
def write_pkg_file(self, file):
10201018
"""Write the PKG-INFO format data to a file object.

Lib/distutils/tests/test_sdist.py

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from distutils.errors import DistutilsOptionError
1616
from distutils.spawn import find_executable
1717
from distutils.log import WARN
18+
from distutils.filelist import FileList
1819
from distutils.archive_util import ARCHIVE_FORMATS
1920

2021
SETUP_PY = """
@@ -78,9 +79,6 @@ def get_cmd(self, metadata=None):
7879
dist.include_package_data = True
7980
cmd = sdist(dist)
8081
cmd.dist_dir = 'dist'
81-
def _warn(*args):
82-
pass
83-
cmd.warn = _warn
8482
return dist, cmd
8583

8684
@unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
@@ -235,7 +233,8 @@ def test_metadata_check_option(self):
235233
# with the `check` subcommand
236234
cmd.ensure_finalized()
237235
cmd.run()
238-
warnings = self.get_logs(WARN)
236+
warnings = [msg for msg in self.get_logs(WARN) if
237+
msg.startswith('warning: check:')]
239238
self.assertEqual(len(warnings), 2)
240239

241240
# trying with a complete set of metadata
@@ -244,7 +243,8 @@ def test_metadata_check_option(self):
244243
cmd.ensure_finalized()
245244
cmd.metadata_check = 0
246245
cmd.run()
247-
warnings = self.get_logs(WARN)
246+
warnings = [msg for msg in self.get_logs(WARN) if
247+
msg.startswith('warning: check:')]
248248
self.assertEqual(len(warnings), 0)
249249

250250
def test_check_metadata_deprecated(self):
@@ -266,7 +266,6 @@ def test_show_formats(self):
266266
self.assertEqual(len(output), num_formats)
267267

268268
def test_finalize_options(self):
269-
270269
dist, cmd = self.get_cmd()
271270
cmd.finalize_options()
272271

@@ -286,6 +285,32 @@ def test_finalize_options(self):
286285
cmd.formats = 'supazipa'
287286
self.assertRaises(DistutilsOptionError, cmd.finalize_options)
288287

288+
# the following tests make sure there is a nice error message instead
289+
# of a traceback when parsing an invalid manifest template
290+
291+
def _test_template(self, content):
292+
dist, cmd = self.get_cmd()
293+
os.chdir(self.tmp_dir)
294+
self.write_file('MANIFEST.in', content)
295+
cmd.ensure_finalized()
296+
cmd.filelist = FileList()
297+
cmd.read_template()
298+
warnings = self.get_logs(WARN)
299+
self.assertEqual(len(warnings), 1)
300+
301+
def test_invalid_template_unknown_command(self):
302+
self._test_template('taunt knights *')
303+
304+
def test_invalid_template_wrong_arguments(self):
305+
# this manifest command takes one argument
306+
self._test_template('prune')
307+
308+
@unittest.skipIf(os.name != 'nt', 'test relevant for Windows only')
309+
def test_invalid_template_wrong_path(self):
310+
# on Windows, trailing slashes are not allowed
311+
# this used to crash instead of raising a warning: #8286
312+
self._test_template('include examples/')
313+
289314
@unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
290315
def test_get_file_list(self):
291316
# make sure MANIFEST is recalculated

Lib/html/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,4 +458,4 @@ def replaceEntities(s):
458458
return '&'+s+';'
459459

460460
return re.sub(r"&(#?[xX]?(?:[0-9a-fA-F]+|\w{1,8}));",
461-
replaceEntities, s, re.ASCII)
461+
replaceEntities, s, flags=re.ASCII)

Lib/packaging/tests/test_util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ def _setuptools_egg_info_pkg(self):
946946

947947
def _distutils_pkg_info(self):
948948
tmp = self._distutils_setup_py_pkg()
949-
self.write_file([tmp, 'PKG-INFO'], '')
949+
self.write_file([tmp, 'PKG-INFO'], '', encoding='UTF-8')
950950
return tmp
951951

952952
def _setup_cfg_with_no_metadata_pkg(self):
@@ -971,7 +971,7 @@ def _egg_info_with_no_setuptools(self):
971971

972972
def _pkg_info_with_no_distutils(self):
973973
tmp = self._random_setup_py_pkg()
974-
self.write_file([tmp, 'PKG-INFO'], '')
974+
self.write_file([tmp, 'PKG-INFO'], '', encoding='UTF-8')
975975
return tmp
976976

977977
def _random_setup_py_pkg(self):

0 commit comments

Comments
 (0)