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

Skip to content

Commit 43b2f45

Browse files
committed
Merged revisions 87136,87221,87256,87337-87338,87571,87839,88164 via svnmerge from
svn+ssh://[email protected]/python/branches/py3k ........ r87136 | r.david.murray | 2010-12-08 17:53:00 -0500 (Wed, 08 Dec 2010) | 6 lines Have script_helper._assert_python strip refcount strings from stderr. This makes the output of the function and those that depend on it independent of whether or not they are being run under a debug build. ........ r87221 | r.david.murray | 2010-12-13 19:55:46 -0500 (Mon, 13 Dec 2010) | 4 lines #10699: fix docstring for tzset: it does not take a parameter Thanks to Garrett Cooper for the fix. ........ r87256 | r.david.murray | 2010-12-14 21:19:14 -0500 (Tue, 14 Dec 2010) | 2 lines #10705: document what the values of debuglevel are and mean. ........ r87337 | r.david.murray | 2010-12-17 11:11:40 -0500 (Fri, 17 Dec 2010) | 2 lines #10559: provide instructions for accessing sys.argv when first mentioned. ........ r87338 | r.david.murray | 2010-12-17 11:29:07 -0500 (Fri, 17 Dec 2010) | 2 lines #10454: clarify the compileall docs and help messages. [compileall.py changes not backported.] ........ r87571 | r.david.murray | 2010-12-29 14:06:48 -0500 (Wed, 29 Dec 2010) | 2 lines Fix same typo in docs. ........ r87839 | r.david.murray | 2011-01-07 16:57:25 -0500 (Fri, 07 Jan 2011) | 9 lines Fix formatting of values with embedded newlines when rfc2047 encoding Before this patch if a value being encoded had an embedded newline, the line following the newline would have no leading whitespace, and the whitespace it did have was encoded into the word. Now the existing whitespace gets turned into a blank, the way it does in other header reformatting, and the _continuation_ws gets added at the beginning of the encoded line. ........ r88164 | r.david.murray | 2011-01-24 14:34:58 -0500 (Mon, 24 Jan 2011) | 12 lines #10960: fix 'stat' links, link to lstat from stat, general tidy of stat doc. Original patch by Michal Nowikowski, with some additions and wording fixes by me. I changed the wording from 'Performs a stat system call' to 'Performs the equivalent of a stat system call', since on Windows there are no stat/lstat system calls involved. I also extended Michal's breakout of the attributes into a list to the other paragraphs, and rearranged the order of the paragraphs in the 'stat' docs to make it flow better and put it in what I think is a more logical/useful order. ........
1 parent d71c4e9 commit 43b2f45

11 files changed

Lines changed: 129 additions & 63 deletions

File tree

Doc/ACKS.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ [email protected]), and we'll be glad to correct the problem.
139139
* Ross Moore
140140
* Sjoerd Mullender
141141
* Dale Nagata
142+
* Michal Nowikowski
142143
* Ng Pheng Siong
143144
* Koray Oner
144145
* Tomas Oppelstrup

Doc/library/compileall.rst

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66

77

88
This module provides some utility functions to support installing Python
9-
libraries. These functions compile Python source files in a directory tree,
10-
allowing users without permission to write to the libraries to take advantage of
11-
cached byte-code files.
9+
libraries. These functions compile Python source files in a directory tree.
10+
This module can be used to create the cached byte-code files at library
11+
installation time, which makes them available for use even by users who don't
12+
have write permission to the library directories.
1213

1314

1415
Command-line use
@@ -27,23 +28,29 @@ compile Python sources.
2728

2829
.. cmdoption:: -l
2930

30-
Do not recurse.
31+
Do not recurse into subdirectories, only compile source code files directly
32+
contained in the named or implied directories.
3133

3234
.. cmdoption:: -f
3335

3436
Force rebuild even if timestamps are up-to-date.
3537

3638
.. cmdoption:: -q
3739

38-
Do not print the list of files compiled.
40+
Do not print the list of files compiled, print only error messages.
3941

4042
.. cmdoption:: -d destdir
4143

42-
Purported directory name for error messages.
44+
Directory prepended to the path to each file being compiled. This will
45+
appear in compilation time tracebacks, and is also compiled in to the
46+
byte-code file, where it will be used in tracebacks and other messages in
47+
cases where the source file does not exist at the time the byte-code file is
48+
executed.
4349

4450
.. cmdoption:: -x regex
4551

46-
Skip files with a full path that matches given regular expression.
52+
regex is used to search the full path to each file considered for
53+
compilation, and if the regex produces a match, the file is skipped.
4754

4855

4956
Public functions
@@ -52,24 +59,34 @@ Public functions
5259
.. function:: compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None, quiet=False)
5360

5461
Recursively descend the directory tree named by *dir*, compiling all :file:`.py`
55-
files along the way. The *maxlevels* parameter is used to limit the depth of
56-
the recursion; it defaults to ``10``. If *ddir* is given, it is used as the
57-
base path from which the filenames used in error messages will be generated.
62+
files along the way.
63+
64+
The *maxlevels* parameter is used to limit the depth of the recursion; it
65+
defaults to ``10``.
66+
67+
If *ddir* is given, it is prepended to the path to each file being compiled
68+
for use in compilation time tracebacks, and is also compiled in to the
69+
byte-code file, where it will be used in tracebacks and other messages in
70+
cases where the source file does not exist at the time the byte-code file is
71+
executed.
72+
5873
If *force* is true, modules are re-compiled even if the timestamps are up to
5974
date.
6075

61-
If *rx* is given, it specifies a regular expression of file names to exclude
62-
from the search; that expression is searched for in the full path.
76+
If *rx* is given, its search method is called on the complete path to each
77+
file considered for compilation, and if it returns a true value, the file
78+
is skipped.
6379

64-
If *quiet* is true, nothing is printed to the standard output in normal
65-
operation.
80+
If *quiet* is true, nothing is printed to the standard output unless errors
81+
occur.
6682

6783
.. function:: compile_path(skip_curdir=True, maxlevels=0, force=False)
6884

6985
Byte-compile all the :file:`.py` files found along ``sys.path``. If
70-
*skip_curdir* is true (the default), the current directory is not included in
71-
the search. The *maxlevels* and *force* parameters default to ``0`` and are
72-
passed to the :func:`compile_dir` function.
86+
*skip_curdir* is true (the default), the current directory is not included
87+
in the search. All other parameters are passed to the :func:`compile_dir`
88+
function. Note that unlike the other compile functions, ``maxlevels``
89+
defaults to ``0``.
7390

7491
To force a recompile of all the :file:`.py` files in the :file:`Lib/`
7592
subdirectory and all its subdirectories::

Doc/library/email.header.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Here is the :class:`Header` class description:
6363
character set is used both as *s*'s initial charset and as the default for
6464
subsequent :meth:`append` calls.
6565

66-
The maximum line length can be specified explicit via *maxlinelen*. For
66+
The maximum line length can be specified explicitly via *maxlinelen*. For
6767
splitting the first line to a shorter value (to account for the field header
6868
which isn't included in *s*, e.g. :mailheader:`Subject`) pass in the name of the
6969
field in *header_name*. The default *maxlinelen* is 76, and the default value

Doc/library/http.client.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,10 @@ HTTPConnection Objects
381381

382382
.. method:: HTTPConnection.set_debuglevel(level)
383383

384-
Set the debugging level (the amount of debugging output printed). The default
385-
debug level is ``0``, meaning no debugging output is printed.
384+
Set the debugging level. The default debug level is ``0``, meaning no
385+
debugging output is printed. Any value greater than ``0`` will cause all
386+
currently defined debug output to be printed to stdout. The ``debuglevel``
387+
is passed to any new :class:`HTTPResponse` objects that are created.
386388

387389
.. versionadded:: 3.1
388390

Doc/library/os.rst

Lines changed: 55 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ as internal buffering of data.
534534

535535
.. function:: fstat(fd)
536536

537-
Return status for file descriptor *fd*, like :func:`stat`.
537+
Return status for file descriptor *fd*, like :func:`~os.stat`.
538538

539539
Availability: Unix, Windows.
540540

@@ -952,9 +952,10 @@ Files and Directories
952952

953953
.. function:: lstat(path)
954954

955-
Like :func:`stat`, but do not follow symbolic links. This is an alias for
956-
:func:`stat` on platforms that do not support symbolic links, such as
957-
Windows.
955+
Perform the equivalent of an :c:func:`lstat` system call on the given path.
956+
Similar to :func:`~os.stat`, but does not follow symbolic links. On
957+
platforms that do not support symbolic links, this is an alias for
958+
:func:`~os.stat`.
958959

959960

960961
.. function:: mkfifo(path[, mode])
@@ -1138,64 +1139,81 @@ Files and Directories
11381139

11391140
.. function:: stat(path)
11401141

1141-
Perform a :cfunc:`stat` system call on the given path. The return value is an
1142-
object whose attributes correspond to the members of the :ctype:`stat`
1143-
structure, namely: :attr:`st_mode` (protection bits), :attr:`st_ino` (inode
1144-
number), :attr:`st_dev` (device), :attr:`st_nlink` (number of hard links),
1145-
:attr:`st_uid` (user id of owner), :attr:`st_gid` (group id of owner),
1146-
:attr:`st_size` (size of file, in bytes), :attr:`st_atime` (time of most recent
1147-
access), :attr:`st_mtime` (time of most recent content modification),
1148-
:attr:`st_ctime` (platform dependent; time of most recent metadata change on
1149-
Unix, or the time of creation on Windows)::
1142+
Perform the equivalent of a :c:func:`stat` system call on the given path.
1143+
(This function follows symlinks; to stat a symlink use :func:`lstat`.)
11501144

1151-
>>> import os
1152-
>>> statinfo = os.stat('somefile.txt')
1153-
>>> statinfo
1154-
(33188, 422511, 769, 1, 1032, 100, 926, 1105022698,1105022732, 1105022732)
1155-
>>> statinfo.st_size
1156-
926
1157-
>>>
1145+
The return value is an object whose attributes correspond to the members
1146+
of the :c:type:`stat` structure, namely:
11581147

1148+
* :attr:`st_mode` - protection bits,
1149+
* :attr:`st_ino` - inode number,
1150+
* :attr:`st_dev` - device,
1151+
* :attr:`st_nlink` - number of hard links,
1152+
* :attr:`st_uid` - user id of owner,
1153+
* :attr:`st_gid` - group id of owner,
1154+
* :attr:`st_size` - size of file, in bytes,
1155+
* :attr:`st_atime` - time of most recent access,
1156+
* :attr:`st_mtime` - time of most recent content modification,
1157+
* :attr:`st_ctime` - platform dependent; time of most recent metadata change on
1158+
Unix, or the time of creation on Windows)
11591159

11601160
On some Unix systems (such as Linux), the following attributes may also be
1161-
available: :attr:`st_blocks` (number of blocks allocated for file),
1162-
:attr:`st_blksize` (filesystem blocksize), :attr:`st_rdev` (type of device if an
1163-
inode device). :attr:`st_flags` (user defined flags for file).
1161+
available:
1162+
1163+
* :attr:`st_blocks` - number of blocks allocated for file
1164+
* :attr:`st_blksize` - filesystem blocksize
1165+
* :attr:`st_rdev` - type of device if an inode device
1166+
* :attr:`st_flags` - user defined flags for file
11641167

11651168
On other Unix systems (such as FreeBSD), the following attributes may be
1166-
available (but may be only filled out if root tries to use them): :attr:`st_gen`
1167-
(file generation number), :attr:`st_birthtime` (time of file creation).
1169+
available (but may be only filled out if root tries to use them):
1170+
1171+
* :attr:`st_gen` - file generation number
1172+
* :attr:`st_birthtime` - time of file creation
11681173

11691174
On Mac OS systems, the following attributes may also be available:
1170-
:attr:`st_rsize`, :attr:`st_creator`, :attr:`st_type`.
11711175

1172-
.. index:: module: stat
1176+
* :attr:`st_rsize`
1177+
* :attr:`st_creator`
1178+
* :attr:`st_type`
1179+
1180+
.. note::
1181+
1182+
The exact meaning and resolution of the :attr:`st_atime`, :attr:`st_mtime`, and
1183+
:attr:`st_ctime` members depends on the operating system and the file system.
1184+
For example, on Windows systems using the FAT or FAT32 file systems,
1185+
:attr:`st_mtime` has 2-second resolution, and :attr:`st_atime` has only 1-day
1186+
resolution. See your operating system documentation for details.
11731187

1174-
For backward compatibility, the return value of :func:`stat` is also accessible
1188+
For backward compatibility, the return value of :func:`~os.stat` is also accessible
11751189
as a tuple of at least 10 integers giving the most important (and portable)
11761190
members of the :ctype:`stat` structure, in the order :attr:`st_mode`,
11771191
:attr:`st_ino`, :attr:`st_dev`, :attr:`st_nlink`, :attr:`st_uid`,
11781192
:attr:`st_gid`, :attr:`st_size`, :attr:`st_atime`, :attr:`st_mtime`,
11791193
:attr:`st_ctime`. More items may be added at the end by some implementations.
1194+
1195+
.. index:: module: stat
1196+
11801197
The standard module :mod:`stat` defines functions and constants that are useful
11811198
for extracting information from a :ctype:`stat` structure. (On Windows, some
11821199
items are filled with dummy values.)
11831200

1184-
.. note::
1201+
Example::
11851202

1186-
The exact meaning and resolution of the :attr:`st_atime`, :attr:`st_mtime`, and
1187-
:attr:`st_ctime` members depends on the operating system and the file system.
1188-
For example, on Windows systems using the FAT or FAT32 file systems,
1189-
:attr:`st_mtime` has 2-second resolution, and :attr:`st_atime` has only 1-day
1190-
resolution. See your operating system documentation for details.
1203+
>>> import os
1204+
>>> statinfo = os.stat('somefile.txt')
1205+
>>> statinfo
1206+
(33188, 422511, 769, 1, 1032, 100, 926, 1105022698,1105022732, 1105022732)
1207+
>>> statinfo.st_size
1208+
926
11911209

11921210
Availability: Unix, Windows.
11931211

11941212

11951213
.. function:: stat_float_times([newvalue])
11961214

11971215
Determine whether :class:`stat_result` represents time stamps as float objects.
1198-
If *newvalue* is ``True``, future calls to :func:`stat` return floats, if it is
1216+
If *newvalue* is ``True``, future calls to :func:`~os.stat` return floats, if it is
11991217
``False``, future calls return ints. If *newvalue* is omitted, return the
12001218
current setting.
12011219

@@ -1255,8 +1273,8 @@ Files and Directories
12551273
respectively. Whether a directory can be given for *path* depends on whether
12561274
the operating system implements directories as files (for example, Windows
12571275
does not). Note that the exact times you set here may not be returned by a
1258-
subsequent :func:`stat` call, depending on the resolution with which your
1259-
operating system records access and modification times; see :func:`stat`.
1276+
subsequent :func:`~os.stat` call, depending on the resolution with which your
1277+
operating system records access and modification times; see :func:`~os.stat`.
12601278

12611279
Availability: Unix, Windows.
12621280

Doc/tutorial/interpreter.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ Argument Passing
7878
----------------
7979

8080
When known to the interpreter, the script name and additional arguments
81-
thereafter are passed to the script in the variable ``sys.argv``, which is a
82-
list of strings. Its length is at least one; when no script and no arguments
81+
thereafter are turned into a list of strings and assigned to the ``argv``
82+
variable in the ``sys`` module. You can access this list by executing ``import
83+
sys``. The length of the list is at least one; when no script and no arguments
8384
are given, ``sys.argv[0]`` is an empty string. When the script name is given as
8485
``'-'`` (meaning standard input), ``sys.argv[0]`` is set to ``'-'``. When
8586
:option:`-c` *command* is used, ``sys.argv[0]`` is set to ``'-c'``. When

Lib/email/header.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,15 @@ def encode(self, splitchars=';, \t', maxlinelen=None):
304304
self._continuation_ws, splitchars)
305305
for string, charset in self._chunks:
306306
lines = string.splitlines()
307-
for line in lines:
307+
formatter.feed(lines[0], charset)
308+
for line in lines[1:]:
309+
formatter.newline()
310+
if charset.header_encoding is not None:
311+
formatter.feed(self._continuation_ws, USASCII)
312+
line = ' ' + line.lstrip()
308313
formatter.feed(line, charset)
309-
if len(lines) > 1:
310-
formatter.newline()
314+
if len(lines) > 1:
315+
formatter.newline()
311316
formatter.add_transition()
312317
value = str(formatter)
313318
if _embeded_header.search(value):

Lib/email/test/test_email.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import difflib
1010
import unittest
1111
import warnings
12+
import textwrap
1213

1314
from io import StringIO
1415
from itertools import chain
@@ -959,6 +960,19 @@ def test_long_lines_with_different_header(self):
959960
960961
""")
961962

963+
def test_long_rfc2047_header_with_embedded_fws(self):
964+
h = Header(textwrap.dedent("""\
965+
We're going to pretend this header is in a non-ascii character set
966+
\tto see if line wrapping with encoded words and embedded
967+
folding white space works"""),
968+
charset='utf-8',
969+
header_name='Test')
970+
self.assertEqual(h.encode()+'\n', textwrap.dedent("""\
971+
=?utf-8?q?We=27re_going_to_pretend_this_header_is_in_a_non-ascii_chara?=
972+
=?utf-8?q?cter_set?=
973+
=?utf-8?q?_to_see_if_line_wrapping_with_encoded_words_and_embedded?=
974+
=?utf-8?q?_folding_white_space_works?=""")+'\n')
975+
962976

963977

964978
# Test mangling of "From " lines in the body of a message

Lib/test/script_helper.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import sys
55
import os
6+
import re
67
import os.path
78
import tempfile
89
import subprocess
@@ -11,6 +12,7 @@
1112
import shutil
1213
import zipfile
1314

15+
from test.support import strip_python_stderr
1416

1517
# Executing the interpreter in a subprocess
1618
def _assert_python(expected_success, *args, **env_vars):
@@ -32,6 +34,7 @@ def _assert_python(expected_success, *args, **env_vars):
3234
p.stdout.close()
3335
p.stderr.close()
3436
rc = p.returncode
37+
err = strip_python_stderr(err)
3538
if (rc and expected_success) or (not rc and not expected_success):
3639
raise AssertionError(
3740
"Process return code is %d, "

Misc/NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ Core and Builtins
3737
Library
3838
-------
3939

40+
- email.header.Header was incorrectly encoding folding white space when
41+
rfc2047-encoding header values with embedded newlines, leaving them
42+
without folding whitespace. It now uses the continuation_ws, as it
43+
does for continuation lines that it creates itself.
44+
4045
- Issue #11110: Fix _sqlite to not deref a NULL when module creation fails.
4146

4247
- Issue #11089: Fix performance issue limiting the use of ConfigParser()

0 commit comments

Comments
 (0)