Skip to content

Commit 561b96f

Browse files
committed
Merged revisions 86542,87136,87216,87221,87228,87256,87337-87338,87372,87516,87571,88164 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r86542 | r.david.murray | 2010-11-19 22:48:58 -0500 (Fri, 19 Nov 2010) | 2 lines Make test class name unique so that both test classes run. ........ 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. ........ r87216 | r.david.murray | 2010-12-13 17:50:30 -0500 (Mon, 13 Dec 2010) | 2 lines python#10698: fix typo in example. ........ r87221 | r.david.murray | 2010-12-13 19:55:46 -0500 (Mon, 13 Dec 2010) | 4 lines python#10699: fix docstring for tzset: it does not take a parameter Thanks to Garrett Cooper for the fix. ........ r87228 | r.david.murray | 2010-12-13 21:25:43 -0500 (Mon, 13 Dec 2010) | 2 lines Turn on regrtest -W (rerun immediately) option for Windows, too. ........ r87256 | r.david.murray | 2010-12-14 21:19:14 -0500 (Tue, 14 Dec 2010) | 2 lines python#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 python#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 python#10454: clarify the compileall docs and help messages. [changes to compileall.py were not backported, only the doc changes] ........ r87372 | r.david.murray | 2010-12-18 11:39:06 -0500 (Sat, 18 Dec 2010) | 2 lines python#10728: the default for printing help is sys.stdout, not stderr. ........ r87516 | r.david.murray | 2010-12-27 15:09:32 -0500 (Mon, 27 Dec 2010) | 5 lines python#7056: runtest and runtest_inner don't use testdir, so drop it from their sigs I've only tested regular runs and -j runs. If I've broken anything else I'm sure I'll hear about it sooner or later. ........ r87571 | r.david.murray | 2010-12-29 14:06:48 -0500 (Wed, 29 Dec 2010) | 2 lines Fix same typo in docs. ........ r88164 | r.david.murray | 2011-01-24 14:34:58 -0500 (Mon, 24 Jan 2011) | 12 lines python#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 730d12f commit 561b96f

12 files changed

Lines changed: 133 additions & 88 deletions

File tree

Doc/ACKS.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ docs@python.org), and we'll be glad to correct the problem.
137137
* Ross Moore
138138
* Sjoerd Mullender
139139
* Dale Nagata
140+
* Michal Nowikowski
140141
* Ng Pheng Siong
141142
* Koray Oner
142143
* Tomas Oppelstrup

Doc/library/argparse.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,14 +1654,14 @@ are available:
16541654
.. method:: ArgumentParser.print_usage(file=None)
16551655

16561656
Print a brief description of how the :class:`ArgumentParser` should be
1657-
invoked on the command line. If *file* is ``None``, :data:`sys.stderr` is
1657+
invoked on the command line. If *file* is ``None``, :data:`sys.stdout` is
16581658
assumed.
16591659

16601660
.. method:: ArgumentParser.print_help(file=None)
16611661

16621662
Print a help message, including the program usage and information about the
16631663
arguments registered with the :class:`ArgumentParser`. If *file* is
1664-
``None``, :data:`sys.stderr` is assumed.
1664+
``None``, :data:`sys.stdout` is assumed.
16651665

16661666
There are also variants of these methods that simply return a string instead of
16671667
printing it:

Doc/library/compileall.rst

Lines changed: 49 additions & 26 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,27 +28,35 @@ 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
.. cmdoption:: -i list
4956

50-
Expand list with its content (file and directory names).
57+
Read the file ``list`` and add each line that it contains to the list of
58+
files and directories to compile. If ``list`` is ``-``, read lines from
59+
``stdin``.
5160

5261
.. versionchanged:: 2.7
5362
Added the ``-i`` option.
@@ -59,41 +68,55 @@ Public functions
5968
.. function:: compile_dir(dir[, maxlevels[, ddir[, force[, rx[, quiet]]]]])
6069

6170
Recursively descend the directory tree named by *dir*, compiling all :file:`.py`
62-
files along the way. The *maxlevels* parameter is used to limit the depth of
63-
the recursion; it defaults to ``10``. If *ddir* is given, it is used as the
64-
base path from which the filenames used in error messages will be generated.
71+
files along the way.
72+
73+
The *maxlevels* parameter is used to limit the depth of the recursion; it
74+
defaults to ``10``.
75+
76+
If *ddir* is given, it is prepended to the path to each file being compiled
77+
for use in compilation time tracebacks, and is also compiled in to the
78+
byte-code file, where it will be used in tracebacks and other messages in
79+
cases where the source file does not exist at the time the byte-code file is
80+
executed.
81+
6582
If *force* is true, modules are re-compiled even if the timestamps are up to
6683
date.
6784

68-
If *rx* is given, it specifies a regular expression of file names to exclude
69-
from the search; that expression is searched for in the full path.
85+
If *rx* is given, its search method is called on the complete path to each
86+
file considered for compilation, and if it returns a true value, the file
87+
is skipped.
7088

71-
If *quiet* is true, nothing is printed to the standard output in normal
72-
operation.
89+
If *quiet* is true, nothing is printed to the standard output unless errors
90+
occur.
7391

7492

7593
.. function:: compile_file(fullname[, ddir[, force[, rx[, quiet]]]])
7694

77-
Compile the file with path *fullname*. If *ddir* is given, it is used as the
78-
base path from which the filename used in error messages will be generated.
79-
If *force* is true, modules are re-compiled even if the timestamp is up to
80-
date.
95+
Compile the file with path *fullname*.
96+
97+
If *ddir* is given, it is prepended to the path to the file being compiled
98+
for use in compilation time tracebacks, and is also compiled in to the
99+
byte-code file, where it will be used in tracebacks and other messages in
100+
cases where the source file does not exist at the time the byte-code file is
101+
executed.
81102

82-
If *rx* is given, it specifies a regular expression which, if matched, will
83-
prevent compilation; that expression is searched for in the full path.
103+
If *ra* is given, its search method is passed the full path name to the
104+
file being compiled, and if it returns a true value, the file is not
105+
compiled and ``True`` is returned.
84106

85-
If *quiet* is true, nothing is printed to the standard output in normal
86-
operation.
107+
If *quiet* is true, nothing is printed to the standard output unless errors
108+
occur.
87109

88110
.. versionadded:: 2.7
89111

90112

91113
.. function:: compile_path([skip_curdir[, maxlevels[, force]]])
92114

93115
Byte-compile all the :file:`.py` files found along ``sys.path``. If
94-
*skip_curdir* is true (the default), the current directory is not included in
95-
the search. The *maxlevels* and *force* parameters default to ``0`` and are
96-
passed to the :func:`compile_dir` function.
116+
*skip_curdir* is true (the default), the current directory is not included
117+
in the search. All other parameters are passed to the :func:`compile_dir`
118+
function. Note that unlike the other compile functions, ``maxlevels``
119+
defaults to ``0``.
97120

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

Doc/library/doctest.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ test module::
982982

983983
def load_tests(loader, tests, ignore):
984984
tests.addTests(doctest.DocTestSuite(my_module_with_doctests))
985-
return test
985+
return tests
986986

987987
There are two main functions for creating :class:`unittest.TestSuite` instances
988988
from text files and modules with doctests:

Doc/library/email.header.rst

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

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

Doc/library/os.rst

Lines changed: 61 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ as internal buffering of data.
674674

675675
.. function:: fstat(fd)
676676

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

679679
Availability: Unix, Windows.
680680

@@ -1114,9 +1114,10 @@ Files and Directories
11141114

11151115
.. function:: lstat(path)
11161116

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

11211122

11221123
.. function:: mkfifo(path[, mode])
@@ -1314,23 +1315,23 @@ Files and Directories
13141315

13151316
.. function:: stat(path)
13161317

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

1327-
>>> import os
1328-
>>> statinfo = os.stat('somefile.txt')
1329-
>>> statinfo
1330-
(33188, 422511L, 769L, 1, 1032, 100, 926L, 1105022698,1105022732, 1105022732)
1331-
>>> statinfo.st_size
1332-
926L
1333-
>>>
1321+
The return value is an object whose attributes correspond to the members
1322+
of the :c:type:`stat` structure, namely:
1323+
1324+
* :attr:`st_mode` - protection bits,
1325+
* :attr:`st_ino` - inode number,
1326+
* :attr:`st_dev` - device,
1327+
* :attr:`st_nlink` - number of hard links,
1328+
* :attr:`st_uid` - user id of owner,
1329+
* :attr:`st_gid` - group id of owner,
1330+
* :attr:`st_size` - size of file, in bytes,
1331+
* :attr:`st_atime` - time of most recent access,
1332+
* :attr:`st_mtime` - time of most recent content modification,
1333+
* :attr:`st_ctime` - platform dependent; time of most recent metadata change on
1334+
Unix, or the time of creation on Windows)
13341335

13351336
.. versionchanged:: 2.3
13361337
If :func:`stat_float_times` returns ``True``, the time values are floats, measuring
@@ -1339,39 +1340,60 @@ Files and Directories
13391340
discussion.
13401341

13411342
On some Unix systems (such as Linux), the following attributes may also be
1342-
available: :attr:`st_blocks` (number of blocks allocated for file),
1343-
:attr:`st_blksize` (filesystem blocksize), :attr:`st_rdev` (type of device if an
1344-
inode device). :attr:`st_flags` (user defined flags for file).
1343+
available:
1344+
1345+
* :attr:`st_blocks` - number of blocks allocated for file
1346+
* :attr:`st_blksize` - filesystem blocksize
1347+
* :attr:`st_rdev` - type of device if an inode device
1348+
* :attr:`st_flags` - user defined flags for file
13451349

