[pypy-issue] Issue #2097: Occasional KeyError in sqlite3 driver (pypy/pypy)

David MacIver issues-reply at bitbucket.org
Fri Jul 24 04:00:10 CEST 2015


New issue 2097: Occasional KeyError in sqlite3 driver
https://bitbucket.org/pypy/pypy/issues/2097/occasional-keyerror-in-sqlite3-driver

David MacIver:

I'm not sure what's changed (it would be on my end rather than yours), but recently I've been seeing the following exception every now and then in the Hypothesis django tests - it only happens every few days and I don't have a reproducible test case, but I thought I'd mention it speculatively in case it was obvious to someone what was going on.

I'm only seeing this on pypy, and a KeyError is the sort of thing that shouldn't escape closing an sqlite3 connection, so there's definitely a bug in here somewhere.

This is running pypy 2.6.0 on linux (specifically on Travis).

```
ImportError: Failed to import test module: tests.django.toystore.test_fixtures
Traceback (most recent call last):
  File "/home/travis/.pyenv/versions/pypy-2.6.0/lib-python/2.7/unittest/loader.py", line 254, in _find_tests
    module = self._get_module_from_name(name)
  File "/home/travis/.pyenv/versions/pypy-2.6.0/lib-python/2.7/unittest/loader.py", line 232, in _get_module_from_name
    __import__(name)
  File "tests/django/toystore/test_fixtures.py", line 55, in <module>
    lambda x: x.store_set.count() >= 2
  File "/home/travis/build/DRMacIver/hypothesis/.tox/pypy/site-packages/hypothesis/extra/django/fixtures.py", line 102, in fixture
    return Fixture(strategy, constraint, execute)
  File "/home/travis/build/DRMacIver/hypothesis/.tox/pypy/site-packages/hypothesis/extra/django/fixtures.py", line 51, in __init__
    self._set_template()
  File "/home/travis/build/DRMacIver/hypothesis/.tox/pypy/site-packages/hypothesis/extra/django/fixtures.py", line 74, in _set_template
    verbosity=verbosity, interactive=False
  File "/home/travis/build/DRMacIver/hypothesis/.tox/pypy/site-packages/django/test/runner.py", line 370, in setup_databases
    serialize=connection.settings_dict.get("TEST", {}).get("SERIALIZE", True),
  File "/home/travis/build/DRMacIver/hypothesis/.tox/pypy/site-packages/django/db/backends/base/creation.py", line 356, in create_test_db
    self.connection.close()
  File "/home/travis/build/DRMacIver/hypothesis/.tox/pypy/site-packages/django/db/backends/sqlite3/base.py", line 226, in close
    BaseDatabaseWrapper.close(self)
  File "/home/travis/build/DRMacIver/hypothesis/.tox/pypy/site-packages/django/db/backends/base/base.py", line 198, in close
    self._close()
  File "/home/travis/build/DRMacIver/hypothesis/.tox/pypy/site-packages/django/db/backends/base/base.py", line 152, in _close
    return self.connection.close()
  File "/home/travis/.pyenv/versions/pypy-2.6.0/lib_pypy/_sqlite3.py", line 256, in close
    self._finalize_raw_statement(stmt)
  File "/home/travis/.pyenv/versions/pypy-2.6.0/lib_pypy/_sqlite3.py", line 348, in _finalize_raw_statement
    self.__rawstatements.remove(_statement)
KeyError: <cdata 'sqlite3_stmt *' 0x3995dc8>
```




More information about the pypy-issue mailing list