Skip to content

Commit

Permalink
Merge pull request #98 from NextThought/dep-updates
Browse files Browse the repository at this point in the history
Add support for Python3.8, PyYAML 5, and Persistent 4.4.3
  • Loading branch information
jamadden committed Nov 11, 2019
2 parents 964cd85 + 83dd4cd commit e419401
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 18 deletions.
17 changes: 8 additions & 9 deletions .travis.yml
@@ -1,19 +1,18 @@
language: python
sudo: false
group: travis_latest
language: python
python:
- 2.7
- 3.6
- 3.7
- 3.8
- pypy
- pypy3
jobs:
include:
- python: 2.7 # 2.7.14 pip 9.0.1
- python: 3.6 # 3.6.3 pip 9.0.1
- python: 3.7 # 3.7.0 pip 10.0.1
dist: xenial
sudo: true
- python: pypy # 2.7.13 pip 9.0.1
- python: pypy3 # 3.5.3 pip 9.0.1
- python: 2.7
env: PURE_PYTHON=1
- python: 3.6
- python: 3.8
env: PURE_PYTHON=1
env:
global:
Expand Down
7 changes: 6 additions & 1 deletion CHANGES.rst
Expand Up @@ -6,8 +6,13 @@
1.0.0a14 (unreleased)
=====================

- Build with Cython 0.29 using '3str' as the language level.
- Build with Cython 0.29.14 using '3str' as the language level.

- Add support for Python 3.8.

- Update PyYAML to 5.1 and change the default output style slightly.

- Fix tests with Persistent 4.4.3 and above.

1.0.0a13 (2018-09-20)
=====================
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Expand Up @@ -162,6 +162,7 @@ def _c(m):
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
],
Expand All @@ -178,8 +179,8 @@ def _c(m):
'BTrees',
'isodate',
'nti.schema >= 1.7.0',
'persistent >= 4.4.0',
'PyYAML',
'persistent >= 4.4.3',
'PyYAML >= 5.1',
'pytz',
'simplejson',
'transaction >= 2.2',
Expand Down
8 changes: 7 additions & 1 deletion src/nti/externalization/representation.py
Expand Up @@ -165,7 +165,13 @@ def construct_yaml_str(self, node):
class YamlRepresenter(object):

def dump(self, obj, fp=None):
return yaml.dump(obj, stream=fp, Dumper=_ExtDumper)
# The default_flow_style changed in PyYaml 5.1 from None to False.
# Using False produces multi-line, indented, verbose output. While being human readable,
# this consumes space and eliminates simple parsing with JSON. Using True
# produces JSON-compatible output in many cases. Using None (the old default)
# produces backwards-compatible output that's a hybrid of indented and JSON-like.
# https://github.com/yaml/pyyaml/issues/199
return yaml.dump(obj, stream=fp, Dumper=_ExtDumper, default_flow_style=True)

def load(self, stream):
return yaml.load(stream, Loader=_UnicodeLoader)
Expand Down
2 changes: 1 addition & 1 deletion src/nti/externalization/tests/test_externalization.py
Expand Up @@ -162,7 +162,7 @@ class SubUnicode(str if bytes is not str else unicode):
l.append(LocatedExternalDict(k2=SubUnicode(u'foo')))

assert_that(to_external_representation(l, EXT_REPR_YAML),
is_('- {k: v}\n- {k2: foo}\n'))
is_('[{k: v}, {k2: foo}]\n'))

def test_external_class_name(self):
class C(UserDict, ExternalizableDictionaryMixin):
Expand Down
7 changes: 4 additions & 3 deletions src/nti/externalization/tests/test_representation.py
Expand Up @@ -113,16 +113,17 @@ class Foo(Persistent):

o._p_oid = b'12345678'
r = self._normalized_repr(o)

# Persistent 4.4.3 and above represent the OID using hex; prior
# to that it was bytes.
assert_that(r,
is_("<Foo object at 0xdeadbeef oid b'12345678' _p_repr {}>"))
is_("<Foo object at 0xdeadbeef oid 0xdeadbeef _p_repr {}>"))

o.a = 1

r = self._normalized_repr(o)

assert_that(r,
is_("<Foo object at 0xdeadbeef oid b'12345678' _p_repr {'a': 1}>"))
is_("<Foo object at 0xdeadbeef oid 0xdeadbeef _p_repr {'a': 1}>"))

def test_persistent_subclass_custom(self):
@representation.WithRepr(lambda s: 'Hi')
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
@@ -1,6 +1,6 @@
[tox]
envlist =
py27,py27-pure,py35,py36,py36-pure,py37,pypy,pypy3,coverage,docs
py27,py27-pure,py36,py36-pure,py37,py38,pypy,pypy3,coverage,docs

[testenv]
commands =
Expand Down

0 comments on commit e419401

Please sign in to comment.