From 483a04214c4d0f38a6b7a1b723fe37187b4f7fb6 Mon Sep 17 00:00:00 2001 From: Arne Date: Sun, 13 Oct 2019 13:43:30 +0200 Subject: [PATCH] Prepare support for python 3.8 (#702) * closes #701 * best practice for handling copmat here is a try..except import --- panel/_testing/fixtures.py | 2 +- panel/util.py | 8 ++++++-- panel/viewable.py | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/panel/_testing/fixtures.py b/panel/_testing/fixtures.py index 795042ce3f..2a76fcf16e 100644 --- a/panel/_testing/fixtures.py +++ b/panel/_testing/fixtures.py @@ -45,7 +45,7 @@ def hv_mpl(): @pytest.yield_fixture def tmpdir(request, tmpdir_factory): name = request.node.name - name = re.sub("[\W]", "_", name) + name = re.sub(r"[\W]", "_", name) MAXVAL = 30 if len(name) > MAXVAL: name = name[:MAXVAL] diff --git a/panel/util.py b/panel/util.py index 7cf9ccf94a..fe144ad07c 100644 --- a/panel/util.py +++ b/panel/util.py @@ -9,9 +9,13 @@ import numbers import datetime as dt -from collections import defaultdict, MutableSequence, MutableMapping, OrderedDict from datetime import datetime from six import string_types +from collections import defaultdict, OrderedDict +try: + from collections.abc import MutableSequence, MutableMapping +except ImportError: # support for python>3.8 + from collections import MutableSequence, MutableMapping import param import numpy as np @@ -77,7 +81,7 @@ def param_name(name): """ Removes the integer id from a Parameterized class name. """ - match = re.match('(.)+(\d){5}', name) + match = re.match(r'(.)+(\d){5}', name) return name[:-5] if match else name diff --git a/panel/viewable.py b/panel/viewable.py index 0beb314547..315de877a7 100644 --- a/panel/viewable.py +++ b/panel/viewable.py @@ -740,7 +740,7 @@ def _cleanup(self, root): return customjs = model.select({'type': CustomJS}) - pattern = "data\['comm_id'\] = \"(.*)\"" + pattern = r"data\['comm_id'\] = \"(.*)\"" for js in customjs: comm_ids = list(re.findall(pattern, js.code)) if not comm_ids: