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

Skip to content

Commit bb7da03

Browse files
author
Éric Araujo
committed
Merge fixes for #13614, #13512 and #7719 from 3.3
2 parents 53f604c + 3f7c0e4 commit bb7da03

12 files changed

Lines changed: 74 additions & 34 deletions

File tree

Doc/distutils/apiref.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,12 @@ directories.
992992
destination of the symlink will be copied. *update* and *verbose* are the same
993993
as for :func:`copy_file`.
994994

995+
Files in *src* that begin with :file:`.nfs` are skipped (more information on
996+
these files is available in answer D2 of the `NFS FAQ page
997+
<http://nfs.sourceforge.net/#section_d>`_.
998+
999+
.. versionchanged:: 3.3.1
1000+
NFS files are ignored.
9951001

9961002
.. function:: remove_tree(directory[, verbose=0, dry_run=0])
9971003

Doc/library/abc.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ This module provides the following class:
129129

130130
The :mod:`abc` module also provides the following decorators:
131131

132-
.. decorator:: abstractmethod(function)
132+
.. decorator:: abstractmethod
133133

134134
A decorator indicating abstract methods.
135135

@@ -203,7 +203,7 @@ The :mod:`abc` module also provides the following decorators:
203203
multiple-inheritance.
204204

205205

206-
.. decorator:: abstractclassmethod(function)
206+
.. decorator:: abstractclassmethod
207207

208208
A subclass of the built-in :func:`classmethod`, indicating an abstract
209209
classmethod. Otherwise it is similar to :func:`abstractmethod`.
@@ -224,7 +224,7 @@ The :mod:`abc` module also provides the following decorators:
224224
:func:`abstractmethod`, making this decorator redundant.
225225

226226

227-
.. decorator:: abstractstaticmethod(function)
227+
.. decorator:: abstractstaticmethod
228228

229229
A subclass of the built-in :func:`staticmethod`, indicating an abstract
230230
staticmethod. Otherwise it is similar to :func:`abstractmethod`.

Doc/library/io.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ I/O Base Classes
232232
Note that calling any method (even inquiries) on a closed stream is
233233
undefined. Implementations may raise :exc:`ValueError` in this case.
234234

235-
:class:`IOBase` (and its subclasses) support the iterator protocol, meaning
235+
:class:`IOBase` (and its subclasses) supports the iterator protocol, meaning
236236
that an :class:`IOBase` object can be iterated over yielding the lines in a
237237
stream. Lines are defined slightly differently depending on whether the
238238
stream is a binary stream (yielding bytes), or a text stream (yielding

Doc/library/sys.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ always available.
833833
For other systems, the values are:
834834

835835
================ ===========================
836-
System :data:`platform` value
836+
System ``platform`` value
837837
================ ===========================
838838
Linux ``'linux'``
839839
Windows ``'win32'``

Lib/distutils/command/check.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ def __init__(self, source, report_level, halt_level, stream=None,
2323

2424
def system_message(self, level, message, *children, **kwargs):
2525
self.messages.append((level, message, children, kwargs))
26+
return nodes.system_message(message, level=level,
27+
type=self.levels[level],
28+
*children, **kwargs)
2629

2730
HAS_DOCUTILS = True
2831
except Exception:

Lib/distutils/config.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
that uses .pypirc in the distutils.command package.
55
"""
66
import os
7-
import sys
87
from configparser import ConfigParser
98

109
from distutils.cmd import Command
@@ -43,16 +42,8 @@ def _get_rc_file(self):
4342
def _store_pypirc(self, username, password):
4443
"""Creates a default .pypirc file."""
4544
rc = self._get_rc_file()
46-
f = open(rc, 'w')
47-
try:
45+
with os.fdopen(os.open(rc, os.O_CREAT | os.O_WRONLY, 0o600), 'w') as f:
4846
f.write(DEFAULT_PYPIRC % (username, password))
49-
finally:
50-
f.close()
51-
try:
52-
os.chmod(rc, 0o600)
53-
except OSError:
54-
# should do something better here
55-
pass
5647

5748
def _read_pypirc(self):
5849
"""Reads the .pypirc file."""

Lib/distutils/dir_util.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ def copy_tree(src, dst, preserve_mode=1, preserve_times=1,
141141
src_name = os.path.join(src, n)
142142
dst_name = os.path.join(dst, n)
143143

144+
if n.startswith('.nfs'):
145+
# skip NFS rename files
146+
continue
147+
144148
if preserve_symlinks and os.path.islink(src_name):
145149
link_dest = os.readlink(src_name)
146150
if verbose >= 1:

Lib/distutils/tests/test_dir_util.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ def test_create_tree_verbosity(self):
7676

7777
remove_tree(self.root_target, verbose=0)
7878

79-
8079
def test_copy_tree_verbosity(self):
8180

8281
mkpath(self.target, verbose=0)
@@ -88,11 +87,8 @@ def test_copy_tree_verbosity(self):
8887

8988
mkpath(self.target, verbose=0)
9089
a_file = os.path.join(self.target, 'ok.txt')
91-
f = open(a_file, 'w')
92-
try:
90+
with open(a_file, 'w') as f:
9391
f.write('some content')
94-
finally:
95-
f.close()
9692

9793
wanted = ['copying %s -> %s' % (a_file, self.target2)]
9894
copy_tree(self.target, self.target2, verbose=1)
@@ -101,6 +97,21 @@ def test_copy_tree_verbosity(self):
10197
remove_tree(self.root_target, verbose=0)
10298
remove_tree(self.target2, verbose=0)
10399

100+
def test_copy_tree_skips_nfs_temp_files(self):
101+
mkpath(self.target, verbose=0)
102+
103+
a_file = os.path.join(self.target, 'ok.txt')
104+
nfs_file = os.path.join(self.target, '.nfs123abc')
105+
for f in a_file, nfs_file:
106+
with open(f, 'w') as fh:
107+
fh.write('some content')
108+
109+
copy_tree(self.target, self.target2)
110+
self.assertEqual(os.listdir(self.target2), ['ok.txt'])
111+
112+
remove_tree(self.root_target, verbose=0)
113+
remove_tree(self.target2, verbose=0)
114+
104115
def test_ensure_relative(self):
105116
if os.sep == '/':
106117
self.assertEqual(ensure_relative('/home/foo'), 'home/foo')

Lib/distutils/tests/test_register.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
"""Tests for distutils.command.register."""
2-
import sys
32
import os
43
import unittest
54
import getpass
@@ -10,11 +9,14 @@
109

1110
from distutils.command import register as register_module
1211
from distutils.command.register import register
13-
from distutils.core import Distribution
1412
from distutils.errors import DistutilsSetupError
1513

16-
from distutils.tests import support
17-
from distutils.tests.test_config import PYPIRC, PyPIRCCommandTestCase
14+
from distutils.tests.test_config import PyPIRCCommandTestCase
15+
16+
try:
17+
import docutils
18+
except ImportError:
19+
docutils = None
1820

1921
PYPIRC_NOPASSWORD = """\
2022
[distutils]
@@ -193,6 +195,7 @@ def test_password_reset(self):
193195
self.assertEqual(headers['Content-length'], '290')
194196
self.assertTrue((b'tarek') in req.data)
195197

198+
@unittest.skipUnless(docutils is not None, 'needs docutils')
196199
def test_strict(self):
197200
# testing the script option
198201
# when on, the register command stops if
@@ -205,13 +208,6 @@ def test_strict(self):
205208
cmd.strict = 1
206209
self.assertRaises(DistutilsSetupError, cmd.run)
207210

208-
# we don't test the reSt feature if docutils
209-
# is not installed
210-
try:
211-
import docutils
212-
except ImportError:
213-
return
214-
215211
# metadata are OK but long_description is broken
216212
metadata = {'url': 'xxx', 'author': 'xxx',
217213
'author_email': 'éxéxé',
@@ -265,6 +261,22 @@ def test_strict(self):
265261
finally:
266262
del register_module.input
267263

264+
@unittest.skipUnless(docutils is not None, 'needs docutils')
265+
def test_register_invalid_long_description(self):
266+
description = ':funkie:`str`' # mimic Sphinx-specific markup
267+
metadata = {'url': 'xxx', 'author': 'xxx',
268+
'author_email': 'xxx',
269+
'name': 'xxx', 'version': 'xxx',
270+
'long_description': description}
271+
cmd = self._get_cmd(metadata)
272+
cmd.ensure_finalized()
273+
cmd.strict = True
274+
inputs = Inputs('2', 'tarek', '[email protected]')
275+
register_module.input = inputs
276+
self.addCleanup(delattr, register_module, 'input')
277+
278+
self.assertRaises(DistutilsSetupError, cmd.run)
279+
268280
def test_check_metadata_deprecated(self):
269281
# makes sure make_metadata is deprecated
270282
cmd = self._get_cmd()

Lib/distutils/tests/test_sdist.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,8 @@ def get_cmd(self, metadata=None):
8383

8484
@unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
8585
def test_prune_file_list(self):
86-
# this test creates a package with some vcs dirs in it
87-
# and launch sdist to make sure they get pruned
88-
# on all systems
86+
# this test creates a project with some VCS dirs and an NFS rename
87+
# file, then launches sdist to check they get pruned on all systems
8988

9089
# creating VCS directories with some files in them
9190
os.mkdir(join(self.tmp_dir, 'somecode', '.svn'))
@@ -99,6 +98,8 @@ def test_prune_file_list(self):
9998
self.write_file((self.tmp_dir, 'somecode', '.git',
10099
'ok'), 'xxx')
101100

101+
self.write_file((self.tmp_dir, 'somecode', '.nfs0001'), 'xxx')
102+
102103
# now building a sdist
103104
dist, cmd = self.get_cmd()
104105

0 commit comments

Comments
 (0)