13461350
On other Unix systems (such as FreeBSD), the following attributes may be
1347-
available (but may be only filled out if root tries to use them): :attr:`st_gen`
1348-
(file generation number), :attr:`st_birthtime` (time of file creation).
1351+
available (but may be only filled out if root tries to use them):
1352+
1353+
* :attr:`st_gen` - file generation number
1354+
* :attr:`st_birthtime` - time of file creation
13491355

13501356
On Mac OS systems, the following attributes may also be available:
1351-
:attr:`st_rsize`, :attr:`st_creator`, :attr:`st_type`.
13521357

1353-
On RISCOS systems, the following attributes are also available: :attr:`st_ftype`
1354-
(file type), :attr:`st_attrs` (attributes), :attr:`st_obtype` (object type).
1358+
* :attr:`st_rsize`
1359+
* :attr:`st_creator`
1360+
* :attr:`st_type`
13551361

1356-
.. index:: module: stat
1362+
On RISCOS systems, the following attributes are also available:
1363+
1364+
* :attr:`st_ftype` (file type)
1365+
* :attr:`st_attrs` (attributes)
1366+
* :attr:`st_obtype` (object type).
1367+
1368+
.. note::
1369+
1370+
The exact meaning and resolution of the :attr:`st_atime`, :attr:`st_mtime`, and
1371+
:attr:`st_ctime` members depends on the operating system and the file system.
1372+
For example, on Windows systems using the FAT or FAT32 file systems,
1373+
:attr:`st_mtime` has 2-second resolution, and :attr:`st_atime` has only 1-day
1374+
resolution. See your operating system documentation for details.
13571375

1358-
For backward compatibility, the return value of :func:`stat` is also accessible
1376+
For backward compatibility, the return value of :func:`~os.stat` is also accessible
13591377
as a tuple of at least 10 integers giving the most important (and portable)
13601378
members of the :ctype:`stat` structure, in the order :attr:`st_mode`,
13611379
:attr:`st_ino`, :attr:`st_dev`, :attr:`st_nlink`, :attr:`st_uid`,
13621380
:attr:`st_gid`, :attr:`st_size`, :attr:`st_atime`, :attr:`st_mtime`,
13631381
:attr:`st_ctime`. More items may be added at the end by some implementations.
1382+
1383+
.. index:: module: stat
1384+
13641385
The standard module :mod:`stat` defines functions and constants that are useful
13651386
for extracting information from a :ctype:`stat` structure. (On Windows, some
13661387
items are filled with dummy values.)
13671388

1368-
.. note::
1389+
Example::
13691390

1370-
The exact meaning and resolution of the :attr:`st_atime`, :attr:`st_mtime`, and
1371-
:attr:`st_ctime` members depends on the operating system and the file system.
1372-
For example, on Windows systems using the FAT or FAT32 file systems,
1373-
:attr:`st_mtime` has 2-second resolution, and :attr:`st_atime` has only 1-day
1374-
resolution. See your operating system documentation for details.
1391+
>>> import os
1392+
>>> statinfo = os.stat('somefile.txt')
1393+
>>> statinfo
1394+
(33188, 422511, 769, 1, 1032, 100, 926, 1105022698,1105022732, 1105022732)
1395+
>>> statinfo.st_size
1396+
926
13751397

13761398
Availability: Unix, Windows.
13771399

@@ -1385,7 +1407,7 @@ Files and Directories
13851407
.. function:: stat_float_times([newvalue])
13861408

13871409
Determine whether :class:`stat_result` represents time stamps as float objects.
1388-
If *newvalue* is ``True``, future calls to :func:`stat` return floats, if it is
1410+
If *newvalue* is ``True``, future calls to :func:`~os.stat` return floats, if it is
13891411
``False``, future calls return ints. If *newvalue* is omitted, return the
13901412
current setting.
13911413

@@ -1505,8 +1527,8 @@ Files and Directories
15051527
respectively. Whether a directory can be given for *path* depends on whether
15061528
the operating system implements directories as files (for example, Windows
15071529
does not). Note that the exact times you set here may not be returned by a
1508-
subsequent :func:`stat` call, depending on the resolution with which your
1509-
operating system records access and modification times; see :func:`stat`.
1530+
subsequent :func:`~os.stat` call, depending on the resolution with which your
1531+
operating system records access and modification times; see :func:`~os.stat`.
15101532

15111533
.. versionchanged:: 2.0
15121534
Added support for ``None`` for *times*.

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

0 commit comments

Comments
 (0)