From 9516ac5f4fb010283619821259eeb4e4bd029db3 Mon Sep 17 00:00:00 2001 From: Gunnar Aastrand Grimnes Date: Sat, 27 Oct 2018 23:48:32 +0200 Subject: [PATCH 1/2] 3.7 for travis --- .travis.yml | 6 ++++++ docs/developers.rst | 2 +- setup.py | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fa9a44736..f37f0750d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,12 @@ python: - 3.5 - 3.6 +matrix: + include: + - python: 3.7 + dist: xenial + sudo: true + before_install: - pip install -U setuptools pip # seems travis comes with a too old setuptools for html5lib - bash .travis.fuseki_install_optional.sh diff --git a/docs/developers.rst b/docs/developers.rst index d0ba29454..c6afeee3d 100644 --- a/docs/developers.rst +++ b/docs/developers.rst @@ -56,7 +56,7 @@ If you make a pull-request to RDFLib on GitHub, travis will automatically test y Compatibility ------------- -RDFLib>=5.0.0 tries to be compatible with python versions 2.7, 3.5, 3.6. +RDFLib>=5.0.0 tries to be compatible with python versions 2.7, 3.5, 3.6, 3.7. Releasing diff --git a/setup.py b/setup.py index 3066332f5..9859360e0 100644 --- a/setup.py +++ b/setup.py @@ -46,6 +46,7 @@ def find_version(filename): "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", "License :: OSI Approved :: BSD License", "Topic :: Software Development :: Libraries :: Python Modules", "Operating System :: OS Independent", From 58c45d6f30af88a22f60edcb9a459648a885e226 Mon Sep 17 00:00:00 2001 From: Gunnar Aastrand Grimnes Date: Sun, 28 Oct 2018 01:03:53 +0200 Subject: [PATCH 2/2] fixed SPARQL evaluate issue with StopIteration in py3.7 --- rdflib/plugins/sparql/evaluate.py | 18 +++--------------- rdflib/query.py | 3 ++- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/rdflib/plugins/sparql/evaluate.py b/rdflib/plugins/sparql/evaluate.py index ee7184466..a693dff79 100644 --- a/rdflib/plugins/sparql/evaluate.py +++ b/rdflib/plugins/sparql/evaluate.py @@ -15,6 +15,7 @@ """ import collections +import itertools from rdflib import Variable, Graph, BNode, URIRef, Literal from six import iteritems, itervalues @@ -321,22 +322,9 @@ def evalOrderBy(ctx, part): def evalSlice(ctx, slice): - # import pdb; pdb.set_trace() res = evalPart(ctx, slice.p) - i = 0 - while i < slice.start: - next(res) - i += 1 - i = 0 - for x in res: - i += 1 - if slice.length is None: - yield x - else: - if i <= slice.length: - yield x - else: - break + + return itertools.islice(res, slice.start, slice.start+slice.length if slice.length is not None else None) def evalReduced(ctx, part): diff --git a/rdflib/query.py b/rdflib/query.py index 9cfe5a26b..929fa3384 100644 --- a/rdflib/query.py +++ b/rdflib/query.py @@ -3,6 +3,7 @@ from __future__ import print_function import os +import itertools import shutil import tempfile import warnings @@ -185,7 +186,7 @@ def _get_bindings(self): return self._bindings def _set_bindings(self, b): - if isinstance(b, types.GeneratorType): + if isinstance(b, (types.GeneratorType, itertools.islice)): self._genbindings = b self._bindings = [] else: