From bdd70e69e37d8335ed3e2f2a2d9269db9c0cb244 Mon Sep 17 00:00:00 2001 From: Joern Hees Date: Wed, 23 Sep 2015 18:46:15 +0200 Subject: adding python 3.5 support (activating tests) --- .travis.yml | 1 + setup.py | 1 + tox.ini | 22 ++++++++++++++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a23b677e..616c79a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ python: # - 3.2 - 3.3 - 3.4 + - 3.5 # - "pypy" before_install: diff --git a/setup.py b/setup.py index c21cc27c..bbcb7062 100644 --- a/setup.py +++ b/setup.py @@ -123,6 +123,7 @@ setup( "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", + "Programming Language :: Python :: 3.5", "License :: OSI Approved :: BSD License", "Topic :: Software Development :: Libraries :: Python Modules", "Operating System :: OS Independent", diff --git a/tox.ini b/tox.ini index a858f194..e5f8abca 100644 --- a/tox.ini +++ b/tox.ini @@ -1,9 +1,9 @@ [tox] envlist = - py25,py26,py27,py32,py33,py34 + py25,py26,py27,py32,py33,py34,py35 [testenv] -setenv = +setenv = BERKELEYDB_DIR = /usr commands = {envpython} setup.py clean --all @@ -105,6 +105,24 @@ deps = html5lib SPARQLWrapper>=1.6.2 +[testenv:py35] +basepython = + python3.5 +commands = + python setup.py clean --all + python setup.py build + nosetests --where=./build/src \ + --with-doctest \ + --doctest-extension=.doctest \ + --doctest-tests +deps = + nose + isodate + pyparsing + bsddb3 + html5lib + SPARQLWrapper>=1.6.2 + [testenv:pypy] basepython = -- cgit v1.2.1 From ad37869ed8569c51214e76c92c46487ed69a20be Mon Sep 17 00:00:00 2001 From: Joern Hees Date: Wed, 23 Sep 2015 19:27:19 +0200 Subject: introduced py3.5+ handling for better re.sub unmatched group handling otherwise our workaround for http://bugs.python.org/issue1519638 fails on py3.5+ --- rdflib/plugins/sparql/operators.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rdflib/plugins/sparql/operators.py b/rdflib/plugins/sparql/operators.py index 7fa840dc..92c92a6b 100644 --- a/rdflib/plugins/sparql/operators.py +++ b/rdflib/plugins/sparql/operators.py @@ -6,6 +6,7 @@ using setEvalFn """ +import sys import re import math import random @@ -234,7 +235,7 @@ def Builtin_REPLACE(expr, ctx): # Now this is ugly. # Python has a "feature" where unmatched groups return None # then re.sub chokes on this. - # see http://bugs.python.org/issue1519638 + # see http://bugs.python.org/issue1519638 , fixed and errs in py3.5 # this works around and hooks into the internal of the re module... @@ -260,7 +261,10 @@ def Builtin_REPLACE(expr, ctx): cFlag = reduce(pyop.or_, [flagMap.get(f, 0) for f in flags]) # @@FIXME@@ either datatype OR lang, NOT both - return Literal(re.sub(unicode(pattern), _r, text, cFlag), + + compat_r = unicode(replacement) if sys.version_info[:2] >= (3, 5) else _r + + return Literal(re.sub(unicode(pattern), compat_r, text, cFlag), datatype=text.datatype, lang=text.language) -- cgit v1.2.1 From b8e6633b2c95d6690380e14126ecac1ebfab96e4 Mon Sep 17 00:00:00 2001 From: Joern Hees Date: Thu, 24 Sep 2015 10:40:24 +0200 Subject: added comment referring to explanation for re.sub handling in _r() --- rdflib/plugins/sparql/operators.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rdflib/plugins/sparql/operators.py b/rdflib/plugins/sparql/operators.py index 92c92a6b..0179c6fb 100644 --- a/rdflib/plugins/sparql/operators.py +++ b/rdflib/plugins/sparql/operators.py @@ -262,6 +262,8 @@ def Builtin_REPLACE(expr, ctx): # @@FIXME@@ either datatype OR lang, NOT both + # this is necessary due to different treatment of unmatched groups in + # python versions. see comments above in _r(m). compat_r = unicode(replacement) if sys.version_info[:2] >= (3, 5) else _r return Literal(re.sub(unicode(pattern), compat_r, text, cFlag), -- cgit v1.2.1