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

brett.cannon python-checkins at python.org
Fri Feb 17 00:03:53 CET 2012


http://hg.python.org/cpython/rev/83e833f70977
changeset:   74993:83e833f70977
parent:      74992:45a2bbf6c752
parent:      74991:cdc9e0238b1d
user:        Brett Cannon <brett at python.org>
date:        Thu Feb 16 18:03:47 2012 -0500
summary:
  Merge

files:
  Doc/includes/sqlite3/shortcut_methods.py |   3 +-
  Doc/library/sqlite3.rst                  |  11 ++--
  Lib/test/test_sched.py                   |  28 ++++++-----
  Lib/test/test_xml_etree.py               |   8 +---
  Lib/test/test_xml_etree_c.py             |   5 +-
  Lib/xml/etree/ElementTree.py             |   2 +
  Misc/NEWS                                |   4 +-
  7 files changed, 30 insertions(+), 31 deletions(-)


diff --git a/Doc/includes/sqlite3/shortcut_methods.py b/Doc/includes/sqlite3/shortcut_methods.py
--- a/Doc/includes/sqlite3/shortcut_methods.py
+++ b/Doc/includes/sqlite3/shortcut_methods.py
@@ -17,5 +17,4 @@
 for row in con.execute("select firstname, lastname from person"):
     print(row)
 
-# Using a dummy WHERE clause to not let SQLite take the shortcut table deletes.
-print("I just deleted", con.execute("delete from person where 1=1").rowcount, "rows")
+print("I just deleted", con.execute("delete from person").rowcount, "rows")
diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst
--- a/Doc/library/sqlite3.rst
+++ b/Doc/library/sqlite3.rst
@@ -555,18 +555,17 @@
    attribute, the database engine's own support for the determination of "rows
    affected"/"rows selected" is quirky.
 
-   For ``DELETE`` statements, SQLite reports :attr:`rowcount` as 0 if you make a
-   ``DELETE FROM table`` without any condition.
-
    For :meth:`executemany` statements, the number of modifications are summed up
    into :attr:`rowcount`.
 
    As required by the Python DB API Spec, the :attr:`rowcount` attribute "is -1 in
    case no ``executeXX()`` has been performed on the cursor or the rowcount of the
-   last operation is not determinable by the interface".
+   last operation is not determinable by the interface". This includes ``SELECT``
+   statements because we cannot determine the number of rows a query produced
+   until all rows were fetched.
 
-   This includes ``SELECT`` statements because we cannot determine the number of
-   rows a query produced until all rows were fetched.
+   With SQLite versions before 3.6.5, :attr:`rowcount` is set to 0 if
+   you make a ``DELETE FROM table`` without any condition.
 
 .. attribute:: Cursor.lastrowid
 
diff --git a/Lib/test/test_sched.py b/Lib/test/test_sched.py
--- a/Lib/test/test_sched.py
+++ b/Lib/test/test_sched.py
@@ -12,10 +12,10 @@
         l = []
         fun = lambda x: l.append(x)
         scheduler = sched.scheduler(time.time, time.sleep)
-        for x in [0.05, 0.04, 0.03, 0.02, 0.01]:
+        for x in [0.5, 0.4, 0.3, 0.2, 0.1]:
             z = scheduler.enter(x, 1, fun, (x,))
         scheduler.run()
-        self.assertEqual(l, [0.01, 0.02, 0.03, 0.04, 0.05])
+        self.assertEqual(l, [0.1, 0.2, 0.3, 0.4, 0.5])
 
     def test_enterabs(self):
         l = []
@@ -31,7 +31,7 @@
         fun = lambda x: l.append(x)
         scheduler = sched.scheduler(time.time, time.sleep)
         for priority in [1, 2, 3, 4, 5]:
-            z = scheduler.enter(0.01, priority, fun, (priority,))
+            z = scheduler.enterabs(0.01, priority, fun, (priority,))
         scheduler.run()
         self.assertEqual(l, [1, 2, 3, 4, 5])
 
@@ -39,11 +39,12 @@
         l = []
         fun = lambda x: l.append(x)
         scheduler = sched.scheduler(time.time, time.sleep)
