mirror of https://github.com/python/cpython
Merged revisions 87136,87221,87256,87337-87338,87571,87839,88164 via svnmerge from
svn+ssh://pythondev@svn.python.org/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. ........
This commit is contained in:
parent
d71c4e9d13
commit
43b2f457a0
|
@ -139,6 +139,7 @@ docs@python.org), and we'll be glad to correct the problem.
|
|||
* Ross Moore
|
||||
* Sjoerd Mullender
|
||||
* Dale Nagata
|
||||
* Michal Nowikowski
|
||||
* Ng Pheng Siong
|
||||
* Koray Oner
|
||||
* Tomas Oppelstrup
|
||||
|
|
|
@ -6,9 +6,10 @@
|
|||
|
||||
|
||||
This module provides some utility functions to support installing Python
|
||||
libraries. These functions compile Python source files in a directory tree,
|
||||
allowing users without permission to write to the libraries to take advantage of
|
||||
cached byte-code files.
|
||||
libraries. These functions compile Python source files in a directory tree.
|
||||
This module can be used to create the cached byte-code files at library
|
||||
installation time, which makes them available for use even by users who don't
|
||||
have write permission to the library directories.
|
||||
|
||||
|
||||
Command-line use
|
||||
|
@ -27,7 +28,8 @@ compile Python sources.
|
|||
|
||||
.. cmdoption:: -l
|
||||
|
||||
Do not recurse.
|
||||
Do not recurse into subdirectories, only compile source code files directly
|
||||
contained in the named or implied directories.
|
||||
|
||||
.. cmdoption:: -f
|
||||
|
||||
|
@ -35,15 +37,20 @@ compile Python sources.
|
|||
|
||||
.. cmdoption:: -q
|
||||
|
||||
Do not print the list of files compiled.
|
||||
Do not print the list of files compiled, print only error messages.
|
||||
|
||||
.. cmdoption:: -d destdir
|
||||
|
||||
Purported directory name for error messages.
|
||||
Directory prepended to the path to each file being compiled. This will
|
||||
appear in compilation time tracebacks, and is also compiled in to the
|
||||
byte-code file, where it will be used in tracebacks and other messages in
|
||||
cases where the source file does not exist at the time the byte-code file is
|
||||
executed.
|
||||
|
||||
.. cmdoption:: -x regex
|
||||
|
||||
Skip files with a full path that matches given regular expression.
|
||||
regex is used to search the full path to each file considered for
|
||||
compilation, and if the regex produces a match, the file is skipped.
|
||||
|
||||
|
||||
Public functions
|
||||
|
@ -52,24 +59,34 @@ Public functions
|
|||
.. function:: compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None, quiet=False)
|
||||
|
||||
Recursively descend the directory tree named by *dir*, compiling all :file:`.py`
|
||||
files along the way. The *maxlevels* parameter is used to limit the depth of
|
||||
the recursion; it defaults to ``10``. If *ddir* is given, it is used as the
|
||||
base path from which the filenames used in error messages will be generated.
|
||||
files along the way.
|
||||
|
||||
The *maxlevels* parameter is used to limit the depth of the recursion; it
|
||||
defaults to ``10``.
|
||||
|
||||
If *ddir* is given, it is prepended to the path to each file being compiled
|
||||
for use in compilation time tracebacks, and is also compiled in to the
|
||||
byte-code file, where it will be used in tracebacks and other messages in
|
||||
cases where the source file does not exist at the time the byte-code file is
|
||||
executed.
|
||||
|
||||
If *force* is true, modules are re-compiled even if the timestamps are up to
|
||||
date.
|
||||
|
||||
If *rx* is given, it specifies a regular expression of file names to exclude
|
||||
from the search; that expression is searched for in the full path.
|
||||
If *rx* is given, its search method is called on the complete path to each
|
||||
file considered for compilation, and if it returns a true value, the file
|
||||
is skipped.
|
||||
|
||||
If *quiet* is true, nothing is printed to the standard output in normal
|
||||
operation.
|
||||
If *quiet* is true, nothing is printed to the standard output unless errors
|
||||
occur.
|
||||
|
||||
.. function:: compile_path(skip_curdir=True, maxlevels=0, force=False)
|
||||
|
||||
Byte-compile all the :file:`.py` files found along ``sys.path``. If
|
||||
*skip_curdir* is true (the default), the current directory is not included in
|
||||
the search. The *maxlevels* and *force* parameters default to ``0`` and are
|
||||
passed to the :func:`compile_dir` function.
|
||||
*skip_curdir* is true (the default), the current directory is not included
|
||||
in the search. All other parameters are passed to the :func:`compile_dir`
|
||||
function. Note that unlike the other compile functions, ``maxlevels``
|
||||
defaults to ``0``.
|
||||
|
||||
To force a recompile of all the :file:`.py` files in the :file:`Lib/`
|
||||
subdirectory and all its subdirectories::
|
||||
|
|
|
@ -63,7 +63,7 @@ Here is the :class:`Header` class description:
|
|||
character set is used both as *s*'s initial charset and as the default for
|
||||
subsequent :meth:`append` calls.
|
||||
|
||||
The maximum line length can be specified explicit via *maxlinelen*. For
|
||||
The maximum line length can be specified explicitly via *maxlinelen*. For
|
||||
splitting the first line to a shorter value (to account for the field header
|
||||
which isn't included in *s*, e.g. :mailheader:`Subject`) pass in the name of the
|
||||
field in *header_name*. The default *maxlinelen* is 76, and the default value
|
||||
|
|
|
@ -381,8 +381,10 @@ HTTPConnection Objects
|
|||
|
||||
.. method:: HTTPConnection.set_debuglevel(level)
|
||||
|
||||
Set the debugging level (the amount of debugging output printed). The default
|
||||
debug level is ``0``, meaning no debugging output is printed.
|
||||
Set the debugging level. The default debug level is ``0``, meaning no
|
||||
debugging output is printed. Any value greater than ``0`` will cause all
|
||||
currently defined debug output to be printed to stdout. The ``debuglevel``
|
||||
is passed to any new :class:`HTTPResponse` objects that are created.
|
||||
|
||||
.. versionadded:: 3.1
|
||||
|
||||
|
|
|
@ -534,7 +534,7 @@ as internal buffering of data.
|
|||
|
||||
.. function:: fstat(fd)
|
||||
|
||||
Return status for file descriptor *fd*, like :func:`stat`.
|
||||
Return status for file descriptor *fd*, like :func:`~os.stat`.
|
||||
|
||||
Availability: Unix, Windows.
|
||||
|
||||
|
@ -952,9 +952,10 @@ Files and Directories
|
|||
|
||||
.. function:: lstat(path)
|
||||
|
||||
Like :func:`stat`, but do not follow symbolic links. This is an alias for
|
||||
:func:`stat` on platforms that do not support symbolic links, such as
|
||||
Windows.
|
||||
Perform the equivalent of an :c:func:`lstat` system call on the given path.
|
||||
Similar to :func:`~os.stat`, but does not follow symbolic links. On
|
||||
platforms that do not support symbolic links, this is an alias for
|
||||
:func:`~os.stat`.
|
||||
|
||||
|
||||
.. function:: mkfifo(path[, mode])
|
||||
|
@ -1138,48 +1139,43 @@ Files and Directories
|
|||
|
||||
.. function:: stat(path)
|
||||
|
||||
Perform a :cfunc:`stat` system call on the given path. The return value is an
|
||||
object whose attributes correspond to the members of the :ctype:`stat`
|
||||
structure, namely: :attr:`st_mode` (protection bits), :attr:`st_ino` (inode
|
||||
number), :attr:`st_dev` (device), :attr:`st_nlink` (number of hard links),
|
||||
:attr:`st_uid` (user id of owner), :attr:`st_gid` (group id of owner),
|
||||
:attr:`st_size` (size of file, in bytes), :attr:`st_atime` (time of most recent
|
||||
access), :attr:`st_mtime` (time of most recent content modification),
|
||||
:attr:`st_ctime` (platform dependent; time of most recent metadata change on
|
||||
Unix, or the time of creation on Windows)::
|
||||
Perform the equivalent of a :c:func:`stat` system call on the given path.
|
||||
(This function follows symlinks; to stat a symlink use :func:`lstat`.)
|
||||
|
||||
>>> import os
|
||||
>>> statinfo = os.stat('somefile.txt')
|
||||
>>> statinfo
|
||||
(33188, 422511, 769, 1, 1032, 100, 926, 1105022698,1105022732, 1105022732)
|
||||
>>> statinfo.st_size
|
||||
926
|
||||
>>>
|
||||
The return value is an object whose attributes correspond to the members
|
||||
of the :c:type:`stat` structure, namely:
|
||||
|
||||
* :attr:`st_mode` - protection bits,
|
||||
* :attr:`st_ino` - inode number,
|
||||
* :attr:`st_dev` - device,
|
||||
* :attr:`st_nlink` - number of hard links,
|
||||
* :attr:`st_uid` - user id of owner,
|
||||
* :attr:`st_gid` - group id of owner,
|
||||
* :attr:`st_size` - size of file, in bytes,
|
||||
* :attr:`st_atime` - time of most recent access,
|
||||
* :attr:`st_mtime` - time of most recent content modification,
|
||||
* :attr:`st_ctime` - platform dependent; time of most recent metadata change on
|
||||
Unix, or the time of creation on Windows)
|
||||
|
||||
On some Unix systems (such as Linux), the following attributes may also be
|
||||
available: :attr:`st_blocks` (number of blocks allocated for file),
|
||||
:attr:`st_blksize` (filesystem blocksize), :attr:`st_rdev` (type of device if an
|
||||
inode device). :attr:`st_flags` (user defined flags for file).
|
||||
available:
|
||||
|
||||
* :attr:`st_blocks` - number of blocks allocated for file
|
||||
* :attr:`st_blksize` - filesystem blocksize
|
||||
* :attr:`st_rdev` - type of device if an inode device
|
||||
* :attr:`st_flags` - user defined flags for file
|
||||
|
||||
On other Unix systems (such as FreeBSD), the following attributes may be
|
||||
available (but may be only filled out if root tries to use them): :attr:`st_gen`
|
||||
(file generation number), :attr:`st_birthtime` (time of file creation).
|
||||
available (but may be only filled out if root tries to use them):
|
||||
|
||||
* :attr:`st_gen` - file generation number
|
||||
* :attr:`st_birthtime` - time of file creation
|
||||
|
||||
On Mac OS systems, the following attributes may also be available:
|
||||
:attr:`st_rsize`, :attr:`st_creator`, :attr:`st_type`.
|
||||
|
||||
.. index:: module: stat
|
||||
|
||||
For backward compatibility, the return value of :func:`stat` is also accessible
|
||||
as a tuple of at least 10 integers giving the most important (and portable)
|
||||
members of the :ctype:`stat` structure, in the order :attr:`st_mode`,
|
||||
:attr:`st_ino`, :attr:`st_dev`, :attr:`st_nlink`, :attr:`st_uid`,
|
||||
:attr:`st_gid`, :attr:`st_size`, :attr:`st_atime`, :attr:`st_mtime`,
|
||||
:attr:`st_ctime`. More items may be added at the end by some implementations.
|
||||
The standard module :mod:`stat` defines functions and constants that are useful
|
||||
for extracting information from a :ctype:`stat` structure. (On Windows, some
|
||||
items are filled with dummy values.)
|
||||
* :attr:`st_rsize`
|
||||
* :attr:`st_creator`
|
||||
* :attr:`st_type`
|
||||
|
||||
.. note::
|
||||
|
||||
|
@ -1189,13 +1185,35 @@ Files and Directories
|
|||
:attr:`st_mtime` has 2-second resolution, and :attr:`st_atime` has only 1-day
|
||||
resolution. See your operating system documentation for details.
|
||||
|
||||
For backward compatibility, the return value of :func:`~os.stat` is also accessible
|
||||
as a tuple of at least 10 integers giving the most important (and portable)
|
||||
members of the :ctype:`stat` structure, in the order :attr:`st_mode`,
|
||||
:attr:`st_ino`, :attr:`st_dev`, :attr:`st_nlink`, :attr:`st_uid`,
|
||||
:attr:`st_gid`, :attr:`st_size`, :attr:`st_atime`, :attr:`st_mtime`,
|
||||
:attr:`st_ctime`. More items may be added at the end by some implementations.
|
||||
|
||||
.. index:: module: stat
|
||||
|
||||
The standard module :mod:`stat` defines functions and constants that are useful
|
||||
for extracting information from a :ctype:`stat` structure. (On Windows, some
|
||||
items are filled with dummy values.)
|
||||
|
||||
Example::
|
||||
|
||||
>>> import os
|
||||
>>> statinfo = os.stat('somefile.txt')
|
||||
>>> statinfo
|
||||
(33188, 422511, 769, 1, 1032, 100, 926, 1105022698,1105022732, 1105022732)
|
||||
>>> statinfo.st_size
|
||||
926
|
||||
|
||||
Availability: Unix, Windows.
|
||||
|
||||
|
||||
.. function:: stat_float_times([newvalue])
|
||||
|
||||
Determine whether :class:`stat_result` represents time stamps as float objects.
|
||||
If *newvalue* is ``True``, future calls to :func:`stat` return floats, if it is
|
||||
If *newvalue* is ``True``, future calls to :func:`~os.stat` return floats, if it is
|
||||
``False``, future calls return ints. If *newvalue* is omitted, return the
|
||||
current setting.
|
||||
|
||||
|
@ -1255,8 +1273,8 @@ Files and Directories
|
|||
respectively. Whether a directory can be given for *path* depends on whether
|
||||
the operating system implements directories as files (for example, Windows
|
||||
does not). Note that the exact times you set here may not be returned by a
|
||||
subsequent :func:`stat` call, depending on the resolution with which your
|
||||
operating system records access and modification times; see :func:`stat`.
|
||||
subsequent :func:`~os.stat` call, depending on the resolution with which your
|
||||
operating system records access and modification times; see :func:`~os.stat`.
|
||||
|
||||
Availability: Unix, Windows.
|
||||
|
||||
|
|
|
@ -78,8 +78,9 @@ Argument Passing
|
|||
----------------
|
||||
|
||||
When known to the interpreter, the script name and additional arguments
|
||||
thereafter are passed to the script in the variable ``sys.argv``, which is a
|
||||
list of strings. Its length is at least one; when no script and no arguments
|
||||
thereafter are turned into a list of strings and assigned to the ``argv``
|
||||
variable in the ``sys`` module. You can access this list by executing ``import
|
||||
sys``. The length of the list is at least one; when no script and no arguments
|
||||
are given, ``sys.argv[0]`` is an empty string. When the script name is given as
|
||||
``'-'`` (meaning standard input), ``sys.argv[0]`` is set to ``'-'``. When
|
||||
:option:`-c` *command* is used, ``sys.argv[0]`` is set to ``'-c'``. When
|
||||
|
|
|
@ -304,10 +304,15 @@ class Header:
|
|||
self._continuation_ws, splitchars)
|
||||
for string, charset in self._chunks:
|
||||
lines = string.splitlines()
|
||||
for line in lines:
|
||||
formatter.feed(lines[0], charset)
|
||||
for line in lines[1:]:
|
||||
formatter.newline()
|
||||
if charset.header_encoding is not None:
|
||||
formatter.feed(self._continuation_ws, USASCII)
|
||||
line = ' ' + line.lstrip()
|
||||
formatter.feed(line, charset)
|
||||
if len(lines) > 1:
|
||||
formatter.newline()
|
||||
if len(lines) > 1:
|
||||
formatter.newline()
|
||||
formatter.add_transition()
|
||||
value = str(formatter)
|
||||
if _embeded_header.search(value):
|
||||
|
|
|
@ -9,6 +9,7 @@ import base64
|
|||
import difflib
|
||||
import unittest
|
||||
import warnings
|
||||
import textwrap
|
||||
|
||||
from io import StringIO
|
||||
from itertools import chain
|
||||
|
@ -959,6 +960,19 @@ List: List-Unsubscribe: <http://lists.sourceforge.net/lists/listinfo/spamassassi
|
|||
|
||||
""")
|
||||
|
||||
def test_long_rfc2047_header_with_embedded_fws(self):
|
||||
h = Header(textwrap.dedent("""\
|
||||
We're going to pretend this header is in a non-ascii character set
|
||||
\tto see if line wrapping with encoded words and embedded
|
||||
folding white space works"""),
|
||||
charset='utf-8',
|
||||
header_name='Test')
|
||||
self.assertEqual(h.encode()+'\n', textwrap.dedent("""\
|
||||
=?utf-8?q?We=27re_going_to_pretend_this_header_is_in_a_non-ascii_chara?=
|
||||
=?utf-8?q?cter_set?=
|
||||
=?utf-8?q?_to_see_if_line_wrapping_with_encoded_words_and_embedded?=
|
||||
=?utf-8?q?_folding_white_space_works?=""")+'\n')
|
||||
|
||||
|
||||
|
||||
# Test mangling of "From " lines in the body of a message
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
import os.path
|
||||
import tempfile
|
||||
import subprocess
|
||||
|
@ -11,6 +12,7 @@ import contextlib
|
|||
import shutil
|
||||
import zipfile
|
||||
|
||||
from test.support import strip_python_stderr
|
||||
|
||||
# Executing the interpreter in a subprocess
|
||||
def _assert_python(expected_success, *args, **env_vars):
|
||||
|
@ -32,6 +34,7 @@ def _assert_python(expected_success, *args, **env_vars):
|
|||
p.stdout.close()
|
||||
p.stderr.close()
|
||||
rc = p.returncode
|
||||
err = strip_python_stderr(err)
|
||||
if (rc and expected_success) or (not rc and not expected_success):
|
||||
raise AssertionError(
|
||||
"Process return code is %d, "
|
||||
|
|
|
@ -37,6 +37,11 @@ Core and Builtins
|
|||
Library
|
||||
-------
|
||||
|
||||
- email.header.Header was incorrectly encoding folding white space when
|
||||
rfc2047-encoding header values with embedded newlines, leaving them
|
||||
without folding whitespace. It now uses the continuation_ws, as it
|
||||
does for continuation lines that it creates itself.
|
||||
|
||||
- Issue #11110: Fix _sqlite to not deref a NULL when module creation fails.
|
||||
|
||||
- Issue #11089: Fix performance issue limiting the use of ConfigParser()
|
||||
|
|
|
@ -742,7 +742,7 @@ time_tzset(PyObject *self, PyObject *unused)
|
|||
}
|
||||
|
||||
PyDoc_STRVAR(tzset_doc,
|
||||
"tzset(zone)\n\
|
||||
"tzset()\n\
|
||||
\n\
|
||||
Initialize, or reinitialize, the local timezone to the value stored in\n\
|
||||
os.environ['TZ']. The TZ environment variable should be specified in\n\
|
||||
|
|
Loading…
Reference in New Issue