Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import sqlite3 only if used; minor bugfixes #620

Merged
merged 1 commit into from
May 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ Hypothesis APIs come in three flavours:
You should generally assume that an API is internal unless you have specific
information to the contrary.

------------------
3.8.5 - 2017-05-16
------------------

Hypothesis now imports ``sqlite3`` when a SQLite database is used, rather
than at module load, improving compatibility with Python implementations
compiled without SQLite support (such as BSD or Jython).

------------------
3.8.4 - 2017-05-16
Expand Down
12 changes: 5 additions & 7 deletions docs/supported.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ Python versions
Hypothesis is supported and tested on CPython 2.7 and CPython 3.4+.

Hypothesis also supports PyPy2, and will support PyPy3 when there is a stable
release supporting Python 3.4+. Hypothesis does not currently work on Jython
(it requires sqlite), though could feasibly be made to do so. IronPython might
work but hasn't been tested. 32-bit and narrow builds should work, though
this is currently only tested on Windows.
release supporting Python 3.4+. Hypothesis does not currently work on Jython,
though could feasibly be made to do so. IronPython might work but hasn't been
tested. 32-bit and narrow builds should work, though this is currently only
tested on Windows.

In general Hypothesis does not officially support anything except the latest
patch release of any version of Python it supports. Earlier releases should work
Expand All @@ -30,9 +30,7 @@ Operating systems

In theory Hypothesis should work anywhere that Python does. In practice it is
only known to work and regularly tested on OS X, Windows and Linux, and you may
experience issues running it elsewhere. For example a known issue is that FreeBSD
splits out the python-sqlite package from the main python package, and you will
need to install that in order for it to work.
experience issues running it elsewhere.

If you're using something else and it doesn't work, do get in touch and I'll try
to help, but unless you can come up with a way for me to run a CI server on that
Expand Down
4 changes: 2 additions & 2 deletions src/hypothesis/_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ def database(self):
If this was explicitly set at settings instantiation then that
value will be used (even if it was None). If not and the
database_file setting is not None this will be lazily loaded as
an SQLite backed ExampleDatabase using that file the first time
this property is accessed on a particular thread.
an ExampleDatabase using that file the first time this property
is accessed on a particular thread.
"""
if self._database is not_set and self.database_file is not None:
Expand Down
4 changes: 3 additions & 1 deletion src/hypothesis/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@

import os
import re
import sqlite3
import binascii
import threading
from contextlib import contextmanager

from hypothesis.internal.compat import FileNotFoundError, sha1, \
b64decode, b64encode

sqlite3 = None
SQLITE_PATH = re.compile(r"\.\(db|sqlite|sqlite3\)$")


Expand Down Expand Up @@ -115,6 +115,8 @@ def __init__(self, path=u':memory:'):
self.path = path
self.db_created = False
self.current_connection = threading.local()
global sqlite3
import sqlite3

def connection(self):
if not hasattr(self.current_connection, 'connection'):
Expand Down
2 changes: 1 addition & 1 deletion src/hypothesis/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@

from __future__ import division, print_function, absolute_import

__version_info__ = (3, 8, 4)
__version_info__ = (3, 8, 5)
__version__ = '.'.join(map(str, __version_info__))