From 9cff42736d1f3443dc0819ec6f8506e5d439f425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sun, 15 Jan 2012 02:25:31 +0100 Subject: [PATCH 01/15] 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. I’ve 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 | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/Doc/distutils/apiref.rst b/Doc/distutils/apiref.rst index b3def22afa3..e15dc76c83c 100644 --- a/Doc/distutils/apiref.rst +++ b/Doc/distutils/apiref.rst @@ -449,7 +449,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) @@ -603,7 +605,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: @@ -723,30 +727,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) @@ -874,8 +877,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]) @@ -887,8 +888,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]) @@ -1000,8 +999,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 ===================================================== @@ -1115,8 +1112,6 @@ other utility module. * ``macosx-10.6-intel`` - .. % XXX isn't this also provided by some other non-distutils module? - .. function:: convert_path(pathname) @@ -1321,8 +1316,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 optparse - .. function:: fancy_getopt(options, negative_opt, object, args) Wrapper function. *options* is a list of ``(long_option, short_option, @@ -1338,9 +1331,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]) @@ -1403,10 +1393,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 ============================================== From 9c7b9190c33d3df61167ddd25d8ddd6ca1e79bff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sun, 15 Jan 2012 02:31:58 +0100 Subject: [PATCH 02/15] Markup improvements for the embedding CPython doc patch from #1040439 --- Doc/extending/embedding.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Doc/extending/embedding.rst b/Doc/extending/embedding.rst index ec93a16e164..3143c990e5f 100644 --- a/Doc/extending/embedding.rst +++ b/Doc/extending/embedding.rst @@ -271,7 +271,7 @@ it. To find out the required compiler and linker flags, you can execute the :file:`python{X.Y}-config` script which is generated as part of the -installation process (a generic :file:`python3-config` script is also +installation process (a :file:`python3-config` script may also be available). This script has several options, of which the following will be directly useful to you: @@ -294,9 +294,10 @@ be directly useful to you: example. If this procedure doesn't work for you (it is not guaranteed to work for -all Unix-like platforms; however, we welcome bug reports at -http://bugs.python.org), you will have to read your system's documentation -about dynamic linking and/or examine Python's Makefile and compilation +all Unix-like platforms; however, we welcome :ref:`bug reports `) +you will have to read your system's documentation about dynamic linking and/or +examine Python's :file:`Makefile` (use :func:`sysconfig.get_makefile_filename` +to find its location) and compilation options. In this case, the :mod:`sysconfig` module is a useful tool to programmatically extract the configuration values that you will want to combine together:: From 73cec21af2bfd729e9b9a72a97bc661211db6077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sun, 15 Jan 2012 02:48:55 +0100 Subject: [PATCH 03/15] Stop ignoring RPMs in distutils' upload command (#2945). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug reported by Hartmut Goebel and patch contributed by Carl Robben. Carl tested the fix and we have a buildbot with rpm installed, so I’m committing even though I could not run this test (but I do understand the changed code :) --- 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 678e1188966..357eaa575e6 100644 --- a/Lib/distutils/command/bdist_rpm.py +++ b/Lib/distutils/command/bdist_rpm.py @@ -365,16 +365,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)) def _dist_path(self, path): return os.path.join(self.dist_dir, os.path.basename(path)) diff --git a/Lib/distutils/tests/test_bdist_rpm.py b/Lib/distutils/tests/test_bdist_rpm.py index 804fb1355f2..ab7a1bf24e7 100644 --- a/Lib/distutils/tests/test_bdist_rpm.py +++ b/Lib/distutils/tests/test_bdist_rpm.py @@ -78,6 +78,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 @@ -117,6 +121,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 24f3f4599c4..bad11aebacf 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -765,6 +765,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 fe28751a2db..271c5b7423b 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -97,6 +97,8 @@ Core and Builtins Library ------- +- Issue #2945: Make the distutils upload command aware of bdist_rpm products. + - Issue #13642: Unquote before b64encoding user:password during Basic Authentication. Patch contributed by Joonas Kuorilehto. From 6f7aa00c1eb40d9a74e25e6bc3ab7c8efbe8e866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Mon, 16 Jan 2012 10:09:20 +0100 Subject: [PATCH 04/15] Document json.dump ensure_ascii parameter (#13770) --- Doc/library/json.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doc/library/json.rst b/Doc/library/json.rst index 4ee17f23951..a7912598317 100644 --- a/Doc/library/json.rst +++ b/Doc/library/json.rst @@ -125,6 +125,10 @@ Basic Usage :class:`bytes` objects. Therefore, ``fp.write()`` must support :class:`str` input. + If *ensure_ascii* is ``True`` (the default), the output is guaranteed to + have all incoming non-ASCII characters escaped. If *ensure_ascii* is + ``False``, these characters will be output as-is. + If *check_circular* is ``False`` (default: ``True``), then the circular reference check for container types will be skipped and a circular reference will result in an :exc:`OverflowError` (or worse). From f2fbb9cf4274e9d74da45d2f2d0503a57af1cad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Mon, 16 Jan 2012 16:55:55 +0100 Subject: [PATCH 05/15] Improve interlinking of archiving/compression modules docs. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove duplicated 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 | 10 +++++++--- Doc/library/tarfile.rst | 3 ++- Doc/library/zipfile.rst | 3 --- Doc/library/zlib.rst | 4 +--- 7 files changed, 11 insertions(+), 16 deletions(-) diff --git a/Doc/library/archiving.rst b/Doc/library/archiving.rst index f2d08ada0cb..75d137c9a8d 100644 --- a/Doc/library/archiving.rst +++ b/Doc/library/archiving.rst @@ -6,6 +6,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 d9a2bad7567..445c4de9c91 100644 --- a/Doc/library/bz2.rst +++ b/Doc/library/bz2.rst @@ -12,9 +12,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 48a86942fc7..8aca2dd9564 100644 --- a/Doc/library/gzip.rst +++ b/Doc/library/gzip.rst @@ -21,9 +21,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 8b4aabbb717..3b44774d7e2 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 ------------------------------ @@ -181,7 +183,7 @@ Directory and files operations (*srcname*, *dstname*, *exception*). -.. _shutil-example: +.. _shutil-copytree-example: copytree example :::::::::::::::: @@ -248,6 +250,9 @@ Another example that uses the *ignore* argument to add a logging call:: 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]]]]]]]) Create an archive file (such as zip or tar) and return its name. @@ -375,6 +380,7 @@ Archiving operations .. versionadded:: 3.2 +.. _shutil-archiving-example: Archiving example ::::::::::::::::: @@ -400,5 +406,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 b56058bfab5..46e4900b40b 100644 --- a/Doc/library/tarfile.rst +++ b/Doc/library/tarfile.rst @@ -14,7 +14,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 6f84bcce570..bcec1344a29 100644 --- a/Doc/library/zipfile.rst +++ b/Doc/library/zipfile.rst @@ -23,9 +23,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 a7b8343c7eb..897d919e310 100644 --- a/Doc/library/zlib.rst +++ b/Doc/library/zlib.rst @@ -18,9 +18,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 f99f3339fdab123033ef097a918da3f0a88cf776 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Sat, 4 Feb 2012 16:44:21 +0100 Subject: [PATCH 06/15] Fix failing test on big-endian machines (issue #13806). --- Lib/test/test_audioop.py | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/Lib/test/test_audioop.py b/Lib/test/test_audioop.py index ff60a7d93fb..c14e8b87a85 100644 --- a/Lib/test/test_audioop.py +++ b/Lib/test/test_audioop.py @@ -2,18 +2,19 @@ import audioop import unittest from test.support import run_unittest +endian = 'big' if audioop.getsample(b'\0\1', 2, 0) == 1 else 'little' def gendata1(): return b'\0\1\2' def gendata2(): - if audioop.getsample(b'\0\1', 2, 0) == 1: + if endian == 'big': return b'\0\0\0\1\0\2' else: return b'\0\0\1\0\2\0' def gendata4(): - if audioop.getsample(b'\0\0\0\1', 4, 0) == 1: + if endian == 'big': return b'\0\0\0\0\0\0\0\1\0\0\0\2' else: return b'\0\0\0\0\1\0\0\0\2\0\0\0' @@ -111,9 +112,16 @@ class TestAudioop(unittest.TestCase): # Cursory d = audioop.lin2alaw(data[0], 1) self.assertEqual(audioop.alaw2lin(d, 1), data[0]) - self.assertEqual(audioop.alaw2lin(d, 2), b'\x08\x00\x08\x01\x10\x02') - self.assertEqual(audioop.alaw2lin(d, 4), - b'\x00\x00\x08\x00\x00\x00\x08\x01\x00\x00\x10\x02') + if endian == 'big': + self.assertEqual(audioop.alaw2lin(d, 2), + b'\x00\x08\x01\x08\x02\x10') + self.assertEqual(audioop.alaw2lin(d, 4), + b'\x00\x08\x00\x00\x01\x08\x00\x00\x02\x10\x00\x00') + else: + self.assertEqual(audioop.alaw2lin(d, 2), + b'\x08\x00\x08\x01\x10\x02') + self.assertEqual(audioop.alaw2lin(d, 4), + b'\x00\x00\x08\x00\x00\x00\x08\x01\x00\x00\x10\x02') def test_lin2ulaw(self): self.assertEqual(audioop.lin2ulaw(data[0], 1), b'\xff\xe7\xdb') @@ -124,9 +132,16 @@ class TestAudioop(unittest.TestCase): # Cursory d = audioop.lin2ulaw(data[0], 1) self.assertEqual(audioop.ulaw2lin(d, 1), data[0]) - self.assertEqual(audioop.ulaw2lin(d, 2), b'\x00\x00\x04\x01\x0c\x02') - self.assertEqual(audioop.ulaw2lin(d, 4), - b'\x00\x00\x00\x00\x00\x00\x04\x01\x00\x00\x0c\x02') + if endian == 'big': + self.assertEqual(audioop.ulaw2lin(d, 2), + b'\x00\x00\x01\x04\x02\x0c') + self.assertEqual(audioop.ulaw2lin(d, 4), + b'\x00\x00\x00\x00\x01\x04\x00\x00\x02\x0c\x00\x00') + else: + self.assertEqual(audioop.ulaw2lin(d, 2), + b'\x00\x00\x04\x01\x0c\x02') + self.assertEqual(audioop.ulaw2lin(d, 4), + b'\x00\x00\x00\x00\x00\x00\x04\x01\x00\x00\x0c\x02') def test_mul(self): data2 = [] From ed3b867f330c107ed77044cffb4b28703aa17d08 Mon Sep 17 00:00:00 2001 From: Ned Deily Date: Sat, 4 Feb 2012 18:36:43 +0100 Subject: [PATCH 07/15] Issue #13933: IDLE auto-complete did not work with some imported module, like hashlib. (Patch by Roger Serwy) --- Lib/idlelib/AutoComplete.py | 4 ++-- Misc/NEWS | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Lib/idlelib/AutoComplete.py b/Lib/idlelib/AutoComplete.py index fa1733f9a6e..519099033f9 100644 --- a/Lib/idlelib/AutoComplete.py +++ b/Lib/idlelib/AutoComplete.py @@ -190,7 +190,7 @@ class AutoComplete: bigl = eval("dir()", namespace) bigl.sort() if "__all__" in bigl: - smalll = eval("__all__", namespace) + smalll = list(eval("__all__", namespace)) smalll.sort() else: smalll = [s for s in bigl if s[:1] != '_'] @@ -200,7 +200,7 @@ class AutoComplete: bigl = dir(entity) bigl.sort() if "__all__" in bigl: - smalll = entity.__all__ + smalll = list(entity.__all__) smalll.sort() else: smalll = [s for s in bigl if s[:1] != '_'] diff --git a/Misc/NEWS b/Misc/NEWS index 136748e6cb7..d3a3b9e18d0 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -113,6 +113,9 @@ Core and Builtins Library ------- +- Issue #13933: IDLE auto-complete did not work with some imported + module, like hashlib. (Patch by Roger Serwy) + - Issue #13901: Prevent test_distutils failures on OS X with --enable-shared. - Issue #13676: Handle strings with embedded zeros correctly in sqlite3. From 8f50912f8709446d379d76defc495a981bb1d8f8 Mon Sep 17 00:00:00 2001 From: Nadeem Vawda Date: Sat, 4 Feb 2012 23:44:49 +0200 Subject: [PATCH 08/15] Issue #1625: Document BZ2File's lack of support for multi-stream inputs. --- Doc/library/bz2.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Doc/library/bz2.rst b/Doc/library/bz2.rst index d9a2bad7567..e493ddd1a88 100644 --- a/Doc/library/bz2.rst +++ b/Doc/library/bz2.rst @@ -65,6 +65,15 @@ Handling of compressed files is offered by the :class:`BZ2File` class. Support for the :keyword:`with` statement was added. + .. note:: + + This class does not support input files containing multiple streams (such + as those produced by the :program:`pbzip2` tool). When reading such an + input file, only the first stream will be accessible. If you require + support for multi-stream files, consider using the third-party `bz2file + module `_ instead of this class. + + .. method:: close() Close the file. Sets data attribute :attr:`closed` to true. A closed file From 8582bb1ebd9a5951a790505e8b62d829b2b78326 Mon Sep 17 00:00:00 2001 From: Meador Inge Date: Sat, 4 Feb 2012 20:36:48 -0600 Subject: [PATCH 09/15] Issue #12142: Fixed reference cycle when importing ctypes --- Lib/ctypes/_endian.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/ctypes/_endian.py b/Lib/ctypes/_endian.py index 721b0d1c9e3..dae65fc2152 100644 --- a/Lib/ctypes/_endian.py +++ b/Lib/ctypes/_endian.py @@ -1,7 +1,7 @@ import sys from ctypes import * -_array_type = type(c_int * 3) +_array_type = type(Array) def _other_endian(typ): """Return the type with the 'other' byte order. Simple types like From 9701eb6e14e8a7d2bf2ae099611087c0a07baa43 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 5 Feb 2012 09:25:22 +0100 Subject: [PATCH 10/15] Closes #13944: fix capitalization of class name. --- Doc/library/hmac.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/library/hmac.rst b/Doc/library/hmac.rst index 0ca3eda083d..eff27241bc8 100644 --- a/Doc/library/hmac.rst +++ b/Doc/library/hmac.rst @@ -24,14 +24,14 @@ This module implements the HMAC algorithm as described by :rfc:`2104`. An HMAC object has the following methods: -.. method:: hmac.update(msg) +.. method:: HMAC.update(msg) Update the hmac object with the bytes object *msg*. Repeated calls are equivalent to a single call with the concatenation of all the arguments: ``m.update(a); m.update(b)`` is equivalent to ``m.update(a + b)``. -.. method:: hmac.digest() +.. method:: HMAC.digest() Return the digest of the bytes passed to the :meth:`update` method so far. This bytes object will be the same length as the *digest_size* of the digest @@ -39,14 +39,14 @@ An HMAC object has the following methods: bytes. -.. method:: hmac.hexdigest() +.. method:: HMAC.hexdigest() Like :meth:`digest` except the digest is returned as a string twice the length containing only hexadecimal digits. This may be used to exchange the value safely in email or other non-binary environments. -.. method:: hmac.copy() +.. method:: HMAC.copy() Return a copy ("clone") of the hmac object. This can be used to efficiently compute the digests of strings that share a common initial substring. From bd249c1bae9e70368ca190ca8e60b3e5343e9344 Mon Sep 17 00:00:00 2001 From: Nadeem Vawda Date: Sun, 5 Feb 2012 14:29:00 +0200 Subject: [PATCH 11/15] Clarify note in BZ2File docs about lack of multi-stream support (issue #1625). --- Doc/library/bz2.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Doc/library/bz2.rst b/Doc/library/bz2.rst index e493ddd1a88..0a4804c0bdf 100644 --- a/Doc/library/bz2.rst +++ b/Doc/library/bz2.rst @@ -70,8 +70,11 @@ Handling of compressed files is offered by the :class:`BZ2File` class. This class does not support input files containing multiple streams (such as those produced by the :program:`pbzip2` tool). When reading such an input file, only the first stream will be accessible. If you require - support for multi-stream files, consider using the third-party `bz2file - module `_ instead of this class. + support for multi-stream files, consider using the third-party + :mod:`bz2file` module (available from + `PyPI `_). This module provides a + backport of Python 3.3's :class:`BZ2File` class, which does support + multi-stream files. .. method:: close() From 89dfd5cf80965fcf1d3fe4db8268f8acc67b5f64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sun, 5 Feb 2012 13:40:08 +0100 Subject: [PATCH 12/15] Really make bztar support in shutil conditional. This dict entry is added a few lines after if the bzip2 module is available, but removing this line was forgotten. --- Lib/shutil.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/shutil.py b/Lib/shutil.py index 00bffe5f20f..d1b1af3246a 100644 --- a/Lib/shutil.py +++ b/Lib/shutil.py @@ -493,7 +493,6 @@ def _make_zipfile(base_name, base_dir, verbose=0, dry_run=0, logger=None): _ARCHIVE_FORMATS = { 'gztar': (_make_tarball, [('compress', 'gzip')], "gzip'ed tar-file"), - 'bztar': (_make_tarball, [('compress', 'bzip2')], "bzip2'ed tar-file"), 'tar': (_make_tarball, [('compress', None)], "uncompressed tar file"), 'zip': (_make_zipfile, [],"ZIP file") } From a77aa69870aad71c9cfce10fbca5f1e25cb2bb95 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Sun, 5 Feb 2012 14:31:16 -0500 Subject: [PATCH 13/15] #13933 refine patch using 'new' builtin --- Lib/idlelib/AutoComplete.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Lib/idlelib/AutoComplete.py b/Lib/idlelib/AutoComplete.py index 519099033f9..4e173252d61 100644 --- a/Lib/idlelib/AutoComplete.py +++ b/Lib/idlelib/AutoComplete.py @@ -190,8 +190,7 @@ class AutoComplete: bigl = eval("dir()", namespace) bigl.sort() if "__all__" in bigl: - smalll = list(eval("__all__", namespace)) - smalll.sort() + smalll = sorted(eval("__all__", namespace)) else: smalll = [s for s in bigl if s[:1] != '_'] else: @@ -200,8 +199,7 @@ class AutoComplete: bigl = dir(entity) bigl.sort() if "__all__" in bigl: - smalll = list(entity.__all__) - smalll.sort() + smalll = sorted(entity.__all__) else: smalll = [s for s in bigl if s[:1] != '_'] except: From e91e7637bb2d7723b95cd7d3b8f581aff39d70f2 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Sun, 5 Feb 2012 15:14:20 -0500 Subject: [PATCH 14/15] Issue 964437 Make IDLE help window non-modal. Patch by Guilherme Polo and Roger Serwy. --- Lib/idlelib/EditorWindow.py | 51 +++++++++++++++++++++++++++++++++++-- Lib/idlelib/textView.py | 24 ++++++++++------- Misc/NEWS | 3 +++ 3 files changed, 67 insertions(+), 11 deletions(-) diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py index f47a9c13485..6a01db01253 100644 --- a/Lib/idlelib/EditorWindow.py +++ b/Lib/idlelib/EditorWindow.py @@ -63,6 +63,50 @@ def _find_module(fullname, path=None): descr = os.path.splitext(filename)[1], None, imp.PY_SOURCE return file, filename, descr + +class HelpDialog(object): + + def __init__(self): + self.parent = None # parent of help window + self.dlg = None # the help window iteself + + def display(self, parent, near=None): + """ Display the help dialog. + + parent - parent widget for the help window + + near - a Toplevel widget (e.g. EditorWindow or PyShell) + to use as a reference for placing the help window + """ + if self.dlg is None: + self.show_dialog(parent) + if near: + self.nearwindow(near) + + def show_dialog(self, parent): + self.parent = parent + fn=os.path.join(os.path.abspath(os.path.dirname(__file__)),'help.txt') + self.dlg = dlg = textView.view_file(parent,'Help',fn, modal=False) + dlg.bind('', self.destroy, '+') + + def nearwindow(self, near): + # Place the help dialog near the window specified by parent. + # Note - this may not reposition the window in Metacity + # if "/apps/metacity/general/disable_workarounds" is enabled + dlg = self.dlg + geom = (near.winfo_rootx() + 10, near.winfo_rooty() + 10) + dlg.withdraw() + dlg.geometry("=+%d+%d" % geom) + dlg.deiconify() + dlg.lift() + + def destroy(self, ev=None): + self.dlg = None + self.parent = None + +helpDialog = HelpDialog() # singleton instance + + class EditorWindow(object): from idlelib.Percolator import Percolator from idlelib.ColorDelegator import ColorDelegator @@ -453,8 +497,11 @@ class EditorWindow(object): configDialog.ConfigDialog(self.top,'Settings') def help_dialog(self, event=None): - fn=os.path.join(os.path.abspath(os.path.dirname(__file__)),'help.txt') - textView.view_file(self.top,'Help',fn) + if self.root: + parent = self.root + else: + parent = self.top + helpDialog.display(parent, near=self.top) def python_docs(self, event=None): if sys.platform[:3] == 'win': diff --git a/Lib/idlelib/textView.py b/Lib/idlelib/textView.py index e0f49d4c450..1eaa4649edf 100644 --- a/Lib/idlelib/textView.py +++ b/Lib/idlelib/textView.py @@ -9,7 +9,7 @@ class TextViewer(Toplevel): """A simple text viewer dialog for IDLE """ - def __init__(self, parent, title, text): + def __init__(self, parent, title, text, modal=True): """Show the given text in a scrollable window with a 'close' button """ @@ -24,8 +24,6 @@ class TextViewer(Toplevel): self.CreateWidgets() self.title(title) - self.transient(parent) - self.grab_set() self.protocol("WM_DELETE_WINDOW", self.Ok) self.parent = parent self.textView.focus_set() @@ -34,7 +32,11 @@ class TextViewer(Toplevel): self.bind('',self.Ok) #dismiss dialog self.textView.insert(0.0, text) self.textView.config(state=DISABLED) - self.wait_window() + + if modal: + self.transient(parent) + self.grab_set() + self.wait_window() def CreateWidgets(self): frameText = Frame(self, relief=SUNKEN, height=700) @@ -57,10 +59,10 @@ class TextViewer(Toplevel): self.destroy() -def view_text(parent, title, text): - TextViewer(parent, title, text) +def view_text(parent, title, text, modal=True): + return TextViewer(parent, title, text, modal) -def view_file(parent, title, filename, encoding=None): +def view_file(parent, title, filename, encoding=None, modal=True): try: with open(filename, 'r', encoding=encoding) as file: contents = file.read() @@ -70,7 +72,7 @@ def view_file(parent, title, filename, encoding=None): message='Unable to load file %r .' % filename, parent=parent) else: - return view_text(parent, title, contents) + return view_text(parent, title, contents, modal) if __name__ == '__main__': @@ -80,11 +82,15 @@ if __name__ == '__main__': filename = './textView.py' text = file(filename, 'r').read() btn1 = Button(root, text='view_text', - command=lambda:view_text(root, 'view_text', text)) + command=lambda:view_text(root, 'view_text', text)) btn1.pack(side=LEFT) btn2 = Button(root, text='view_file', command=lambda:view_file(root, 'view_file', filename)) btn2.pack(side=LEFT) + btn3 = Button(root, text='nonmodal view_text', + command=lambda:view_text(root, 'nonmodal view_text', text, + modal=False)) + btn3.pack(side=LEFT) close = Button(root, text='Close', command=root.destroy) close.pack(side=RIGHT) root.mainloop() diff --git a/Misc/NEWS b/Misc/NEWS index 70c5f10071a..0a12d215246 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -113,6 +113,9 @@ Core and Builtins Library ------- +- Issue #964437 Make IDLE help window non-modal. + Patch by Guilherme Polo and Roger Serwy. + - Issue #2945: Make the distutils upload command aware of bdist_rpm products. - Issue #13933: IDLE auto-complete did not work with some imported From d531b295f26d7a0364f171d95b6abac873185a2f Mon Sep 17 00:00:00 2001 From: Ned Deily Date: Mon, 6 Feb 2012 00:58:18 +0100 Subject: [PATCH 15/15] Issue #10881: Fix test_site failure with OS X framework builds. --- Lib/test/test_site.py | 23 +++++++++++++---------- Misc/NEWS | 2 ++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py index 4d36e171cd6..ba426494fb4 100644 --- a/Lib/test/test_site.py +++ b/Lib/test/test_site.py @@ -223,7 +223,19 @@ class HelperFunctionsTests(unittest.TestCase): self.assertEqual(len(dirs), 1) wanted = os.path.join('xoxo', 'Lib', 'site-packages') self.assertEqual(dirs[0], wanted) + elif (sys.platform == "darwin" and + sysconfig.get_config_var("PYTHONFRAMEWORK")): + # OS X framework builds + site.PREFIXES = ['Python.framework'] + dirs = site.getsitepackages() + self.assertEqual(len(dirs), 3) + wanted = os.path.join('/Library', + sysconfig.get_config_var("PYTHONFRAMEWORK"), + sys.version[:3], + 'site-packages') + self.assertEqual(dirs[2], wanted) elif os.sep == '/': + # OS X non-framwework builds, Linux, FreeBSD, etc self.assertEqual(len(dirs), 2) wanted = os.path.join('xoxo', 'lib', 'python' + sys.version[:3], 'site-packages') @@ -231,21 +243,12 @@ class HelperFunctionsTests(unittest.TestCase): wanted = os.path.join('xoxo', 'lib', 'site-python') self.assertEqual(dirs[1], wanted) else: + # other platforms self.assertEqual(len(dirs), 2) self.assertEqual(dirs[0], 'xoxo') wanted = os.path.join('xoxo', 'lib', 'site-packages') self.assertEqual(dirs[1], wanted) - # let's try the specific Apple location - if (sys.platform == "darwin" and - sysconfig.get_config_var("PYTHONFRAMEWORK")): - site.PREFIXES = ['Python.framework'] - dirs = site.getsitepackages() - self.assertEqual(len(dirs), 3) - wanted = os.path.join('/Library', 'Python', sys.version[:3], - 'site-packages') - self.assertEqual(dirs[2], wanted) - class PthFile(object): """Helper class for handling testing of .pth files""" diff --git a/Misc/NEWS b/Misc/NEWS index 0a12d215246..5761ed0a1bc 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -113,6 +113,8 @@ Core and Builtins Library ------- +- Issue #10881: Fix test_site failure with OS X framework builds. + - Issue #964437 Make IDLE help window non-modal. Patch by Guilherme Polo and Roger Serwy.