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

Skip to content

Commit b2b1863

Browse files
committed
merge 3.2 heads
2 parents 2029344 + f959618 commit b2b1863

4 files changed

Lines changed: 41 additions & 19 deletions

File tree

Doc/library/sqlite3.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
.. module:: sqlite3
55
:synopsis: A DB-API 2.0 implementation using SQLite 3.x.
6-
.. sectionauthor:: Gerhard Häring <[email protected]>
6+
.. sectionauthor:: Gerhard Häring <[email protected]>
77

88

99
SQLite is a C library that provides a lightweight disk-based database that
@@ -20,6 +20,7 @@ To use the module, you must first create a :class:`Connection` object that
2020
represents the database. Here the data will be stored in the
2121
:file:`/tmp/example` file::
2222

23+
import sqlite3
2324
conn = sqlite3.connect('/tmp/example')
2425

2526
You can also supply the special name ``:memory:`` to create a database in RAM.
@@ -56,15 +57,15 @@ example::
5657

5758
# Never do this -- insecure!
5859
symbol = 'IBM'
59-
c.execute("... where symbol = '%s'" % symbol)
60+
c.execute("select * from stocks where symbol = '%s'" % symbol)
6061

6162
# Do this instead
6263
t = (symbol,)
6364
c.execute('select * from stocks where symbol=?', t)
6465

6566
# Larger example
6667
for t in [('2006-03-28', 'BUY', 'IBM', 1000, 45.00),
67-
('2006-04-05', 'BUY', 'MSOFT', 1000, 72.00),
68+
('2006-04-05', 'BUY', 'MSFT', 1000, 72.00),
6869
('2006-04-06', 'SELL', 'IBM', 500, 53.00),
6970
]:
7071
c.execute('insert into stocks values (?,?,?,?,?)', t)
@@ -271,7 +272,6 @@ Connection Objects
271272
calling the cursor method, then calls the cursor's :meth:`executemany
272273
<Cursor.executemany>` method with the parameters given.
273274

274-
275275
.. method:: Connection.executescript(sql_script)
276276

277277
This is a nonstandard shortcut that creates an intermediate cursor object by
@@ -376,22 +376,22 @@ Connection Objects
376376
aggregates or whole new virtual table implementations. One well-known
377377
extension is the fulltext-search extension distributed with SQLite.
378378

379+
Loadable extensions are disabled by default. See [#f1]_.
380+
379381
.. versionadded:: 3.2
380382

381383
.. literalinclude:: ../includes/sqlite3/load_extension.py
382384

383-
Loadable extensions are disabled by default. See [#f1]_.
384-
385385
.. method:: Connection.load_extension(path)
386386

387387
This routine loads a SQLite extension from a shared library. You have to
388388
enable extension loading with :meth:`enable_load_extension` before you can
389389
use this routine.
390390

391-
.. versionadded:: 3.2
392-
393391
Loadable extensions are disabled by default. See [#f1]_.
394392

393+
.. versionadded:: 3.2
394+
395395
.. attribute:: Connection.row_factory
396396

397397
You can change this attribute to a callable that accepts the cursor and the

Lib/test/regrtest.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -677,10 +677,10 @@ def work():
677677
if bad:
678678
print(count(len(bad), "test"), "failed:")
679679
printlist(bad)
680-
if environment_changed:
681-
print("{} altered the execution environment:".format(
682-
count(len(environment_changed), "test")))
683-
printlist(environment_changed)
680+
if environment_changed:
681+
print("{} altered the execution environment:".format(
682+
count(len(environment_changed), "test")))
683+
printlist(environment_changed)
684684
if skipped and not quiet:
685685
print(count(len(skipped), "test"), "skipped:")
686686
printlist(skipped)
@@ -890,7 +890,9 @@ def __init__(self, testname, verbose=0, quiet=False):
890890
'logging._handlers', 'logging._handlerList',
891891
'shutil.archive_formats', 'shutil.unpack_formats',
892892
'sys.warnoptions', 'threading._dangling',
893-
'multiprocessing.process._dangling')
893+
'multiprocessing.process._dangling',
894+
'support.TESTFN',
895+
)
894896

895897
def get_sys_argv(self):
896898
return id(sys.argv), sys.argv, sys.argv[:]
@@ -1020,6 +1022,21 @@ def restore_multiprocessing_process__dangling(self, saved):
10201022
multiprocessing.process._dangling.clear()
10211023
multiprocessing.process._dangling.update(saved)
10221024

1025+
def get_support_TESTFN(self):
1026+
if os.path.isfile(support.TESTFN):
1027+
result = 'f'
1028+
elif os.path.isdir(support.TESTFN):
1029+
result = 'd'
1030+
else:
1031+
result = None
1032+
return result
1033+
def restore_support_TESTFN(self, saved_value):
1034+
if saved_value is None:
1035+
if os.path.isfile(support.TESTFN):
1036+
os.unlink(support.TESTFN)
1037+
elif os.path.isdir(support.TESTFN):
1038+
shutil.rmtree(support.TESTFN)
1039+
10231040
def resource_info(self):
10241041
for name in self.resources:
10251042
method_suffix = name.replace('.', '_')

Lib/test/test_base64.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from test import support
33
import base64
44
import binascii
5+
import os
56
import sys
67
import subprocess
78

@@ -227,6 +228,10 @@ def test_ErrorHeritage(self):
227228

228229

229230
class TestMain(unittest.TestCase):
231+
def tearDown(self):
232+
if os.path.exists(support.TESTFN):
233+
os.unlink(support.TESTFN)
234+
230235
def get_output(self, *args, **options):
231236
args = (sys.executable, '-m', 'base64') + args
232237
return subprocess.check_output(args, **options)

Lib/test/test_mailbox.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import email.message
88
import re
99
import io
10+
import shutil
1011
import tempfile
1112
from test import support
1213
import unittest
@@ -38,12 +39,7 @@ def _check_sample(self, msg):
3839
def _delete_recursively(self, target):
3940
# Delete a file or delete a directory recursively
4041
if os.path.isdir(target):
41-
for path, dirs, files in os.walk(target, topdown=False):
42-
for name in files:
43-
os.remove(os.path.join(path, name))
44-
for name in dirs:
45-
os.rmdir(os.path.join(path, name))
46-
os.rmdir(target)
42+
shutil.rmtree(target)
4743
elif os.path.exists(target):
4844
os.remove(target)
4945

@@ -2029,6 +2025,10 @@ class MaildirTestCase(unittest.TestCase):
20292025
def setUp(self):
20302026
# create a new maildir mailbox to work with:
20312027
self._dir = support.TESTFN
2028+
if os.path.isdir(self._dir):
2029+
shutil.rmtree(self._dir)
2030+
elif os.path.isfile(self._dir):
2031+
os.unlink(self._dir)
20322032
os.mkdir(self._dir)
20332033
os.mkdir(os.path.join(self._dir, "cur"))
20342034
os.mkdir(os.path.join(self._dir, "tmp"))

0 commit comments

Comments
 (0)