Commit b2b18632 authored by Eli Bendersky's avatar Eli Bendersky

merge 3.2 heads

parents 20293441 f9596181
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
.. module:: sqlite3 .. module:: sqlite3
:synopsis: A DB-API 2.0 implementation using SQLite 3.x. :synopsis: A DB-API 2.0 implementation using SQLite 3.x.
.. sectionauthor:: Gerhard Häring <gh@ghaering.de> .. sectionauthor:: Gerhard Häring <gh@ghaering.de>
SQLite is a C library that provides a lightweight disk-based database that 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 ...@@ -20,6 +20,7 @@ To use the module, you must first create a :class:`Connection` object that
represents the database. Here the data will be stored in the represents the database. Here the data will be stored in the
:file:`/tmp/example` file:: :file:`/tmp/example` file::
import sqlite3
conn = sqlite3.connect('/tmp/example') conn = sqlite3.connect('/tmp/example')
You can also supply the special name ``:memory:`` to create a database in RAM. You can also supply the special name ``:memory:`` to create a database in RAM.
...@@ -56,7 +57,7 @@ example:: ...@@ -56,7 +57,7 @@ example::
# Never do this -- insecure! # Never do this -- insecure!
symbol = 'IBM' symbol = 'IBM'
c.execute("... where symbol = '%s'" % symbol) c.execute("select * from stocks where symbol = '%s'" % symbol)
# Do this instead # Do this instead
t = (symbol,) t = (symbol,)
...@@ -64,7 +65,7 @@ example:: ...@@ -64,7 +65,7 @@ example::
# Larger example # Larger example
for t in [('2006-03-28', 'BUY', 'IBM', 1000, 45.00), for t in [('2006-03-28', 'BUY', 'IBM', 1000, 45.00),
('2006-04-05', 'BUY', 'MSOFT', 1000, 72.00), ('2006-04-05', 'BUY', 'MSFT', 1000, 72.00),
('2006-04-06', 'SELL', 'IBM', 500, 53.00), ('2006-04-06', 'SELL', 'IBM', 500, 53.00),
]: ]:
c.execute('insert into stocks values (?,?,?,?,?)', t) c.execute('insert into stocks values (?,?,?,?,?)', t)
...@@ -271,7 +272,6 @@ Connection Objects ...@@ -271,7 +272,6 @@ Connection Objects
calling the cursor method, then calls the cursor's :meth:`executemany calling the cursor method, then calls the cursor's :meth:`executemany
<Cursor.executemany>` method with the parameters given. <Cursor.executemany>` method with the parameters given.
.. method:: Connection.executescript(sql_script) .. method:: Connection.executescript(sql_script)
This is a nonstandard shortcut that creates an intermediate cursor object by This is a nonstandard shortcut that creates an intermediate cursor object by
...@@ -376,22 +376,22 @@ Connection Objects ...@@ -376,22 +376,22 @@ Connection Objects
aggregates or whole new virtual table implementations. One well-known aggregates or whole new virtual table implementations. One well-known
extension is the fulltext-search extension distributed with SQLite. extension is the fulltext-search extension distributed with SQLite.
Loadable extensions are disabled by default. See [#f1]_.
.. versionadded:: 3.2 .. versionadded:: 3.2
.. literalinclude:: ../includes/sqlite3/load_extension.py .. literalinclude:: ../includes/sqlite3/load_extension.py
Loadable extensions are disabled by default. See [#f1]_.
.. method:: Connection.load_extension(path) .. method:: Connection.load_extension(path)
This routine loads a SQLite extension from a shared library. You have to This routine loads a SQLite extension from a shared library. You have to
enable extension loading with :meth:`enable_load_extension` before you can enable extension loading with :meth:`enable_load_extension` before you can
use this routine. use this routine.
.. versionadded:: 3.2
Loadable extensions are disabled by default. See [#f1]_. Loadable extensions are disabled by default. See [#f1]_.
.. versionadded:: 3.2
.. attribute:: Connection.row_factory .. attribute:: Connection.row_factory
You can change this attribute to a callable that accepts the cursor and the You can change this attribute to a callable that accepts the cursor and the
......
...@@ -890,7 +890,9 @@ class saved_test_environment: ...@@ -890,7 +890,9 @@ class saved_test_environment:
'logging._handlers', 'logging._handlerList', 'logging._handlers', 'logging._handlerList',
'shutil.archive_formats', 'shutil.unpack_formats', 'shutil.archive_formats', 'shutil.unpack_formats',
'sys.warnoptions', 'threading._dangling', 'sys.warnoptions', 'threading._dangling',
'multiprocessing.process._dangling') 'multiprocessing.process._dangling',
'support.TESTFN',
)
def get_sys_argv(self): def get_sys_argv(self):
return id(sys.argv), sys.argv, sys.argv[:] return id(sys.argv), sys.argv, sys.argv[:]
...@@ -1020,6 +1022,21 @@ class saved_test_environment: ...@@ -1020,6 +1022,21 @@ class saved_test_environment:
multiprocessing.process._dangling.clear() multiprocessing.process._dangling.clear()
multiprocessing.process._dangling.update(saved) multiprocessing.process._dangling.update(saved)
def get_support_TESTFN(self):
if os.path.isfile(support.TESTFN):
result = 'f'
elif os.path.isdir(support.TESTFN):
result = 'd'
else:
result = None
return result
def restore_support_TESTFN(self, saved_value):
if saved_value is None:
if os.path.isfile(support.TESTFN):
os.unlink(support.TESTFN)
elif os.path.isdir(support.TESTFN):
shutil.rmtree(support.TESTFN)
def resource_info(self): def resource_info(self):
for name in self.resources: for name in self.resources:
method_suffix = name.replace('.', '_') method_suffix = name.replace('.', '_')
......
...@@ -2,6 +2,7 @@ import unittest ...@@ -2,6 +2,7 @@ import unittest
from test import support from test import support
import base64 import base64
import binascii import binascii
import os
import sys import sys
import subprocess import subprocess
...@@ -227,6 +228,10 @@ class BaseXYTestCase(unittest.TestCase): ...@@ -227,6 +228,10 @@ class BaseXYTestCase(unittest.TestCase):
class TestMain(unittest.TestCase): class TestMain(unittest.TestCase):
def tearDown(self):
if os.path.exists(support.TESTFN):
os.unlink(support.TESTFN)
def get_output(self, *args, **options): def get_output(self, *args, **options):
args = (sys.executable, '-m', 'base64') + args args = (sys.executable, '-m', 'base64') + args
return subprocess.check_output(args, **options) return subprocess.check_output(args, **options)
......
...@@ -7,6 +7,7 @@ import email ...@@ -7,6 +7,7 @@ import email
import email.message import email.message
import re import re
import io import io
import shutil
import tempfile import tempfile
from test import support from test import support
import unittest import unittest
...@@ -38,12 +39,7 @@ class TestBase(unittest.TestCase): ...@@ -38,12 +39,7 @@ class TestBase(unittest.TestCase):
def _delete_recursively(self, target): def _delete_recursively(self, target):
# Delete a file or delete a directory recursively # Delete a file or delete a directory recursively
if os.path.isdir(target): if os.path.isdir(target):
for path, dirs, files in os.walk(target, topdown=False): shutil.rmtree(target)
for name in files:
os.remove(os.path.join(path, name))
for name in dirs:
os.rmdir(os.path.join(path, name))
os.rmdir(target)
elif os.path.exists(target): elif os.path.exists(target):
os.remove(target) os.remove(target)
...@@ -2029,6 +2025,10 @@ class MaildirTestCase(unittest.TestCase): ...@@ -2029,6 +2025,10 @@ class MaildirTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
# create a new maildir mailbox to work with: # create a new maildir mailbox to work with:
self._dir = support.TESTFN self._dir = support.TESTFN
if os.path.isdir(self._dir):
shutil.rmtree(self._dir)
elif os.path.isfile(self._dir):
os.unlink(self._dir)
os.mkdir(self._dir) os.mkdir(self._dir)
os.mkdir(os.path.join(self._dir, "cur")) os.mkdir(os.path.join(self._dir, "cur"))
os.mkdir(os.path.join(self._dir, "tmp")) os.mkdir(os.path.join(self._dir, "tmp"))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment