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

Skip to content

Commit 486364b

Browse files
committed
Merged revisions 56020-56124 via svnmerge from
svn+ssh://[email protected]/python/branches/p3yk ................ r56037 | georg.brandl | 2007-06-19 05:33:20 -0700 (Tue, 19 Jun 2007) | 2 lines Patch #1739659: don't slice dict.keys() in pydoc. ................ r56060 | martin.v.loewis | 2007-06-21 13:00:02 -0700 (Thu, 21 Jun 2007) | 2 lines Regenerate to add True, False, None. ................ r56069 | neal.norwitz | 2007-06-21 22:31:56 -0700 (Thu, 21 Jun 2007) | 1 line Get the doctest working again after adding None, True, and False as kewyords. ................ r56070 | neal.norwitz | 2007-06-21 23:25:33 -0700 (Thu, 21 Jun 2007) | 1 line Add space to error message. ................ r56071 | neal.norwitz | 2007-06-21 23:40:04 -0700 (Thu, 21 Jun 2007) | 6 lines Get pybench working, primarily * Use print function * Stop using string module * Use sorted instead of assuming dict methods return lists * Convert range result to a list ................ r56089 | collin.winter | 2007-06-26 10:31:48 -0700 (Tue, 26 Jun 2007) | 1 line Fix AttributeError in distutils/dir_util.py. ................ r56124 | guido.van.rossum | 2007-06-29 18:04:31 -0700 (Fri, 29 Jun 2007) | 30 lines Merged revisions 56014-56123 via svnmerge from svn+ssh://[email protected]/python/trunk ........ r56019 | lars.gustaebel | 2007-06-18 04:42:11 -0700 (Mon, 18 Jun 2007) | 2 lines Added exclude keyword argument to the TarFile.add() method. ........ r56023 | lars.gustaebel | 2007-06-18 13:05:55 -0700 (Mon, 18 Jun 2007) | 3 lines Added missing \versionchanged tag for the new exclude parameter. ........ r56038 | georg.brandl | 2007-06-19 05:36:00 -0700 (Tue, 19 Jun 2007) | 2 lines Bug #1737864: allow empty message in logging format routines. ........ r56040 | georg.brandl | 2007-06-19 05:38:20 -0700 (Tue, 19 Jun 2007) | 2 lines Bug #1739115: make shutil.rmtree docs clear wrt. file deletion. ........ r56084 | georg.brandl | 2007-06-25 08:21:23 -0700 (Mon, 25 Jun 2007) | 2 lines Bug #1742901: document None behavior of shlex.split. ........ r56091 | georg.brandl | 2007-06-27 07:09:56 -0700 (Wed, 27 Jun 2007) | 2 lines Fix a variable name in winreg docs. ........ ................
1 parent 8ddff70 commit 486364b

20 files changed

Lines changed: 286 additions & 253 deletions

Doc/lib/libshlex.tex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ \section{\module{shlex} ---
2828
\var{posix} argument is false.
2929
\versionadded{2.3}
3030
\versionchanged[Added the \var{posix} parameter]{2.6}
31+
\note{Since the \function{split()} function instantiates a \class{shlex}
32+
instance, passing \code{None} for \var{s} will read the string
33+
to split from standard input.}
3134
\end{funcdesc}
3235

3336
The \module{shlex} module defines the following class:

Doc/lib/libshutil.tex

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,12 @@ \section{\module{shutil} ---
9191
\end{funcdesc}
9292

9393
\begin{funcdesc}{rmtree}{path\optional{, ignore_errors\optional{, onerror}}}
94-
Delete an entire directory tree.\index{directory!deleting}
95-
If \var{ignore_errors} is true,
96-
errors resulting from failed removals will be ignored; if false or
97-
omitted, such errors are handled by calling a handler specified by
98-
\var{onerror} or, if that is omitted, they raise an exception.
94+
\index{directory!deleting}
95+
Delete an entire directory tree (\var{path} must point to a directory).
96+
If \var{ignore_errors} is true, errors resulting from failed removals
97+
will be ignored; if false or omitted, such errors are handled by
98+
calling a handler specified by \var{onerror} or, if that is omitted,
99+
they raise an exception.
99100

100101
If \var{onerror} is provided, it must be a callable that accepts
101102
three parameters: \var{function}, \var{path}, and \var{excinfo}.

Doc/lib/libtarfile.tex

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,13 +314,17 @@ \subsection{TarFile Objects \label{tarfile-objects}}
314314
\end{notice}
315315
\end{methoddesc}
316316

317-
\begin{methoddesc}{add}{name\optional{, arcname\optional{, recursive}}}
317+
\begin{methoddesc}{add}{name\optional{, arcname\optional{, recursive\optional{, exclude}}}}
318318
Add the file \var{name} to the archive. \var{name} may be any type
319319
of file (directory, fifo, symbolic link, etc.).
320320
If given, \var{arcname} specifies an alternative name for the file in the
321321
archive. Directories are added recursively by default.
322-
This can be avoided by setting \var{recursive} to \constant{False};
323-
the default is \constant{True}.
322+
This can be avoided by setting \var{recursive} to \constant{False}.
323+
If \var{exclude} is given it must be a function that takes one filename
324+
argument and returns a boolean value. Depending on this value the
325+
respective file is either excluded (\constant{True}) or added
326+
(\constant{False}).
327+
\versionchanged[Added the \var{exclude} parameter]{2.6}
324328
\end{methoddesc}
325329

326330
\begin{methoddesc}{addfile}{tarinfo\optional{, fileobj}}

Doc/lib/libwinreg.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ \section{\module{_winreg} --
321321
\var{key} is an already open key, or one of the predefined
322322
\constant{HKEY_*} constants.
323323

324-
\var{sub_key} is a string that names the subkey with which the
324+
\var{value_name} is a string that names the subkey with which the
325325
value is associated.
326326

327327
\var{type} is an integer that specifies the type of the data.

Lib/difflib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ def get_close_matches(word, possibilities, n=3, cutoff=0.6):
719719
>>> import keyword as _keyword
720720
>>> get_close_matches("wheel", _keyword.kwlist)
721721
['while']
722-
>>> get_close_matches("apple", _keyword.kwlist)
722+
>>> get_close_matches("Apple", _keyword.kwlist)
723723
[]
724724
>>> get_close_matches("accept", _keyword.kwlist)
725725
['except']

Lib/distutils/dir_util.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,12 @@ def create_tree (base_dir, files, mode=0o777, verbose=0, dry_run=0):
9696
for 'mkpath()'."""
9797

9898
# First get the list of directories to create
99-
need_dir = {}
99+
need_dir = set()
100100
for file in files:
101-
need_dir[os.path.join(base_dir, os.path.dirname(file))] = 1
102-
need_dirs = need_dir.keys()
103-
need_dirs.sort()
101+
need_dir.add(os.path.join(base_dir, os.path.dirname(file)))
104102

105103
# Now create them
106-
for dir in need_dirs:
104+
for dir in sorted(need_dir):
107105
mkpath(dir, mode, dry_run=dry_run)
108106

109107
# create_tree ()

Lib/keyword.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
kwlist = [
1616
#--start keywords--
17+
'False',
18+
'None',
19+
'True',
1720
'and',
1821
'as',
1922
'assert',

Lib/logging/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ def formatException(self, ei):
400400
traceback.print_exception(ei[0], ei[1], ei[2], None, sio)
401401
s = sio.getvalue()
402402
sio.close()
403-
if s[-1] == "\n":
403+
if s[-1:] == "\n":
404404
s = s[:-1]
405405
return s
406406

@@ -427,7 +427,7 @@ def format(self, record):
427427
if not record.exc_text:
428428
record.exc_text = self.formatException(record.exc_info)
429429
if record.exc_text:
430-
if s[-1] != "\n":
430+
if s[-1:] != "\n":
431431
s = s + "\n"
432432
s = s + record.exc_text
433433
return s

Lib/pydoc.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,17 +1748,16 @@ def intro(self):
17481748
''' % sys.version[:3])
17491749

17501750
def list(self, items, columns=4, width=80):
1751-
items = items[:]
1752-
items.sort()
1753-
colw = width / columns
1754-
rows = (len(items) + columns - 1) / columns
1751+
items = list(sorted(items))
1752+
colw = width // columns
1753+
rows = (len(items) + columns - 1) // columns
17551754
for row in range(rows):
17561755
for col in range(columns):
17571756
i = col * rows + row
17581757
if i < len(items):
17591758
self.output.write(items[i])
17601759
if col < columns - 1:
1761-
self.output.write(' ' + ' ' * (colw-1 - len(items[i])))
1760+
self.output.write(' ' + ' ' * (colw - 1 - len(items[i])))
17621761
self.output.write('\n')
17631762

17641763
def listkeywords(self):

Lib/tarfile.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1925,18 +1925,24 @@ def list(self, verbose=True):
19251925
print("link to", tarinfo.linkname, end=' ')
19261926
print()
19271927

1928-
def add(self, name, arcname=None, recursive=True):
1928+
def add(self, name, arcname=None, recursive=True, exclude=None):
19291929
"""Add the file `name' to the archive. `name' may be any type of file
19301930
(directory, fifo, symbolic link, etc.). If given, `arcname'
19311931
specifies an alternative name for the file in the archive.
19321932
Directories are added recursively by default. This can be avoided by
1933-
setting `recursive' to False.
1933+
setting `recursive' to False. `exclude' is a function that should
1934+
return True for each filename to be excluded.
19341935
"""
19351936
self._check("aw")
19361937

19371938
if arcname is None:
19381939
arcname = name
19391940

1941+
# Exclude pathnames.
1942+
if exclude is not None and exclude(name):
1943+
self._dbg(2, "tarfile: Excluded %r" % name)
1944+
return
1945+
19401946
# Skip if somebody tries to archive the archive...
19411947
if self.name is not None and os.path.abspath(name) == self.name:
19421948
self._dbg(2, "tarfile: Skipped %r" % name)
@@ -1949,7 +1955,7 @@ def add(self, name, arcname=None, recursive=True):
19491955
if arcname == ".":
19501956
arcname = ""
19511957
for f in os.listdir(name):
1952-
self.add(f, os.path.join(arcname, f))
1958+
self.add(f, os.path.join(arcname, f), recursive, exclude)
19531959
return
19541960

19551961
self._dbg(1, name)
@@ -1971,7 +1977,7 @@ def add(self, name, arcname=None, recursive=True):
19711977
self.addfile(tarinfo)
19721978
if recursive:
19731979
for f in os.listdir(name):
1974-
self.add(os.path.join(name, f), os.path.join(arcname, f))
1980+
self.add(os.path.join(name, f), os.path.join(arcname, f), recursive, exclude)
19751981

19761982
else:
19771983
self.addfile(tarinfo)

0 commit comments

Comments
 (0)