From c432a9d5b9a3fa296cebed6ecbe310d26a796f84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Mon, 5 Mar 2012 15:45:08 +0100 Subject: Use raw string for a docstring that uses a backslash --- Lib/xmlrpc/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/xmlrpc/server.py b/Lib/xmlrpc/server.py index d7ed3f3..fd17026 100644 --- a/Lib/xmlrpc/server.py +++ b/Lib/xmlrpc/server.py @@ -1,4 +1,4 @@ -"""XML-RPC Servers. +r"""XML-RPC Servers. This module can be used to create simple XML-RPC servers by creating a server and either installing functions, a -- cgit v0.12 From d3899e320fa4c10166c5eb7dc7996d15dd541f46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Mon, 5 Mar 2012 15:47:32 +0100 Subject: Remove mention of defunct file. Misc/COPYRIGHT was renamed twelve years ago to LICENSE and later copied to the main docs, to which there is already a link. --- Doc/howto/advocacy.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Doc/howto/advocacy.rst b/Doc/howto/advocacy.rst index e67e201..2969d26 100644 --- a/Doc/howto/advocacy.rst +++ b/Doc/howto/advocacy.rst @@ -264,8 +264,7 @@ the organizations that use Python. **What are the restrictions on Python's use?** -They're practically nonexistent. Consult the :file:`Misc/COPYRIGHT` file in the -source distribution, or the section :ref:`history-and-license` for the full +They're practically nonexistent. Consult :ref:`history-and-license` for the full language, but it boils down to three conditions: * You have to leave the copyright notice on the software; if you don't include -- cgit v0.12 From fdfaf0aba2fe8cc8e985d64bdd929b16a1c37690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Mon, 5 Mar 2012 15:50:37 +0100 Subject: Use source reST role instead of file where it makes sense. source generates a nifty link to the Mercurial web viewer. --- Doc/howto/cporting.rst | 4 ++-- Doc/howto/regex.rst | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/howto/cporting.rst b/Doc/howto/cporting.rst index 98db9dd..bea2153 100644 --- a/Doc/howto/cporting.rst +++ b/Doc/howto/cporting.rst @@ -261,8 +261,8 @@ behave slightly differently from real Capsules. Specifically: copy as you see fit.) You can find :file:`capsulethunk.h` in the Python source distribution -in the :file:`Doc/includes` directory. We also include it here for -your reference; here is :file:`capsulethunk.h`: +as :source:`Doc/includes/capsulethunk.h`. We also include it here for +your convenience: .. literalinclude:: ../includes/capsulethunk.h diff --git a/Doc/howto/regex.rst b/Doc/howto/regex.rst index 07a8b56..3ac03ca 100644 --- a/Doc/howto/regex.rst +++ b/Doc/howto/regex.rst @@ -360,7 +360,7 @@ and more. You can learn about this by interactively experimenting with the :mod:`re` module. If you have :mod:`tkinter` available, you may also want to look at -:file:`Tools/demo/redemo.py`, a demonstration program included with the +:source:`Tools/demo/redemo.py`, a demonstration program included with the Python distribution. It allows you to enter REs and strings, and displays whether the RE matches or fails. :file:`redemo.py` can be quite useful when trying to debug a complicated RE. Phil Schwartz's `Kodos @@ -495,7 +495,7 @@ more convenient. If a program contains a lot of regular expressions, or re-uses the same ones in several locations, then it might be worthwhile to collect all the definitions in one place, in a section of code that compiles all the REs ahead of time. To take an example from the standard library, here's an extract -from the now deprecated :file:`xmllib.py`:: +from the now-defunct Python 2 standard :mod:`xmllib` module:: ref = re.compile( ... ) entityref = re.compile( ... ) -- cgit v0.12 From e5eec7e19898d872147ae55f65676c2f30b9461a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Mon, 5 Mar 2012 16:01:41 +0100 Subject: Move xml.etree higher and xml.parsers.expat lower in the markup ToC. I assume that most users looking at this page are looking for a library to process XML, not a low-level parser. First proposed in #11379. --- Doc/library/markup.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/markup.rst b/Doc/library/markup.rst index 49794ef..1b4cca5 100644 --- a/Doc/library/markup.rst +++ b/Doc/library/markup.rst @@ -23,7 +23,7 @@ definition of the Python bindings for the DOM and SAX interfaces. html.rst html.parser.rst html.entities.rst - pyexpat.rst + xml.etree.elementtree.rst xml.dom.rst xml.dom.minidom.rst xml.dom.pulldom.rst @@ -31,4 +31,4 @@ definition of the Python bindings for the DOM and SAX interfaces. xml.sax.handler.rst xml.sax.utils.rst xml.sax.reader.rst - xml.etree.elementtree.rst + pyexpat.rst -- cgit v0.12 From 400a968dfc18a49139c68a6e7d650d5c8ca683f1 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Mon, 5 Mar 2012 09:03:51 -0600 Subject: remove f_yieldfrom access from Python (closes #13970) --- Objects/frameobject.c | 1 - 1 file changed, 1 deletion(-) diff --git a/Objects/frameobject.c b/Objects/frameobject.c index 9b05b9d..c1ec811 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -20,7 +20,6 @@ static PyMemberDef frame_memberlist[] = { {"f_builtins", T_OBJECT, OFF(f_builtins), READONLY}, {"f_globals", T_OBJECT, OFF(f_globals), READONLY}, {"f_lasti", T_INT, OFF(f_lasti), READONLY}, - {"f_yieldfrom", T_OBJECT, OFF(f_yieldfrom), READONLY}, {NULL} /* Sentinel */ }; -- cgit v0.12 From e413c06f35ba4c58f7b6e8aa6984131e94672831 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Mon, 5 Mar 2012 16:09:29 +0100 Subject: =?UTF-8?q?Make=20distutils=E2=80=99=20upload=20command=20work=20w?= =?UTF-8?q?ith=20bdist=5Fmsi=20products=20(#13719).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch by Ralf Schmitt. --- Lib/distutils/command/bdist_msi.py | 2 +- Lib/distutils/tests/test_bdist_msi.py | 18 +++++++++++++----- Misc/NEWS | 2 ++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Lib/distutils/command/bdist_msi.py b/Lib/distutils/command/bdist_msi.py index b3cfe9c..fde0f63 100644 --- a/Lib/distutils/command/bdist_msi.py +++ b/Lib/distutils/command/bdist_msi.py @@ -260,7 +260,7 @@ class bdist_msi(Command): self.db.Commit() if hasattr(self.distribution, 'dist_files'): - tup = 'bdist_msi', self.target_version or 'any', fullname + tup = 'bdist_msi', self.target_version or 'any', installer_name self.distribution.dist_files.append(tup) if not self.keep_temp: diff --git a/Lib/distutils/tests/test_bdist_msi.py b/Lib/distutils/tests/test_bdist_msi.py index 9308c79..9cbfb0c 100644 --- a/Lib/distutils/tests/test_bdist_msi.py +++ b/Lib/distutils/tests/test_bdist_msi.py @@ -1,12 +1,11 @@ """Tests for distutils.command.bdist_msi.""" -import unittest import sys - +import unittest from test.support import run_unittest - from distutils.tests import support -@unittest.skipUnless(sys.platform=="win32", "These tests are only for win32") + +@unittest.skipUnless(sys.platform == 'win32', 'these tests require Windows') class BDistMSITestCase(support.TempdirManager, support.LoggingSilencer, unittest.TestCase): @@ -14,9 +13,18 @@ class BDistMSITestCase(support.TempdirManager, def test_minimal(self): # minimal test XXX need more tests from distutils.command.bdist_msi import bdist_msi - pkg_pth, dist = self.create_dist() + project_dir, dist = self.create_dist() cmd = bdist_msi(dist) cmd.ensure_finalized() + cmd.run() + + bdists = os.listdir(os.path.join(project_dir, 'dist')) + self.assertEqual(bdists, ['foo-0.1.msi']) + + # bug #13719: upload ignores bdist_msi files + self.assertEqual(dist.dist_files, + [('bdist_msi', 'any', 'dist/foo-0.1.msi')]) + def test_suite(): return unittest.makeSuite(BDistMSITestCase) diff --git a/Misc/NEWS b/Misc/NEWS index cd0024e..250dd81 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -130,6 +130,8 @@ Core and Builtins Library ------- +- Issue #13719: Make the distutils upload command aware of bdist_msi products. + - Issue #14195: An issue that caused weakref.WeakSet instances to incorrectly return True for a WeakSet instance 'a' in both 'a < a' and 'a > a' has been fixed. -- cgit v0.12 From 420f698d6e1785c767ef4c19ed25016351501e30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Mon, 5 Mar 2012 16:11:41 +0100 Subject: Backport minidom attribute tests from default (73c76466cf44). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some minidom code changed between 3.2 and 3.3, so to be sure to avoid differenced in behavior I’m backporting these tests added by MvL. --- Lib/test/test_minidom.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py index f3fa1b8..4a69b00 100644 --- a/Lib/test/test_minidom.py +++ b/Lib/test/test_minidom.py @@ -350,13 +350,31 @@ class MinidomTest(unittest.TestCase): def testGetAttrList(self): pass - def testGetAttrValues(self): pass + def testGetAttrValues(self): + pass - def testGetAttrLength(self): pass + def testGetAttrLength(self): + pass - def testGetAttribute(self): pass + def testGetAttribute(self): + dom = Document() + child = dom.appendChild( + dom.createElementNS("http://www.python.org", "python:abc")) + self.assertEqual(child.getAttribute('missing'), '') - def testGetAttributeNS(self): pass + def testGetAttributeNS(self): + dom = Document() + child = dom.appendChild( + dom.createElementNS("http://www.python.org", "python:abc")) + child.setAttributeNS("http://www.w3.org", "xmlns:python", + "http://www.python.org") + self.assertEqual(child.getAttributeNS("http://www.w3.org", "python"), + 'http://www.python.org') + self.assertEqual(child.getAttributeNS("http://www.w3.org", "other"), + '') + child2 = child.appendChild(dom.createElement('abc')) + self.assertEqual(child2.getAttributeNS("http://www.python.org", "missing"), + '') def testGetAttributeNode(self): pass -- cgit v0.12 From 80f7102d439446f6e1cf9abacfc5b4eac3796cea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Mon, 5 Mar 2012 16:16:37 +0100 Subject: Improve packaging.database documentation --- Doc/library/packaging.database.rst | 45 ++++++++++++++++++++++++++++---------- Lib/packaging/database.py | 1 + 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/Doc/library/packaging.database.rst b/Doc/library/packaging.database.rst index aaa2cb9..9d750f0 100644 --- a/Doc/library/packaging.database.rst +++ b/Doc/library/packaging.database.rst @@ -15,6 +15,11 @@ Installed Python distributions are represented by instances of Most functions also provide an extra argument ``use_egg_info`` to take legacy distributions into account. +For the purpose of this module, "installed" means that the distribution's +:file:`.dist-info`, :file:`.egg-info` or :file:`egg` directory or file is found +on :data:`sys.path`. For example, if the parent directory of a +:file:`dist-info` directory is added to :envvar:`PYTHONPATH`, then it will be +available in the database. Classes representing installed distributions -------------------------------------------- @@ -128,7 +133,7 @@ Functions to work with the database for the first installed distribution matching *name*. Egg distributions are considered only if *use_egg_info* is true; if both a dist-info and an egg file are found, the dist-info prevails. The directories to be searched are - given in *paths*, which defaults to :data:`sys.path`. Return ``None`` if no + given in *paths*, which defaults to :data:`sys.path`. Returns ``None`` if no matching distribution is found. .. FIXME param should be named use_egg @@ -200,20 +205,23 @@ functions: Examples -------- -Print all information about a distribution -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Printing all information about a distribution +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Given a path to a ``.dist-info`` distribution, we shall print out all +Given the name of an installed distribution, we shall print out all information that can be obtained using functions provided in this module:: import sys import packaging.database - path = input() - # first create the Distribution instance try: - dist = packaging.database.Distribution(path) - except FileNotFoundError: + name = sys.argv[1] + except ValueError: + sys.exit('Not enough arguments') + + # first create the Distribution instance + dist = packaging.database.Distribution(path) + if dist is None: sys.exit('No such distribution') print('Information about %r' % dist.name) @@ -244,7 +252,7 @@ information from a :file:`.dist-info` directory. By typing in the console: .. code-block:: sh - $ echo /tmp/choxie/choxie-2.0.0.9.dist-info | python3 print_info.py + python print_info.py choxie we get the following output: @@ -299,10 +307,23 @@ we get the following output: * It was installed as a dependency -Find out obsoleted distributions -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Getting metadata about a distribution +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Sometimes you're not interested about the packaging information contained in a +full :class:`Distribution` object but just want to do something with its +:attr:`~Distribution.metadata`:: + + >>> from packaging.database import get_distribution + >>> info = get_distribution('chocolate').metadata + >>> info['Keywords'] + ['cooking', 'happiness'] + + +Finding out obsoleted distributions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Now, we take tackle a different problem, we are interested in finding out +Now, we tackle a different problem, we are interested in finding out which distributions have been obsoleted. This can be easily done as follows:: import packaging.database diff --git a/Lib/packaging/database.py b/Lib/packaging/database.py index b2fcb97..e028dc5 100644 --- a/Lib/packaging/database.py +++ b/Lib/packaging/database.py @@ -19,6 +19,7 @@ __all__ = [ 'get_distributions', 'get_distribution', 'get_file_users', 'provides_distribution', 'obsoletes_distribution', 'enable_cache', 'disable_cache', 'clear_cache', + # XXX these functions' names look like get_file_users but are not related 'get_file_path', 'get_file'] -- cgit v0.12 From c3705d3ac4247b3ac5aac42fa0ed39eb490f9b11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Mon, 5 Mar 2012 17:02:31 +0100 Subject: Fix NameError from #13719 fix --- Lib/distutils/tests/test_bdist_msi.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/distutils/tests/test_bdist_msi.py b/Lib/distutils/tests/test_bdist_msi.py index 9cbfb0c..e599461 100644 --- a/Lib/distutils/tests/test_bdist_msi.py +++ b/Lib/distutils/tests/test_bdist_msi.py @@ -1,4 +1,5 @@ """Tests for distutils.command.bdist_msi.""" +import os import sys import unittest from test.support import run_unittest -- cgit v0.12 From b8e280d225568ea07a02e3e6b94667bd764f9695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Mon, 5 Mar 2012 17:04:07 +0100 Subject: =?UTF-8?q?Make=20packaging=E2=80=99=20upload=20command=20work=20w?= =?UTF-8?q?ith=20bdist=5Fmsi=20products=20(#13719)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Lib/packaging/command/bdist_msi.py | 2 +- Lib/packaging/tests/test_command_bdist_msi.py | 13 +++++++++++-- Misc/NEWS | 3 ++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Lib/packaging/command/bdist_msi.py b/Lib/packaging/command/bdist_msi.py index 995eec5..ad1edef 100644 --- a/Lib/packaging/command/bdist_msi.py +++ b/Lib/packaging/command/bdist_msi.py @@ -261,7 +261,7 @@ class bdist_msi(Command): self.db.Commit() if hasattr(self.distribution, 'dist_files'): - tup = 'bdist_msi', self.target_version or 'any', fullname + tup = 'bdist_msi', self.target_version or 'any', installer_name self.distribution.dist_files.append(tup) if not self.keep_temp: diff --git a/Lib/packaging/tests/test_command_bdist_msi.py b/Lib/packaging/tests/test_command_bdist_msi.py index fded962..25973ef 100644 --- a/Lib/packaging/tests/test_command_bdist_msi.py +++ b/Lib/packaging/tests/test_command_bdist_msi.py @@ -1,20 +1,29 @@ """Tests for distutils.command.bdist_msi.""" +import os import sys from packaging.tests import unittest, support +@unittest.skipUnless(sys.platform == 'win32', 'these tests require Windows') class BDistMSITestCase(support.TempdirManager, support.LoggingCatcher, unittest.TestCase): - @unittest.skipUnless(sys.platform == "win32", "runs only on win32") def test_minimal(self): # minimal test XXX need more tests from packaging.command.bdist_msi import bdist_msi - pkg_pth, dist = self.create_dist() + project_dir, dist = self.create_dist() cmd = bdist_msi(dist) cmd.ensure_finalized() + cmd.run() + + bdists = os.listdir(os.path.join(project_dir, 'dist')) + self.assertEqual(bdists, ['foo-0.1.msi']) + + # bug #13719: upload ignores bdist_msi files + self.assertEqual(dist.dist_files, + [('bdist_msi', 'any', 'dist/foo-0.1.msi')]) def test_suite(): diff --git a/Misc/NEWS b/Misc/NEWS index e2455c8..52fd990 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -13,7 +13,8 @@ Core and Builtins Library ------- -- Issue #13719: Make the distutils upload command aware of bdist_msi products. +- Issue #13719: Make the distutils and packaging upload commands aware of + bdist_msi products. - Issue #14007: Accept incomplete TreeBuilder objects (missing start, end, data or close method) for the Python implementation as well. -- cgit v0.12