summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2012-02-16 23:03:47 (GMT)
committerBrett Cannon <brett@python.org>2012-02-16 23:03:47 (GMT)
commit22e7c88057ee91ded2bd9853a6b67846c34d392f (patch)
tree3241f635caa35ea9bd18bd5f1617e3e6b705efe7
parent3b1a06c1eaec92242683b0a3460377e03cb6c214 (diff)
parent1639505c383a1c8b46ff6f2a5b9071f26ad43ece (diff)
downloadcpython-22e7c88057ee91ded2bd9853a6b67846c34d392f.zip
cpython-22e7c88057ee91ded2bd9853a6b67846c34d392f.tar.gz
cpython-22e7c88057ee91ded2bd9853a6b67846c34d392f.tar.bz2
Merge
-rw-r--r--Doc/includes/sqlite3/shortcut_methods.py3
-rw-r--r--Doc/library/sqlite3.rst11
-rw-r--r--Lib/test/test_sched.py28
-rw-r--r--Lib/test/test_xml_etree.py8
-rw-r--r--Lib/test/test_xml_etree_c.py5
-rw-r--r--Lib/xml/etree/ElementTree.py2
-rw-r--r--Misc/NEWS4
7 files changed, 30 insertions, 31 deletions
diff --git a/Doc/includes/sqlite3/shortcut_methods.py b/Doc/includes/sqlite3/shortcut_methods.py
index 596d87c..71600d4 100644
--- a/Doc/includes/sqlite3/shortcut_methods.py
+++ b/Doc/includes/sqlite3/shortcut_methods.py
@@ -17,5 +17,4 @@ con.executemany("insert into person(firstname, lastname) values (?, ?)", persons
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
index 2eb4614..edd2a00 100644
--- a/Doc/library/sqlite3.rst
+++ b/Doc/library/sqlite3.rst
@@ -555,18 +555,17 @@ Cursor Objects
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
index ae82f94..50ada52 100644
--- a/Lib/test/test_sched.py
+++ b/Lib/test/test_sched.py
@@ -12,10 +12,10 @@ class TestCase(unittest.TestCase):
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 @@ class TestCase(unittest.TestCase):
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 @@ class TestCase(unittest.TestCase):
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 @@ class TestCase(unittest.TestCase):
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
index 6060e06..58fdcd4 100644
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -1352,7 +1352,6 @@ def xinclude():
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 @@ class CleanContext(object):
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
index dbe1c3a..a73d0c4 100644
--- a/Lib/test/test_xml_etree_c.py
+++ b/Lib/test/test_xml_etree_c.py
@@ -5,7 +5,7 @@ from test.support import import_fresh_module
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 @@ class TestAcceleratorImported(unittest.TestCase):
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
index 93147eb..defef0d 100644
--- a/Lib/xml/etree/ElementTree.py
+++ b/Lib/xml/etree/ElementTree.py
@@ -1086,6 +1086,8 @@ _namespace_map = {
# 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
index 786417f..b2cf410 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -2261,8 +2261,8 @@ C-API
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.