-        event1 = scheduler.enter(0.01, 1, fun, (0.01,))
-        event2 = scheduler.enter(0.02, 1, fun, (0.02,))
-        event3 = scheduler.enter(0.03, 1, fun, (0.03,))
-        event4 = scheduler.enter(0.04, 1, fun, (0.04,))
-        event5 = scheduler.enter(0.05, 1, fun, (0.05,))
+        now = time.time()
+        event1 = scheduler.enterabs(now + 0.01, 1, fun, (0.01,))
+        event2 = scheduler.enterabs(now + 0.02, 1, fun, (0.02,))
+        event3 = scheduler.enterabs(now + 0.03, 1, fun, (0.03,))
+        event4 = scheduler.enterabs(now + 0.04, 1, fun, (0.04,))
+        event5 = scheduler.enterabs(now + 0.05, 1, fun, (0.05,))
         scheduler.cancel(event1)
         scheduler.cancel(event5)
         scheduler.run()
@@ -64,11 +65,12 @@
         l = []
         fun = lambda x: l.append(x)
         scheduler = sched.scheduler(time.time, time.sleep)
-        e5 = scheduler.enter(0.05, 1, fun)
-        e1 = scheduler.enter(0.01, 1, fun)
-        e2 = scheduler.enter(0.02, 1, fun)
-        e4 = scheduler.enter(0.04, 1, fun)
-        e3 = scheduler.enter(0.03, 1, fun)
+        now = time.time()
+        e5 = scheduler.enterabs(now + 0.05, 1, fun)
+        e1 = scheduler.enterabs(now + 0.01, 1, fun)
+        e2 = scheduler.enterabs(now + 0.02, 1, fun)
+        e4 = scheduler.enterabs(now + 0.04, 1, fun)
+        e3 = scheduler.enterabs(now + 0.03, 1, fun)
         # queue property is supposed to return an order list of
         # upcoming events
         self.assertEqual(list(scheduler.queue), [e1, e2, e3, e4, e5])
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
@@ -1352,7 +1352,6 @@
     r"""
     Basic inclusion example (XInclude C.1)
 
-    >>> from xml.etree import ElementTree as ET
     >>> from xml.etree import ElementInclude
 
     >>> document = xinclude_loader("C1.xml")
@@ -1882,12 +1881,7 @@
 
     def __enter__(self):
         from xml.etree import ElementPath
-        if hasattr(ET, '_namespace_map'):
-            self._nsmap = ET._namespace_map
-        else:
-            # when testing the cElementTree alias
-            from xml.etree.ElementTree import _namespace_map
-            self._nsmap = _namespace_map
+        self._nsmap = ET.register_namespace._namespace_map
         # Copy the default namespace mapping
         self._nsmap_copy = self._nsmap.copy()
         # Copy the path cache (should be empty)
diff --git a/Lib/test/test_xml_etree_c.py b/Lib/test/test_xml_etree_c.py
--- a/Lib/test/test_xml_etree_c.py
+++ b/Lib/test/test_xml_etree_c.py
@@ -5,7 +5,7 @@
 import unittest
 
 cET = import_fresh_module('xml.etree.ElementTree', fresh=['_elementtree'])
-cET_alias = import_fresh_module('xml.etree.cElementTree', fresh=['_elementtree'])
+cET_alias = import_fresh_module('xml.etree.cElementTree', fresh=['_elementtree', 'xml.etree'])
 
 
 # cElementTree specific tests
@@ -52,6 +52,9 @@
     def test_correct_import_cET(self):
         self.assertEqual(cET.Element.__module__, '_elementtree')
 
+    def test_correct_import_cET_alias(self):
+        self.assertEqual(cET_alias.Element.__module__, '_elementtree')
+
 
 def test_main():
     from test import test_xml_etree, test_xml_etree_c
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
@@ -1086,6 +1086,8 @@
     # dublin core
     "http://purl.org/dc/elements/1.1/": "dc",
 }
+# For tests and troubleshooting
+register_namespace._namespace_map = _namespace_map
 
 def _raise_serialization_error(text):
     raise TypeError(
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -2261,8 +2261,8 @@
 Documentation
 -------------
 
-- Issue #13491: Fix many errors in sqlite3 documentation. Initial
-  patch by Johannes Vogel.
+- Issues #13491 and #13995: Fix many errors in sqlite3 documentation.
+  Initial patch for #13491 by Johannes Vogel.
 
 - Issue #13402: Document absoluteness of sys.executable.
 

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


More information about the Python-checkins mailing list