[Python-checkins] cpython (merge default -> default): merge

christian.heimes python-checkins at python.org
Thu Sep 20 12:43:58 CEST 2012


http://hg.python.org/cpython/rev/dcced3bd22fe
changeset:   79064:dcced3bd22fe
parent:      79063:2bdc8c8ea42e
parent:      79061:ddec854843f1
user:        Christian Heimes <christian at cheimes.de>
date:        Thu Sep 20 12:43:24 2012 +0200
summary:
  merge

files:
  Doc/c-api/import.rst                 |   2 +-
  Doc/faq/windows.rst                  |  10 ++++----
  Doc/library/doctest.rst              |   2 +-
  Doc/library/pyexpat.rst              |   2 +-
  Doc/library/smtpd.rst                |  13 +++++----
  Doc/library/timeit.rst               |  20 ++++++++--------
  Doc/tools/sphinxext/susp-ignored.csv |   3 +-
  Doc/whatsnew/3.3.rst                 |   9 ++++---
  Lib/test/test_xml_etree.py           |  12 +++++++++
  Lib/xml/etree/ElementTree.py         |   2 +-
  Misc/NEWS                            |   6 ++++
  Modules/_io/_iomodule.c              |   2 +-
  Modules/_io/iobase.c                 |   2 +-
  Modules/_io/textio.c                 |   2 +-
  Modules/posixmodule.c                |   9 ++++++-
  Objects/typeobject.c                 |   6 ++--
  16 files changed, 64 insertions(+), 38 deletions(-)


diff --git a/Doc/c-api/import.rst b/Doc/c-api/import.rst
--- a/Doc/c-api/import.rst
+++ b/Doc/c-api/import.rst
@@ -76,7 +76,7 @@
    UTF-8 encoded string instead of a Unicode object.
 
    .. versionchanged:: 3.3
-         Negative values for **level** are no longer accepted.
+         Negative values for *level* are no longer accepted.
 
 .. c:function:: PyObject* PyImport_Import(PyObject *name)
 
diff --git a/Doc/faq/windows.rst b/Doc/faq/windows.rst
--- a/Doc/faq/windows.rst
+++ b/Doc/faq/windows.rst
@@ -464,13 +464,13 @@
 Why does os.path.isdir() fail on NT shared directories?
 -------------------------------------------------------
 
-The solution appears to be always append the "\\" on the end of shared
-drives.
+In order to work correctly, :func:`os.path.isdir` requires a ``"\\"`` at the
+end of the shared drive::
 
    >>> import os
-   >>> os.path.isdir( '\\\\rorschach\\public')
+   >>> os.path.isdir('\\\\rorschach\\public')
    0
-   >>> os.path.isdir( '\\\\rorschach\\public\\')
+   >>> os.path.isdir('\\\\rorschach\\public\\')
    1
 
 It helps to think of share points as being like drive letters.  Example::
@@ -480,7 +480,7 @@
    k:\media is a directory
    k:\media\ is not a directory
 
-The same rules apply if you substitute "k:" with "\\conky\foo"::
+The same rules apply if you substitute ``"k:"`` with ``"\\conky\foo"``::
 
    \\conky\foo  is not a directory
    \\conky\foo\ is a directory
diff --git a/Doc/library/doctest.rst b/Doc/library/doctest.rst
--- a/Doc/library/doctest.rst
+++ b/Doc/library/doctest.rst
@@ -338,7 +338,7 @@
      Backslashes in a raw docstring: m\n
 
   Otherwise, the backslash will be interpreted as part of the string. For example,
-  the "\\" above would be interpreted as a newline character.  Alternatively, you
+  the ``\n`` above would be interpreted as a newline character.  Alternatively, you
   can double each backslash in the doctest version (and not use a raw string)::
 
      >>> def f(x):
diff --git a/Doc/library/pyexpat.rst b/Doc/library/pyexpat.rst
--- a/Doc/library/pyexpat.rst
+++ b/Doc/library/pyexpat.rst
@@ -402,7 +402,7 @@
 .. method:: xmlparser.CommentHandler(data)
 
    Called for comments.  *data* is the text of the comment, excluding the leading
-   '``<!-``\ ``-``' and trailing '``-``\ ``->``'.
+   ``'<!-``\ ``-'`` and trailing ``'-``\ ``->'``.
 
 
 .. method:: xmlparser.StartCdataSectionHandler()
