mirror of https://github.com/python/cpython
Merge
This commit is contained in:
commit
22e7c88057
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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])
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
Loading…
Reference in New Issue