Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 22e7c88

Browse files
committed
Merge
2 parents 3b1a06c + 1639505 commit 22e7c88

7 files changed

Lines changed: 30 additions & 31 deletions

File tree

Doc/includes/sqlite3/shortcut_methods.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,4 @@
1717
for row in con.execute("select firstname, lastname from person"):
1818
print(row)
1919

20-
# Using a dummy WHERE clause to not let SQLite take the shortcut table deletes.
21-
print("I just deleted", con.execute("delete from person where 1=1").rowcount, "rows")
20+
print("I just deleted", con.execute("delete from person").rowcount, "rows")

Doc/library/sqlite3.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -555,18 +555,17 @@ Cursor Objects
555555
attribute, the database engine's own support for the determination of "rows
556556
affected"/"rows selected" is quirky.
557557

558-
For ``DELETE`` statements, SQLite reports :attr:`rowcount` as 0 if you make a
559-
``DELETE FROM table`` without any condition.
560-
561558
For :meth:`executemany` statements, the number of modifications are summed up
562559
into :attr:`rowcount`.
563560

564561
As required by the Python DB API Spec, the :attr:`rowcount` attribute "is -1 in
565562
case no ``executeXX()`` has been performed on the cursor or the rowcount of the
566-
last operation is not determinable by the interface".
563+
last operation is not determinable by the interface". This includes ``SELECT``
564+
statements because we cannot determine the number of rows a query produced
565+
until all rows were fetched.
567566

568-
This includes ``SELECT`` statements because we cannot determine the number of
569-
rows a query produced until all rows were fetched.
567+
With SQLite versions before 3.6.5, :attr:`rowcount` is set to 0 if
568+
you make a ``DELETE FROM table`` without any condition.
570569

571570
.. attribute:: Cursor.lastrowid
572571

Lib/test/test_sched.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ def test_enter(self):
1212
l = []
1313
fun = lambda x: l.append(x)
1414
scheduler = sched.scheduler(time.time, time.sleep)
15-
for x in [0.05, 0.04, 0.03, 0.02, 0.01]:
15+
for x in [0.5, 0.4, 0.3, 0.2, 0.1]:
1616
z = scheduler.enter(x, 1, fun, (x,))
1717
scheduler.run()
18-
self.assertEqual(l, [0.01, 0.02, 0.03, 0.04, 0.05])
18+
self.assertEqual(l, [0.1, 0.2, 0.3, 0.4, 0.5])
1919

2020
def test_enterabs(self):
2121
l = []
@@ -31,19 +31,20 @@ def test_priority(self):
3131
fun = lambda x: l.append(x)
3232
scheduler = sched.scheduler(time.time, time.sleep)
3333
for priority in [1, 2, 3, 4, 5]:
34-
z = scheduler.enter(0.01, priority, fun, (priority,))
34+
z = scheduler.enterabs(0.01, priority, fun, (priority,))
3535
scheduler.run()
3636
self.assertEqual(l, [1, 2, 3, 4, 5])
3737

