Skip to content

Commit

Permalink
Fix test compatibility with ZODB 5.3.0
Browse files Browse the repository at this point in the history
Open files can now be pickled under Python 2.

We had to switch to a custom object: open sockets can be pickled under
PyPy, which was the only other trivial stdlib example I could think
of. This way, at least, we're guaranteed it never happens again.
  • Loading branch information
jamadden committed Sep 22, 2017
1 parent 26f0030 commit bd43205
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
8 changes: 2 additions & 6 deletions .travis.yml
Expand Up @@ -5,12 +5,8 @@ python:
- 3.4
- 3.5
- 3.6
# Force a newer PyPy on the old 'precise' CI image
# in order to install 'cryptography' needed for coveralls
# After September 2017 this should be the default and the version
# pin can be removed.
- pypy-5.6.0
- pypy3.5-5.8.0
- pypy
- pypy3
install:
- pip install -U pip setuptools
- pip install -U coverage coveralls
Expand Down
13 changes: 9 additions & 4 deletions src/zope/session/api.rst
Expand Up @@ -98,14 +98,19 @@ Restrictions
------------

Data stored in the session must be persistent or picklable.
(Exactly which builtin and standard objects can be pickled depends on
the Python version, the Python implementation, and the ZODB version,
so we demonstrate with a custom object.)

>>> import transaction
>>> with open(__file__) as f:
... session['oops'] = f
... transaction.commit()
>>> class NoPickle(object):
... def __reduce__(self):
... raise TypeError("I cannot be pickled")
>>> session['oops'] = NoPickle()
>>> transaction.commit()
Traceback (most recent call last):
[...]
TypeError: ...
TypeError: I cannot be pickled

Clean up:

Expand Down

0 comments on commit bd43205

Please sign in to comment.