Skip to content

Commit 388563f

Browse files
authored
Merge pull request #208 from tomaszn/python_compat
Bring back compatibility with Python < 3.9
2 parents a140eb5 + a5893e5 commit 388563f

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

.github/workflows/run-tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ jobs:
1616
os: [ macos-latest, ubuntu-latest ]
1717
python-version: [ 3.9, "3.10" ]
1818
django-version: [ 3.2, 4.0, 4.1 ]
19+
include:
20+
- os: ubuntu-20.04
21+
python-version: "3.6"
22+
django-version: "3.2"
1923

2024
steps:
2125
- name: Install system dependencies (windows)

martor/urls.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import unicode_literals
3-
41
import django
52

63
from .settings import MARTOR_MARKDOWNIFY_URL, MARTOR_UPLOAD_URL, MARTOR_SEARCH_USERS_URL
@@ -11,8 +8,13 @@
118
)
129

1310

14-
def __normalize(path):
15-
return path.removeprefix('/').removesuffix('/')
11+
def __normalize(path: str) -> str:
12+
# to support Python < 3.9 we can't use removeprefix('/').removesuffix('/')
13+
if path.startswith("/"):
14+
path = path[1:]
15+
if path.endswith("/"):
16+
path = path[:-1]
17+
return path
1618

1719

1820
if django.VERSION >= (2, 0):

requirements.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
urllib3<2 ; python_version < '3.7' # urllib3 2.0 dropped support for Python 3.6
2+
zipp<3.7 ; python_version < '3.7' # zipp 3.7.0 dropped support for Python 3.6
3+
importlib_metadata<4.9 # # importlib_metadata 4.9.0 dropped support for Python 3.6
14
Django>=3.2
2-
Markdown==3.3.4
5+
Markdown<3.4
36
requests
47
bleach
58
tzdata

0 commit comments

Comments
 (0)