From c3cc2acb09d97d7de3a9c4c52ad329b332d634da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sun, 26 Feb 2012 01:10:14 +0100 Subject: [PATCH 01/16] Improve interlinking of archiving/compression modules docs. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove duplicate list of links to the other modules from each module’s doc (people can already go up to library/archiving and there they can see the list). - Link to shutil high-level operations. Reviewed by Nadeem Vawda in #6715. --- Doc/library/archiving.rst | 1 + Doc/library/bz2.rst | 3 --- Doc/library/gzip.rst | 3 --- Doc/library/shutil.rst | 17 ++++++++++++----- Doc/library/tarfile.rst | 3 ++- Doc/library/zipfile.rst | 3 --- Doc/library/zlib.rst | 4 +--- 7 files changed, 16 insertions(+), 18 deletions(-) diff --git a/Doc/library/archiving.rst b/Doc/library/archiving.rst index 7d0df5f575a..472c617182a 100644 --- a/Doc/library/archiving.rst +++ b/Doc/library/archiving.rst @@ -7,6 +7,7 @@ Data Compression and Archiving The modules described in this chapter support data compression with the zlib, gzip, and bzip2 algorithms, and the creation of ZIP- and tar-format archives. +See also :ref:`archiving-operations` provided by the :mod:`shutil` module. .. toctree:: diff --git a/Doc/library/bz2.rst b/Doc/library/bz2.rst index 20dc765774d..79058fbd498 100644 --- a/Doc/library/bz2.rst +++ b/Doc/library/bz2.rst @@ -14,9 +14,6 @@ This module provides a comprehensive interface for the bz2 compression library. It implements a complete file interface, one-shot (de)compression functions, and types for sequential (de)compression. -For other archive formats, see the :mod:`gzip`, :mod:`zipfile`, and -:mod:`tarfile` modules. - Here is a summary of the features offered by the bz2 module: * :class:`BZ2File` class implements a complete file interface, including diff --git a/Doc/library/gzip.rst b/Doc/library/gzip.rst index e074bfc7032..470de08906c 100644 --- a/Doc/library/gzip.rst +++ b/Doc/library/gzip.rst @@ -22,9 +22,6 @@ Note that additional file formats which can be decompressed by the :program:`gzip` and :program:`gunzip` programs, such as those produced by :program:`compress` and :program:`pack`, are not supported by this module. -For other archive formats, see the :mod:`bz2`, :mod:`zipfile`, and -:mod:`tarfile` modules. - The module defines the following items: diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst index 78c38e50da7..a330018a418 100644 --- a/Doc/library/shutil.rst +++ b/Doc/library/shutil.rst @@ -31,6 +31,8 @@ copying and removal. For operations on individual files, see also the are not copied. +.. _file-operations: + Directory and files operations ------------------------------ @@ -185,7 +187,7 @@ Directory and files operations .. versionadded:: 2.3 -.. _shutil-example: +.. _copytree-example: copytree example :::::::::::::::: @@ -254,8 +256,13 @@ Another example that uses the *ignore* argument to add a logging call:: copytree(source, destination, ignore=_logpath) -Archives operations -------------------- +.. _archiving-operations: + +Archiving operations +-------------------- + +High-level utilities to create and read compressed and archived files are also +provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules. .. function:: make_archive(base_name, format, [root_dir, [base_dir, [verbose, [dry_run, [owner, [group, [logger]]]]]]]) @@ -322,6 +329,8 @@ Archives operations .. versionadded:: 2.7 +.. _archiving-example: + Archiving example ::::::::::::::::: @@ -346,5 +355,3 @@ The resulting archive contains:: -rw------- tarek/staff 1675 2008-06-09 13:26:54 ./id_rsa -rw-r--r-- tarek/staff 397 2008-06-09 13:26:54 ./id_rsa.pub -rw-r--r-- tarek/staff 37192 2010-02-06 18:23:10 ./known_hosts - - diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst index 5502adce74f..b6124e1e40c 100644 --- a/Doc/library/tarfile.rst +++ b/Doc/library/tarfile.rst @@ -16,7 +16,8 @@ The :mod:`tarfile` module makes it possible to read and write tar archives, including those using gzip or bz2 compression. -(:file:`.zip` files can be read and written using the :mod:`zipfile` module.) +Use the :mod:`zipfile` module to read or write :file:`.zip` files, or the +higher-level functions in :ref:`shutil `. Some facts and figures: diff --git a/Doc/library/zipfile.rst b/Doc/library/zipfile.rst index 14e40c8b787..68e8dfac4e1 100644 --- a/Doc/library/zipfile.rst +++ b/Doc/library/zipfile.rst @@ -25,9 +25,6 @@ decryption of encrypted files in ZIP archives, but it currently cannot create an encrypted file. Decryption is extremely slow as it is implemented in native Python rather than C. -For other archive formats, see the :mod:`bz2`, :mod:`gzip`, and -:mod:`tarfile` modules. - The module defines the following items: .. exception:: BadZipfile diff --git a/Doc/library/zlib.rst b/Doc/library/zlib.rst index 92a3197337f..bd08f7f6a09 100644 --- a/Doc/library/zlib.rst +++ b/Doc/library/zlib.rst @@ -19,9 +19,7 @@ order. This documentation doesn't attempt to cover all of the permutations; consult the zlib manual at http://www.zlib.net/manual.html for authoritative information. -For reading and writing ``.gz`` files see the :mod:`gzip` module. For -other archive formats, see the :mod:`bz2`, :mod:`zipfile`, and -:mod:`tarfile` modules. +For reading and writing ``.gz`` files see the :mod:`gzip` module. The available exception and functions in this module are: From d673b62bac837d53ae27ba53a0580dfae44f63fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sun, 26 Feb 2012 01:16:47 +0100 Subject: [PATCH 02/16] Stop ignoring RPMs in distutils' upload command (#2945). Bug reported by Hartmut Goebel and patch contributed by Carl Robben. Untested backport of the fix committed and tested for 3.2. --- Lib/distutils/command/bdist_rpm.py | 12 ++++++++++++ Lib/distutils/tests/test_bdist_rpm.py | 9 +++++++++ Misc/ACKS | 1 + Misc/NEWS | 2 ++ 4 files changed, 24 insertions(+) diff --git a/Lib/distutils/command/bdist_rpm.py b/Lib/distutils/command/bdist_rpm.py index 0bba3635574..595824367e3 100644 --- a/Lib/distutils/command/bdist_rpm.py +++ b/Lib/distutils/command/bdist_rpm.py @@ -379,16 +379,28 @@ class bdist_rpm (Command): self.spawn(rpm_cmd) if not self.dry_run: + if self.distribution.has_ext_modules(): + pyversion = get_python_version() + else: + pyversion = 'any' + if not self.binary_only: srpm = os.path.join(rpm_dir['SRPMS'], source_rpm) assert(os.path.exists(srpm)) self.move_file(srpm, self.dist_dir) + filename = os.path.join(self.dist_dir, source_rpm) + self.distribution.dist_files.append( + ('bdist_rpm', pyversion, filename)) if not self.source_only: for rpm in binary_rpms: rpm = os.path.join(rpm_dir['RPMS'], rpm) if os.path.exists(rpm): self.move_file(rpm, self.dist_dir) + filename = os.path.join(self.dist_dir, + os.path.basename(rpm)) + self.distribution.dist_files.append( + ('bdist_rpm', pyversion, filename)) # run() def _dist_path(self, path): diff --git a/Lib/distutils/tests/test_bdist_rpm.py b/Lib/distutils/tests/test_bdist_rpm.py index 25a5763a72d..37d89155c7e 100644 --- a/Lib/distutils/tests/test_bdist_rpm.py +++ b/Lib/distutils/tests/test_bdist_rpm.py @@ -79,6 +79,10 @@ class BuildRpmTestCase(support.TempdirManager, dist_created = os.listdir(os.path.join(pkg_dir, 'dist')) self.assertTrue('foo-0.1-1.noarch.rpm' in dist_created) + # bug #2945: upload ignores bdist_rpm files + self.assertIn(('bdist_rpm', 'any', 'dist/foo-0.1-1.src.rpm'), dist.dist_files) + self.assertIn(('bdist_rpm', 'any', 'dist/foo-0.1-1.noarch.rpm'), dist.dist_files) + def test_no_optimize_flag(self): # XXX I am unable yet to make this test work without @@ -118,6 +122,11 @@ class BuildRpmTestCase(support.TempdirManager, dist_created = os.listdir(os.path.join(pkg_dir, 'dist')) self.assertTrue('foo-0.1-1.noarch.rpm' in dist_created) + + # bug #2945: upload ignores bdist_rpm files + self.assertIn(('bdist_rpm', 'any', 'dist/foo-0.1-1.src.rpm'), dist.dist_files) + self.assertIn(('bdist_rpm', 'any', 'dist/foo-0.1-1.noarch.rpm'), dist.dist_files) + os.remove(os.path.join(pkg_dir, 'dist', 'foo-0.1-1.noarch.rpm')) def test_suite(): diff --git a/Misc/ACKS b/Misc/ACKS index 624b6164bec..c7c3979c507 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -709,6 +709,7 @@ Vlad Riscutia Juan M. Bello Rivas Davide Rizzo Anthony Roach +Carl Robben Mark Roberts Jim Robinson Andy Robinson diff --git a/Misc/NEWS b/Misc/NEWS index 96cfd2dda5f..7be7777dda7 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -98,6 +98,8 @@ Core and Builtins Library ------- +- Issue #2945: Make the distutils upload command aware of bdist_rpm products. + - Issue #13447: Add a test file to host regression tests for bugs in the scripts found in the Tools directory. From 576c6d7ee1ffd980929048dd3ab50a8efba2663c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sun, 26 Feb 2012 01:21:31 +0100 Subject: [PATCH 03/16] Hide or remove user-visible XXX notes from distutils doc (#13716). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Requested by Florent Xicluna with the rationale that they make the docs look unfinished. When I get to replace the XXX notes with the real info for packaging, I’ll backport it. Also removed a few XXX notes that were not visible in the HTML but could waste contributors’ time by suggesting improvements that are never going to happen for distutils. --- Doc/distutils/apiref.rst | 38 +++++++++++--------------------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/Doc/distutils/apiref.rst b/Doc/distutils/apiref.rst index 692d5cf60be..ba4fc9f5a50 100644 --- a/Doc/distutils/apiref.rst +++ b/Doc/distutils/apiref.rst @@ -444,7 +444,9 @@ This module provides the following functions. Define a preprocessor macro for all compilations driven by this compiler object. The optional parameter *value* should be a string; if it is not supplied, then the macro will be defined without an explicit value and the exact outcome - depends on the compiler used (XXX true? does ANSI say anything about this?) + depends on the compiler used. + + .. XXX true? does ANSI say anything about this? .. method:: CCompiler.undefine_macro(name) @@ -598,7 +600,9 @@ This module provides the following functions. *output_libname* should be a library name, not a filename; the filename will be inferred from the library name. *output_dir* is the directory where the library - file will be put. XXX defaults to what? + file will be put. + + .. XXX defaults to what? *debug* is a boolean; if true, debugging information will be included in the library (note that on most platforms, it is the compile step where this matters: @@ -718,30 +722,29 @@ This module provides the following functions. Invokes :func:`distutils.util.execute` This method invokes a Python function *func* with the given arguments *args*, after logging and taking into account - the *dry_run* flag. XXX see also. + the *dry_run* flag. .. method:: CCompiler.spawn(cmd) Invokes :func:`distutils.util.spawn`. This invokes an external process to run - the given command. XXX see also. + the given command. .. method:: CCompiler.mkpath(name[, mode=511]) Invokes :func:`distutils.dir_util.mkpath`. This creates a directory and any - missing ancestor directories. XXX see also. + missing ancestor directories. .. method:: CCompiler.move_file(src, dst) - Invokes :meth:`distutils.file_util.move_file`. Renames *src* to *dst*. XXX see - also. + Invokes :meth:`distutils.file_util.move_file`. Renames *src* to *dst*. .. method:: CCompiler.announce(msg[, level=1]) - Write a message using :func:`distutils.log.debug`. XXX see also. + Write a message using :func:`distutils.log.debug`. .. method:: CCompiler.warn(msg) @@ -869,8 +872,6 @@ tarballs or zipfiles. prefix of all files and directories in the archive. *root_dir* and *base_dir* both default to the current directory. Returns the name of the archive file. - .. XXX This should be changed to support bz2 files. - .. function:: make_tarball(base_name, base_dir[, compress='gzip', verbose=0, dry_run=0]) @@ -882,8 +883,6 @@ tarballs or zipfiles. possibly plus the appropriate compression extension (:file:`.gz`, :file:`.bz2` or :file:`.Z`). Return the output filename. - .. XXX This should be replaced with calls to the :mod:`tarfile` module. - .. function:: make_zipfile(base_name, base_dir[, verbose=0, dry_run=0]) @@ -995,8 +994,6 @@ directories. errors are ignored (apart from being reported to ``sys.stdout`` if *verbose* is true). -.. XXX Some of this could be replaced with the shutil module? - :mod:`distutils.file_util` --- Single file operations ===================================================== @@ -1110,8 +1107,6 @@ other utility module. * ``macosx-10.6-intel`` - .. % XXX isn't this also provided by some other non-distutils module? - .. function:: convert_path(pathname) @@ -1311,8 +1306,6 @@ provides the following additional features: the "negative alias" of :option:`--verbose`, then :option:`--quiet` on the command line sets *verbose* to false. -.. XXX Should be replaced with :mod:`optparse`. - .. function:: fancy_getopt(options, negative_opt, object, args) @@ -1329,8 +1322,6 @@ provides the following additional features: Wraps *text* to less than *width* wide. - .. XXX Should be replaced with :mod:`textwrap` (which is available in Python - 2.3 and later). .. class:: FancyGetopt([option_table=None]) @@ -1394,10 +1385,6 @@ filesystem and building lists of files. :synopsis: A simple logging mechanism, 282-style -.. XXX Should be replaced with standard :mod:`logging` module. - - - :mod:`distutils.spawn` --- Spawn a sub-process ============================================== @@ -1894,9 +1881,6 @@ Subclasses of :class:`Command` must define the following methods. :synopsis: Build the .py/.pyc files of a package -.. % todo - - :mod:`distutils.command.build_scripts` --- Build the scripts of a package ========================================================================= From c8e29dba91916db055c36f1a68d8e3c18f630903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sun, 26 Feb 2012 01:25:11 +0100 Subject: [PATCH 04/16] Mark up constants in socket doc as such --- Doc/library/socket.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst index 8ac47fb17bd..963a5ac1f3b 100644 --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -72,17 +72,17 @@ numeric address in *host* portion. tuple, and the fields depend on the address type. The general tuple form is ``(addr_type, v1, v2, v3 [, scope])``, where: - - *addr_type* is one of TIPC_ADDR_NAMESEQ, TIPC_ADDR_NAME, or - TIPC_ADDR_ID. - - *scope* is one of TIPC_ZONE_SCOPE, TIPC_CLUSTER_SCOPE, and - TIPC_NODE_SCOPE. - - If *addr_type* is TIPC_ADDR_NAME, then *v1* is the server type, *v2* is + - *addr_type* is one of :const;`TIPC_ADDR_NAMESEQ`, :const:`TIPC_ADDR_NAME`, + or :const:`TIPC_ADDR_ID`. + - *scope* is one of :const:`TIPC_ZONE_SCOPE`, :const:`TIPC_CLUSTER_SCOPE`, + and :const:`TIPC_NODE_SCOPE`. + - If *addr_type* is :const:`TIPC_ADDR_NAME`, then *v1* is the server type, *v2* is the port identifier, and *v3* should be 0. - If *addr_type* is TIPC_ADDR_NAMESEQ, then *v1* is the server type, *v2* + If *addr_type* is :const:`TIPC_ADDR_NAMESEQ`, then *v1* is the server type, *v2* is the lower port number, and *v3* is the upper port number. - If *addr_type* is TIPC_ADDR_ID, then *v1* is the node, *v2* is the + If *addr_type* is :const:`TIPC_ADDR_ID`, then *v1* is the node, *v2* is the reference, and *v3* should be set to 0. From ef2e14e675be14d74f5bc42c2d5c58927fca2e06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sun, 26 Feb 2012 01:26:09 +0100 Subject: [PATCH 05/16] Fix instructions on how to rebuild some modules --- Lib/keyword.py | 2 +- Lib/symbol.py | 2 +- Lib/token.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/keyword.py b/Lib/keyword.py index 8eb2860307e..69794bda8c8 100755 --- a/Lib/keyword.py +++ b/Lib/keyword.py @@ -7,7 +7,7 @@ This file is automatically generated; please don't muck it up! To update the symbols in this file, 'cd' to the top directory of the python source tree after building the interpreter and run: - python Lib/keyword.py + ./python Lib/keyword.py """ __all__ = ["iskeyword", "kwlist"] diff --git a/Lib/symbol.py b/Lib/symbol.py index cf179e5ef35..b4d4e13ab80 100755 --- a/Lib/symbol.py +++ b/Lib/symbol.py @@ -7,7 +7,7 @@ # To update the symbols in this file, 'cd' to the top directory of # the python source tree after building the interpreter and run: # -# python Lib/symbol.py +# ./python Lib/symbol.py #--start constants-- single_input = 256 diff --git a/Lib/token.py b/Lib/token.py index 8d5cdaa1754..34abf62016a 100755 --- a/Lib/token.py +++ b/Lib/token.py @@ -7,7 +7,7 @@ # To update the symbols in this file, 'cd' to the top directory of # the python source tree after building the interpreter and run: # -# python Lib/token.py +# ./python Lib/token.py #--start constants-- ENDMARKER = 0 From 8d4d74eefcdcdd7fb5f038b4488b41bfa5e11b2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sun, 26 Feb 2012 01:28:34 +0100 Subject: [PATCH 06/16] Update lingering references to ex-parrot. I mean ex-devguide. --- Lib/locale.py | 3 +-- Misc/python.man | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Lib/locale.py b/Lib/locale.py index 561e9e44788..0f60dcc654e 100644 --- a/Lib/locale.py +++ b/Lib/locale.py @@ -1581,8 +1581,7 @@ locale_alias = { # to include every locale up to Windows Vista. # # NOTE: this mapping is incomplete. If your language is missing, please -# submit a bug report to Python bug manager, which you can find via: -# http://www.python.org/dev/ +# submit a bug report to the Python bug tracker at http://bugs.python.org/ # Make sure you include the missing language identifier and the suggested # locale code. # diff --git a/Misc/python.man b/Misc/python.man index 96c99649b3e..39edbca1e06 100644 --- a/Misc/python.man +++ b/Misc/python.man @@ -459,7 +459,7 @@ Main website: http://www.python.org/ .br Documentation: http://docs.python.org/ .br -Developer resources: http://www.python.org/dev/ +Developer resources: http://docs.python.org/devguide/ .br Downloads: http://python.org/download/ .br From d4e714c74623678a353134f6acf79cd2ce8693e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sun, 26 Feb 2012 01:29:09 +0100 Subject: [PATCH 07/16] Fix typo (#13467) --- Doc/library/sysconfig.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/sysconfig.rst b/Doc/library/sysconfig.rst index 5ba6fa26f27..a745a3d9d63 100644 --- a/Doc/library/sysconfig.rst +++ b/Doc/library/sysconfig.rst @@ -129,7 +129,7 @@ identifier. Python currently uses eight paths: one may call this function and get the default value. If *scheme* is provided, it must be a value from the list returned by - :func:`get_path_names`. Otherwise, the default scheme for the current + :func:`get_scheme_names`. Otherwise, the default scheme for the current platform is used. If *vars* is provided, it must be a dictionary of variables that will update From 06efea3392e54b50f66e790735837e092585350f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sun, 26 Feb 2012 01:33:22 +0100 Subject: [PATCH 08/16] Use raw strings for docstrings with backslashes in ASCII diagrams --- Lib/cookielib.py | 2 +- Lib/httplib.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/cookielib.py b/Lib/cookielib.py index 65214df30d1..f9c8d2f84bd 100644 --- a/Lib/cookielib.py +++ b/Lib/cookielib.py @@ -1,4 +1,4 @@ -"""HTTP cookie handling for web clients. +r"""HTTP cookie handling for web clients. This module has (now fairly distant) origins in Gisle Aas' Perl module HTTP::Cookies, from the libwww-perl library. diff --git a/Lib/httplib.py b/Lib/httplib.py index 19bcd1b41bb..13629c4a965 100644 --- a/Lib/httplib.py +++ b/Lib/httplib.py @@ -1,4 +1,4 @@ -"""HTTP/1.1 client library +r"""HTTP/1.1 client library From c446ce78b84f8ccf162b90687723842e7117336e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sun, 26 Feb 2012 01:33:49 +0100 Subject: [PATCH 09/16] Document that shutil.make_archive does not typecheck its logger argument --- Doc/library/shutil.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst index a330018a418..31231b662ad 100644 --- a/Doc/library/shutil.rst +++ b/Doc/library/shutil.rst @@ -285,7 +285,8 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules. *owner* and *group* are used when creating a tar archive. By default, uses the current owner and group. - *logger* is an instance of :class:`logging.Logger`. + *logger* must be an object compatible with :pep:`282`, usually an instance of + :class:`logging.Logger`. .. versionadded:: 2.7 From a318a3b2fb127f7a18bc3a31bb0798272170d30d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sun, 26 Feb 2012 01:36:31 +0100 Subject: [PATCH 10/16] Avoid relying on the default reST role in logging library doc --- Doc/library/logging.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst index ea69b9e2ec6..f91d4845c11 100644 --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -915,12 +915,11 @@ with the :mod:`warnings` module. If *capture* is ``True``, warnings issued by the :mod:`warnings` module will be redirected to the logging system. Specifically, a warning will be formatted using :func:`warnings.formatwarning` and the resulting string - logged to a logger named 'py.warnings' with a severity of `WARNING`. + logged to a logger named ``'py.warnings'`` with a severity of :const:`WARNING`. If *capture* is ``False``, the redirection of warnings to the logging system will stop, and warnings will be redirected to their original destinations - (i.e. those in effect before `captureWarnings(True)` was called). - + (i.e. those in effect before ``captureWarnings(True)`` was called). .. seealso:: From 9ede557d340f8cafe099322d2933fc153b649a9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sun, 26 Feb 2012 01:37:47 +0100 Subject: [PATCH 11/16] Update docstring with more useful text (from the PEP) --- Lib/numbers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/numbers.py b/Lib/numbers.py index 2592643c136..bdc6dd65213 100644 --- a/Lib/numbers.py +++ b/Lib/numbers.py @@ -303,7 +303,7 @@ class Integral(Rational): raise NotImplementedError def __index__(self): - """index(self)""" + """Called whenever an index is needed, such as in slicing""" return long(self) @abstractmethod From a358bc3ca24f521ed63e81f1f03be52f84777a3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sun, 26 Feb 2012 01:38:26 +0100 Subject: [PATCH 12/16] State explicitely that PYTHONDONTWRITEBYTECODE is equivalent to -B --- Doc/using/cmdline.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst index 4b2793ff7df..2537c485718 100644 --- a/Doc/using/cmdline.rst +++ b/Doc/using/cmdline.rst @@ -541,7 +541,8 @@ These environment variables influence Python's behavior. .. envvar:: PYTHONDONTWRITEBYTECODE If this is set, Python won't try to write ``.pyc`` or ``.pyo`` files on the - import of source modules. + import of source modules. This is equivalent to specifying the :option:`-B` + option. .. versionadded:: 2.6 From 7f4b3be2ccc18751f9f0bdf246c0cc952d976a8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sun, 26 Feb 2012 01:41:39 +0100 Subject: [PATCH 13/16] =?UTF-8?q?Fix=20typo=20=E2=80=9Cseperator=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Lib/_pyio.py | 2 +- Modules/_io/_iomodule.c | 2 +- Modules/_io/textio.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/_pyio.py b/Lib/_pyio.py index 34d0c4c3509..d5114338fad 100644 --- a/Lib/_pyio.py +++ b/Lib/_pyio.py @@ -1451,7 +1451,7 @@ class TextIOWrapper(TextIOBase): enabled. With this enabled, on input, the lines endings '\n', '\r', or '\r\n' are translated to '\n' before being returned to the caller. Conversely, on output, '\n' is translated to the system - default line seperator, os.linesep. If newline is any other of its + default line separator, os.linesep. If newline is any other of its legal values, that newline becomes the newline when the file is read and it is returned untranslated. On output, '\n' is converted to the newline. diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c index 6d7121c2d90..e356ea58df2 100644 --- a/Modules/_io/_iomodule.c +++ b/Modules/_io/_iomodule.c @@ -58,7 +58,7 @@ PyDoc_STRVAR(module_doc, "\n" "At the top of the I/O hierarchy is the abstract base class IOBase. It\n" "defines the basic interface to a stream. Note, however, that there is no\n" -"seperation between reading and writing to streams; implementations are\n" +"separation between reading and writing to streams; implementations are\n" "allowed to throw an IOError if they do not support a given operation.\n" "\n" "Extending IOBase is RawIOBase which deals simply with the reading and\n" diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index c5d7b85a475..1878312835e 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -627,7 +627,7 @@ PyDoc_STRVAR(textiowrapper_doc, "enabled. With this enabled, on input, the lines endings '\\n', '\\r',\n" "or '\\r\\n' are translated to '\\n' before being returned to the\n" "caller. Conversely, on output, '\\n' is translated to the system\n" - "default line seperator, os.linesep. If newline is any other of its\n" + "default line separator, os.linesep. If newline is any other of its\n" "legal values, that newline becomes the newline when the file is read\n" "and it is returned untranslated. On output, '\\n' is converted to the\n" "newline.\n" From ae50babe32b53049910d8d0bb8a2eeac7c18a477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sun, 26 Feb 2012 01:53:53 +0100 Subject: [PATCH 14/16] Synchronize some distutils tests with 3.2. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Actually check the contents of the file created by bdist_dumb. - Don’t use “RECORD” as filename for non-PEP 376 record file - Don’t start method name with “_test”, it looks like a disabled test method instead of an helper method - Fix some idioms (assertIn, addCleanup) --- Lib/distutils/tests/test_bdist_dumb.py | 24 ++++++++++++------ Lib/distutils/tests/test_install.py | 35 +++++++++++++------------- Lib/distutils/tests/test_sdist.py | 10 ++++---- 3 files changed, 38 insertions(+), 31 deletions(-) diff --git a/Lib/distutils/tests/test_bdist_dumb.py b/Lib/distutils/tests/test_bdist_dumb.py index 5a22a10ec87..3378f49ea09 100644 --- a/Lib/distutils/tests/test_bdist_dumb.py +++ b/Lib/distutils/tests/test_bdist_dumb.py @@ -1,8 +1,10 @@ """Tests for distutils.command.bdist_dumb.""" -import unittest -import sys import os +import sys +import zipfile +import unittest +from test.test_support import run_unittest # zlib is not used here, but if it's not available # test_simple_built will fail @@ -11,8 +13,6 @@ try: except ImportError: zlib = None -from test.test_support import run_unittest - from distutils.core import Distribution from distutils.command.bdist_dumb import bdist_dumb from distutils.tests import support @@ -73,15 +73,23 @@ class BuildDumbTestCase(support.TempdirManager, # see what we have dist_created = os.listdir(os.path.join(pkg_dir, 'dist')) - base = "%s.%s" % (dist.get_fullname(), cmd.plat_name) + base = "%s.%s.zip" % (dist.get_fullname(), cmd.plat_name) if os.name == 'os2': base = base.replace(':', '-') - wanted = ['%s.zip' % base] - self.assertEqual(dist_created, wanted) + self.assertEqual(dist_created, [base]) # now let's check what we have in the zip file - # XXX to be done + fp = zipfile.ZipFile(os.path.join('dist', base)) + try: + contents = fp.namelist() + finally: + fp.close() + + contents = sorted(os.path.basename(fn) for fn in contents) + wanted = ['foo-0.1-py%s.%s.egg-info' % sys.version_info[:2], + 'foo.py', 'foo.pyc'] + self.assertEqual(contents, sorted(wanted)) def test_finalize_options(self): pkg_dir, dist = self.create_dist() diff --git a/Lib/distutils/tests/test_install.py b/Lib/distutils/tests/test_install.py index ebfb04f4463..f17baa1e50d 100644 --- a/Lib/distutils/tests/test_install.py +++ b/Lib/distutils/tests/test_install.py @@ -86,19 +86,17 @@ class InstallTestCase(support.TempdirManager, self.old_expand = os.path.expanduser os.path.expanduser = _expanduser - try: - # this is the actual test - self._test_user_site() - finally: + def cleanup(): site.USER_BASE = self.old_user_base site.USER_SITE = self.old_user_site install_module.USER_BASE = self.old_user_base install_module.USER_SITE = self.old_user_site os.path.expanduser = self.old_expand - def _test_user_site(self): + self.addCleanup(cleanup) + for key in ('nt_user', 'unix_user', 'os2_home'): - self.assertTrue(key in INSTALL_SCHEMES) + self.assertIn(key, INSTALL_SCHEMES) dist = Distribution({'name': 'xx'}) cmd = install(dist) @@ -106,14 +104,14 @@ class InstallTestCase(support.TempdirManager, # making sure the user option is there options = [name for name, short, lable in cmd.user_options] - self.assertTrue('user' in options) + self.assertIn('user', options) # setting a value cmd.user = 1 # user base and site shouldn't be created yet - self.assertTrue(not os.path.exists(self.user_base)) - self.assertTrue(not os.path.exists(self.user_site)) + self.assertFalse(os.path.exists(self.user_base)) + self.assertFalse(os.path.exists(self.user_site)) # let's run finalize cmd.ensure_finalized() @@ -122,8 +120,8 @@ class InstallTestCase(support.TempdirManager, self.assertTrue(os.path.exists(self.user_base)) self.assertTrue(os.path.exists(self.user_site)) - self.assertTrue('userbase' in cmd.config_vars) - self.assertTrue('usersite' in cmd.config_vars) + self.assertIn('userbase', cmd.config_vars) + self.assertIn('usersite', cmd.config_vars) def test_handle_extra_path(self): dist = Distribution({'name': 'xx', 'extra_path': 'path,dirs'}) @@ -176,15 +174,16 @@ class InstallTestCase(support.TempdirManager, def test_record(self): install_dir = self.mkdtemp() - project_dir, dist = self.create_dist(scripts=['hello']) - self.addCleanup(os.chdir, os.getcwd()) + project_dir, dist = self.create_dist(py_modules=['hello'], + scripts=['sayhi']) os.chdir(project_dir) - self.write_file('hello', "print('o hai')") + self.write_file('hello.py', "def main(): print 'o hai'") + self.write_file('sayhi', 'from hello import main; main()') cmd = install(dist) dist.command_obj['install'] = cmd cmd.root = install_dir - cmd.record = os.path.join(project_dir, 'RECORD') + cmd.record = os.path.join(project_dir, 'filelist') cmd.ensure_finalized() cmd.run() @@ -195,7 +194,7 @@ class InstallTestCase(support.TempdirManager, f.close() found = [os.path.basename(line) for line in content.splitlines()] - expected = ['hello', + expected = ['hello.py', 'hello.pyc', 'sayhi', 'UNKNOWN-0.0.0-py%s.%s.egg-info' % sys.version_info[:2]] self.assertEqual(found, expected) @@ -203,7 +202,6 @@ class InstallTestCase(support.TempdirManager, install_dir = self.mkdtemp() project_dir, dist = self.create_dist(ext_modules=[ Extension('xx', ['xxmodule.c'])]) - self.addCleanup(os.chdir, os.getcwd()) os.chdir(project_dir) support.copy_xxmodule_c(project_dir) @@ -215,7 +213,7 @@ class InstallTestCase(support.TempdirManager, dist.command_obj['install'] = cmd dist.command_obj['build_ext'] = buildextcmd cmd.root = install_dir - cmd.record = os.path.join(project_dir, 'RECORD') + cmd.record = os.path.join(project_dir, 'filelist') cmd.ensure_finalized() cmd.run() @@ -241,6 +239,7 @@ class InstallTestCase(support.TempdirManager, install_module.DEBUG = False self.assertTrue(len(self.logs) > old_logs_len) + def test_suite(): return unittest.makeSuite(InstallTestCase) diff --git a/Lib/distutils/tests/test_sdist.py b/Lib/distutils/tests/test_sdist.py index 9e422fca173..3a89f73fa2b 100644 --- a/Lib/distutils/tests/test_sdist.py +++ b/Lib/distutils/tests/test_sdist.py @@ -6,6 +6,7 @@ import warnings import zipfile from os.path import join from textwrap import dedent +from test.test_support import captured_stdout, check_warnings, run_unittest # zlib is not used here, but if it's not available # the tests that use zipfile may fail @@ -21,7 +22,6 @@ try: except ImportError: UID_GID_SUPPORT = False -from test.test_support import captured_stdout, check_warnings, run_unittest from distutils.command.sdist import sdist, show_formats from distutils.core import Distribution @@ -375,7 +375,7 @@ class SDistTestCase(PyPIRCCommandTestCase): # the following tests make sure there is a nice error message instead # of a traceback when parsing an invalid manifest template - def _test_template(self, content): + def _check_template(self, content): dist, cmd = self.get_cmd() os.chdir(self.tmp_dir) self.write_file('MANIFEST.in', content) @@ -386,17 +386,17 @@ class SDistTestCase(PyPIRCCommandTestCase): self.assertEqual(len(warnings), 1) def test_invalid_template_unknown_command(self): - self._test_template('taunt knights *') + self._check_template('taunt knights *') def test_invalid_template_wrong_arguments(self): # this manifest command takes one argument - self._test_template('prune') + self._check_template('prune') @unittest.skipIf(os.name != 'nt', 'test relevant for Windows only') def test_invalid_template_wrong_path(self): # on Windows, trailing slashes are not allowed # this used to crash instead of raising a warning: #8286 - self._test_template('include examples/') + self._check_template('include examples/') @unittest.skipUnless(zlib, "requires zlib") def test_get_file_list(self): From 060b812a4bc9a3acb42d8edc0290f5e77126446f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sun, 26 Feb 2012 02:00:35 +0100 Subject: [PATCH 15/16] Fix markup errors --- Doc/library/sys.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 3873eb8ad17..2cf3267cd09 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -208,7 +208,7 @@ always available. be set at build time with the ``--exec-prefix`` argument to the :program:`configure` script. Specifically, all configuration files (e.g. the :file:`pyconfig.h` header file) are installed in the directory - :file:`{exec_prefix}/lib/python{X.Y}/config', and shared library modules are + :file:`{exec_prefix}/lib/python{X.Y}/config`, and shared library modules are installed in :file:`{exec_prefix}/lib/python{X.Y}/lib-dynload`, where *X.Y* is the version number of Python, for example ``2.7``. @@ -775,7 +775,7 @@ always available. argument to the :program:`configure` script. The main collection of Python library modules is installed in the directory :file:`{prefix}/lib/python{X.Y}`` while the platform independent header files (all except :file:`pyconfig.h`) are - stored in :file:`{prefix}/include/python{X.Y}``, where *X.Y* is the version + stored in :file:`{prefix}/include/python{X.Y}`, where *X.Y* is the version number of Python, for example ``2.7``. From 6d37c4e388c01252a646d319c2474828dd3def1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sun, 26 Feb 2012 02:03:39 +0100 Subject: [PATCH 16/16] Add versionadded for sys.flags.hash_randomization variable --- Doc/library/sys.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 2cf3267cd09..691b30cff47 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -1,4 +1,3 @@ - :mod:`sys` --- System-specific parameters and functions ======================================================= @@ -291,6 +290,8 @@ always available. .. versionadded:: 2.6 + .. versionadded:: 2.7.3 + The ``hash_randomization`` attribute. .. data:: float_info