diff --git a/Doc/library/smtpd.rst b/Doc/library/smtpd.rst
--- a/Doc/library/smtpd.rst
+++ b/Doc/library/smtpd.rst
@@ -111,12 +111,13 @@
    .. attribute:: addr
 
       Holds the address of the client, the second value returned by
-      socket.accept()
+      :func:`socket.accept <socket.socket.accept>`
 
    .. attribute:: received_lines
 
       Holds a list of the line strings (decoded using UTF-8) received from
-      the client. The lines have their "\\r\\n" line ending translated to "\\n".
+      the client. The lines have their ``"\r\n"`` line ending translated to
+      ``"\n"``.
 
    .. attribute:: smtp_state
 
@@ -141,12 +142,12 @@
    .. attribute:: received_data
 
       Holds a string containing all of the data sent by the client during the
-      DATA state, up to but not including the terminating "\r\n.\r\n".
+      DATA state, up to but not including the terminating ``"\r\n.\r\n"``.
 
    .. attribute:: fqdn
 
       Holds the fully-qualified domain name of the server as returned by
-      ``socket.getfqdn()``.
+      :func:`socket.getfqdn`.
 
    .. attribute:: peer
 
@@ -170,14 +171,14 @@
    MAIL     Accepts the "MAIL FROM:" syntax and stores the supplied address as
             :attr:`mailfrom`.  In extended command mode, accepts the
             :rfc:`1870` SIZE attribute and responds appropriately based on the
-            value of ``data_size_limit``.
+            value of *data_size_limit*.
    RCPT     Accepts the "RCPT TO:" syntax and stores the supplied addresses in
             the :attr:`rcpttos` list.
    RSET     Resets the :attr:`mailfrom`, :attr:`rcpttos`, and
             :attr:`received_data`, but not the greeting.
    DATA     Sets the internal state to :attr:`DATA` and stores remaining lines
             from the client in :attr:`received_data` until the terminator