3838
def test_cancel(self):
3939
l = []
4040
fun = lambda x: l.append(x)
4141
scheduler = sched.scheduler(time.time, time.sleep)
42-
event1 = scheduler.enter(0.01, 1, fun, (0.01,))
43-
event2 = scheduler.enter(0.02, 1, fun, (0.02,))
44-
event3 = scheduler.enter(0.03, 1, fun, (0.03,))
45-
event4 = scheduler.enter(0.04, 1, fun, (0.04,))
46-
event5 = scheduler.enter(0.05, 1, fun, (0.05,))
42+
now = time.time()
43+
event1 = scheduler.enterabs(now + 0.01, 1, fun, (0.01,))
44+
event2 = scheduler.enterabs(now + 0.02, 1, fun, (0.02,))
45+
event3 = scheduler.enterabs(now + 0.03, 1, fun, (0.03,))
46+
event4 = scheduler.enterabs(now + 0.04, 1, fun, (0.04,))
47+
event5 = scheduler.enterabs(now + 0.05, 1, fun, (0.05,))
4748
scheduler.cancel(event1)
4849
scheduler.cancel(event5)
4950
scheduler.run()
@@ -64,11 +65,12 @@ def test_queue(self):
6465
l = []
6566
fun = lambda x: l.append(x)
6667
scheduler = sched.scheduler(time.time, time.sleep)
67-
e5 = scheduler.enter(0.05, 1, fun)
68-
e1 = scheduler.enter(0.01, 1, fun)
69-
e2 = scheduler.enter(0.02, 1, fun)
70-
e4 = scheduler.enter(0.04, 1, fun)
71-
e3 = scheduler.enter(0.03, 1, fun)
68+
now = time.time()
69+
e5 = scheduler.enterabs(now + 0.05, 1, fun)
70+
e1 = scheduler.enterabs(now + 0.01, 1, fun)
71+
e2 = scheduler.enterabs(now + 0.02, 1, fun)
72+
e4 = scheduler.enterabs(now + 0.04, 1, fun)
73+
e3 = scheduler.enterabs(now + 0.03, 1, fun)
7274
# queue property is supposed to return an order list of
7375
# upcoming events
7476
self.assertEqual(list(scheduler.queue), [e1, e2, e3, e4, e5])

Lib/test/test_xml_etree.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,7 +1352,6 @@ def xinclude():
13521352
r"""
13531353
Basic inclusion example (XInclude C.1)
13541354
1355-
>>> from xml.etree import ElementTree as ET
13561355
>>> from xml.etree import ElementInclude
13571356
13581357
>>> document = xinclude_loader("C1.xml")
@@ -1882,12 +1881,7 @@ def __init__(self, quiet=False):
18821881

18831882
def __enter__(self):
18841883
from xml.etree import ElementPath
1885-
if hasattr(ET, '_namespace_map'):
1886-
self._nsmap = ET._namespace_map
1887-
else:
1888-
# when testing the cElementTree alias
1889-
from xml.etree.ElementTree import _namespace_map
1890-
self._nsmap = _namespace_map
1884+
self._nsmap = ET.register_namespace._namespace_map
18911885
# Copy the default namespace mapping
18921886
self._nsmap_copy = self._nsmap.copy()
18931887
# Copy the path cache (should be empty)

Lib/test/test_xml_etree_c.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import unittest
66

77
cET = import_fresh_module('xml.etree.ElementTree', fresh=['_elementtree'])
8-
cET_alias = import_fresh_module('xml.etree.cElementTree', fresh=['_elementtree'])
8+
cET_alias = import_fresh_module('xml.etree.cElementTree', fresh=['_elementtree', 'xml.etree'])
99

1010

1111
# cElementTree specific tests
@@ -52,6 +52,9 @@ class TestAcceleratorImported(unittest.TestCase):
5252
def test_correct_import_cET(self):
5353
self.assertEqual(cET.Element.__module__, '_elementtree')
5454

55+
def test_correct_import_cET_alias(self):
56+
self.assertEqual(cET_alias.Element.__module__, '_elementtree')
57+
5558

5659
def test_main():
5760
from test import test_xml_etree, test_xml_etree_c

Lib/xml/etree/ElementTree.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,8 @@ def register_namespace(prefix, uri):
10861086
# dublin core
10871087
"http://purl.org/dc/elements/1.1/": "dc",
10881088
}
1089+
# For tests and troubleshooting
1090+
register_namespace._namespace_map = _namespace_map
10891091

10901092
def _raise_serialization_error(text):
10911093
raise TypeError(

Misc/NEWS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2261,8 +2261,8 @@ C-API
22612261
Documentation
22622262
-------------
22632263

2264-
- Issue #13491: Fix many errors in sqlite3 documentation. Initial
2265-
patch by Johannes Vogel.
2264+
- Issues #13491 and #13995: Fix many errors in sqlite3 documentation.
2265+
Initial patch for #13491 by Johannes Vogel.
22662266

22672267
- Issue #13402: Document absoluteness of sys.executable.
22682268

0 commit comments

Comments
 (0)