-            "\r\n.\r\n" is received.
+            ``"\r\n.\r\n"`` is received.
    HELP     Returns minimal information on command syntax
    VRFY     Returns code 252 (the server doesn't know if the address is valid)
    EXPN     Reports that the command is not implemented.
diff --git a/Doc/library/timeit.rst b/Doc/library/timeit.rst
--- a/Doc/library/timeit.rst
+++ b/Doc/library/timeit.rst
@@ -31,13 +31,13 @@
    may also contain multiple statements separated by ``;`` or newlines, as long as
    they don't contain multi-line string literals.
 
-   To measure the execution time of the first statement, use the :meth:`timeit`
-   method.  The :meth:`repeat` method is a convenience to call :meth:`timeit`
+   To measure the execution time of the first statement, use the :meth:`Timer.timeit`
+   method.  The :meth:`repeat` method is a convenience to call :meth:`.timeit`
    multiple times and return a list of results.
 
    The *stmt* and *setup* parameters can also take objects that are callable
    without arguments. This will embed calls to them in a timer function that
-   will then be executed by :meth:`timeit`.  Note that the timing overhead is a
+   will then be executed by :meth:`.timeit`.  Note that the timing overhead is a
    little larger in this case because of the extra function calls.
 
 
@@ -60,12 +60,12 @@
 
 .. method:: Timer.repeat(repeat=3, number=1000000)
 
-   Call :meth:`timeit` a few times.
+   Call :meth:`.timeit` a few times.
 
-   This is a convenience function that calls the :meth:`timeit` repeatedly,
+   This is a convenience function that calls the :meth:`.timeit` repeatedly,
    returning a list of results.  The first argument specifies how many times to
-   call :meth:`timeit`.  The second argument specifies the *number* argument for
-   :func:`timeit`.
+   call :meth:`.timeit`.  The second argument specifies the *number* argument for
+   :meth:`.timeit`.
 
    .. note::
 
@@ -89,7 +89,7 @@
 
    .. note::
 
-      By default, :meth:`timeit` temporarily turns off :term:`garbage collection`
+      By default, :meth:`.timeit` temporarily turns off :term:`garbage collection`
       during the timing.  The advantage of this approach is that it makes
       independent timings more comparable.  This disadvantage is that GC may be
       an important component of the performance of the function being measured.
@@ -117,7 +117,7 @@
 .. function:: timeit(stmt='pass', setup='pass', timer=<default timer>, number=1000000)
 
    Create a :class:`Timer` instance with the given statement, setup code and timer
-   function and run its :meth:`timeit` method with *number* executions.
+   function and run its :meth:`.timeit` method with *number* executions.
 
 
 Command Line Interface
@@ -243,7 +243,7 @@
    3.15 usec/pass
 
 To give the :mod:`timeit` module access to functions you define, you can pass a
-``setup`` parameter which contains an import statement::
+*setup* parameter which contains an import statement::
 
    def test():
        """Stupid test function"""
diff --git a/Doc/tools/sphinxext/susp-ignored.csv b/Doc/tools/sphinxext/susp-ignored.csv
--- a/Doc/tools/sphinxext/susp-ignored.csv
+++ b/Doc/tools/sphinxext/susp-ignored.csv
@@ -124,9 +124,8 @@
 library/functions,,:stop,"a[start:stop, i]"
 library/functions,,:stop,a[start:stop:step]
 library/hotshot,,:lineno,"ncalls  tottime  percall  cumtime  percall filename:lineno(function)"
-library/http.client,52,:port,host:port
+library/http.client,,:port,host:port
 library/http.cookies,,`,!#$%&'*+-.^_`|~:
-library/httplib,,:port,host:port
 library/imaplib,,:MM,"""DD-Mmm-YYYY HH:MM:SS"
 library/imaplib,,:SS,"""DD-Mmm-YYYY HH:MM:SS"
 library/inspect,,:int,">>> def foo(a, *, b:int, **kwargs):"
diff --git a/Doc/whatsnew/3.3.rst b/Doc/whatsnew/3.3.rst
--- a/Doc/whatsnew/3.3.rst
+++ b/Doc/whatsnew/3.3.rst
@@ -69,6 +69,7 @@
 * :mod:`faulthandler` (helps debugging low-level crashes)
 * :mod:`ipaddress` (high-level objects representing IP addresses and masks)
 * :mod:`lzma` (compress data using the XZ / LZMA algorithm)
+* :mod:`unittest.mock` (replace parts of your system under test with mock objects)
 * :mod:`venv` (Python :ref:`virtual environments <pep-405>`, as in the
   popular ``virtualenv`` package)
 
@@ -923,7 +924,7 @@
 faulthandler
 ------------
 
-This new debug module contains functions to dump Python tracebacks explicitly,
+This new debug module :mod:`faulthandler` contains functions to dump Python tracebacks explicitly,
 on a fault (a crash like a segmentation fault), after a timeout, or on a user
 signal. Call :func:`faulthandler.enable` to install fault handlers for the
 :const:`SIGSEGV`, :const:`SIGFPE`, :const:`SIGABRT`, :const:`SIGBUS`, and
@@ -1927,7 +1928,7 @@
   updated to use the full name of the module instead of just the tail of the
   name.
 
-* The **index** argument to :func:`__import__` now defaults to 0 instead of -1
+* The *index* argument to :func:`__import__` now defaults to 0 instead of -1
   and no longer support negative values. It was an oversight when :pep:`328` was
   implemented that the default value remained -1. If you need to continue to
   perform a relative import followed by an absolute import, then perform the
@@ -1995,9 +1996,9 @@
 
 * :c:func:`PyImport_GetMagicNumber` now returns -1 upon failure.
 
-* As a negative value for the **level** argument to :func:`__import__` is no
+* As a negative value for the *level* argument to :func:`__import__` is no
   longer valid, the same now holds for :c:func:`PyImport_ImportModuleLevel`.
-  This also means that the value of **level** used by
+  This also means that the value of *level* used by
   :c:func:`PyImport_ImportModuleEx` is now 0 instead of -1.
 
 
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -1809,6 +1809,18 @@
         mye = MyElement('joe')
         self.assertEqual(mye.newmethod(), 'joe')
 
+    def test_html_empty_elems_serialization(self):
+        # issue 15970
+        # from http://www.w3.org/TR/html401/index/elements.html
+        for element in ['AREA', 'BASE', 'BASEFONT', 'BR', 'COL', 'FRAME', 'HR',
+                        'IMG', 'INPUT', 'ISINDEX', 'LINK', 'META', 'PARAM']:
+            for elem in [element, element.lower()]:
+                expected = '<%s>' % elem
+                serialized = serialize(ET.XML('<%s />' % elem), method='html')
+                self.assertEqual(serialized, expected)
+                serialized = serialize(ET.XML('<%s></%s>' % (elem,elem)),
+                                       method='html')
+                self.assertEqual(serialized, expected)
 
 class ElementIterTest(unittest.TestCase):
     def _ilist(self, elem, tag=None):
diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py
--- a/Lib/xml/etree/ElementTree.py
+++ b/Lib/xml/etree/ElementTree.py
@@ -995,7 +995,7 @@
         write(_escape_cdata(elem.tail))
 
 HTML_EMPTY = ("area", "base", "basefont", "br", "col", "frame", "hr",
-              "img", "input", "isindex", "link", "meta" "param")
+              "img", "input", "isindex", "link", "meta", "param")
 
 try:
     HTML_EMPTY = set(HTML_EMPTY)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
 Core and Builtins
 -----------------
 
+- Issue #15965: Explicitly cast AT_FDCWD as (int).  Required on Solaris 10
+  (which defines AT_FDCWD as 0xffd19553), harmless on other platforms.
+
 - Issue #15926: Fix crash after multiple reinitializations of the interpreter.
 
 - Issue #15895: Fix FILE pointer leak in one error branch of
@@ -29,6 +32,9 @@
 Library
 -------
 
+- Issue #15970: xml.etree.ElementTree now serializes correctly the empty HTML
+  elements 'meta' and 'param'.
+
 - Issue #15842: the SocketIO.{readable,writable,seekable} methods now
   raise ValueError when the file-like object is closed.  Patch by Alessandro
   Moura.
diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c
--- a/Modules/_io/_iomodule.c
+++ b/Modules/_io/_iomodule.c
@@ -185,7 +185,7 @@
 "\n"
 "* On output, if newline is None, any '\\n' characters written are\n"
 "  translated to the system default line separator, os.linesep. If\n"
-"  newline is '' or '\n', no translation takes place. If newline is any\n"
+"  newline is '' or '\\n', no translation takes place. If newline is any\n"
 "  of the other legal values, any '\\n' characters written are translated\n"
 "  to the given string.\n"
 "\n"
diff --git a/Modules/_io/iobase.c b/Modules/_io/iobase.c
--- a/Modules/_io/iobase.c
+++ b/Modules/_io/iobase.c
@@ -442,7 +442,7 @@
     "\n"
     "If limit is specified, at most limit bytes will be read.\n"
     "\n"
-    "The line terminator is always b'\n' for binary files; for text\n"
+    "The line terminator is always b'\\n' for binary files; for text\n"
     "files, the newlines argument to open can be used to select the line\n"
     "terminator(s) recognized.\n");
 
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -648,7 +648,7 @@
     "\n"
     "* On output, if newline is None, any '\\n' characters written are\n"
     "  translated to the system default line separator, os.linesep. If\n"
-    "  newline is '' or '\n', no translation takes place. If newline is any\n"
+    "  newline is '' or '\\n', no translation takes place. If newline is any\n"
     "  of the other legal values, any '\\n' characters written are translated\n"
     "  to the given string.\n"
     "\n"
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -414,7 +414,14 @@
 
 
 #ifdef AT_FDCWD
-#define DEFAULT_DIR_FD AT_FDCWD
+/*
+ * Why the (int) cast?  Solaris 10 defines AT_FDCWD as 0xffd19553 (-3041965);
+ * without the int cast, the value gets interpreted as uint (4291925331),
+ * which doesn't play nicely with all the initializer lines in this file that
+ * look like this:
+ *      int dir_fd = DEFAULT_DIR_FD;
+ */
+#define DEFAULT_DIR_FD (int)AT_FDCWD
 #else
 #define DEFAULT_DIR_FD (-100)
 #endif
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -5992,7 +5992,7 @@
         descr = _PyType_Lookup(type, p->name_strobj);
         if (descr == NULL) {
             if (ptr == (void**)&type->tp_iternext) {
-                specific = _PyObject_NextNotImplemented;
+                specific = (void *)_PyObject_NextNotImplemented;
             }
             continue;
         }
@@ -6039,7 +6039,7 @@
             /* We specifically allow __hash__ to be set to None
                to prevent inheritance of the default
                implementation from object.__hash__ */
-            specific = PyObject_HashNotImplemented;
+            specific = (void *)PyObject_HashNotImplemented;
         }
         else {
             use_generic = 1;
@@ -6254,7 +6254,7 @@
             continue;
         if (PyDict_GetItem(dict, p->name_strobj))
             continue;
-        if (*ptr == PyObject_HashNotImplemented) {
+        if (*ptr == (void *)PyObject_HashNotImplemented) {
             /* Classes may prevent the inheritance of the tp_hash
                slot by storing PyObject_HashNotImplemented in it. Make it
                visible as a None value for the __hash__ attribute. */

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list