Skip to content

Commit 076d4ad

Browse files
committed
Dropped python 3.5 and below.
1 parent db1e571 commit 076d4ad

File tree

10 files changed

+20
-139
lines changed

10 files changed

+20
-139
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ language: python
44

55
matrix:
66
include:
7-
- python: 2.7
8-
env: TOXENV=py27
7+
- python: 3.6
8+
env: TOXENV=py36
99
- python: 3.7
1010
env: TOXENV=py37
1111
- python: 3.8

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ Resources:
2727
## Install
2828

2929
[wheezy.html](https://pypi.org/project/wheezy.html) requires
30-
[python](http://www.python.org) version 2.4 to 2.7 or 3.2+. It is
31-
independent of operating system. You can install it from
32-
[pypi](https://pypi.org/project/wheezy.html) site:
30+
[python](http://www.python.org) version 3.6+. It is independent of operating
31+
system. You can install it from [pypi](https://pypi.org/project/wheezy.html)
32+
site:
3333

3434
```sh
3535
pip install -U wheezy.html
@@ -39,7 +39,6 @@ If you would like take a benefit of template preprocessing for Mako,
3939
Jinja2, Tenjin or Wheezy.Template engines specify extra requirements:
4040

4141
```sh
42-
pip install wheezy.html[jinja2]
4342
pip install wheezy.html[wheezy.template]
4443
```
4544

requirements/dev-py2.txt

Lines changed: 0 additions & 37 deletions
This file was deleted.

requirements/dev-py3.txt renamed to requirements/dev.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This file is autogenerated by pip-compile
33
# To update, run:
44
#
5-
# pip-compile --output-file=requirements/dev-py3.txt requirements/dev.in
5+
# pip-compile --output-file=requirements/dev.txt requirements/dev.in
66
#
77
atomicwrites==1.4.0 # via pytest
88
attrs==20.3.0 # via pytest
@@ -23,7 +23,7 @@ pytest==6.1.2 # via -r requirements/dev.in, pytest-cov
2323
six==1.15.0 # via packaging, pip-tools
2424
tenjin==1.1.1 # via -r requirements/dev.in
2525
toml==0.10.2 # via pytest
26-
wheezy.template==3.0.0 # via -r requirements/dev.in
26+
wheezy.template==3.0.1 # via -r requirements/dev.in
2727

2828
# The following packages are considered to be unsafe in a requirements file:
2929
# pip

setup.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
os.path.join(p, "ext", "__init__.py"),
2020
],
2121
nthreads=2,
22+
compiler_directives={"language_level": 3},
2223
quiet=True,
2324
)
2425
except ImportError:
@@ -72,6 +73,7 @@ def warn(self):
7273
setup(
7374
name="wheezy.html",
7475
version=VERSION,
76+
python_requires=">=3.6",
7577
description="A lightweight html rendering library",
7678
long_description=README,
7779
long_description_content_type="text/markdown",
@@ -86,16 +88,6 @@ def warn(self):
8688
"Natural Language :: English",
8789
"Operating System :: OS Independent",
8890
"Programming Language :: Python",
89-
"Programming Language :: Python :: 2",
90-
"Programming Language :: Python :: 2.4",
91-
"Programming Language :: Python :: 2.5",
92-
"Programming Language :: Python :: 2.6",
93-
"Programming Language :: Python :: 2.7",
94-
"Programming Language :: Python :: 3",
95-
"Programming Language :: Python :: 3.2",
96-
"Programming Language :: Python :: 3.3",
97-
"Programming Language :: Python :: 3.4",
98-
"Programming Language :: Python :: 3.5",
9991
"Programming Language :: Python :: 3.6",
10092
"Programming Language :: Python :: 3.7",
10193
"Programming Language :: Python :: 3.8",

src/wheezy/html/boost.c

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11

22
#include <Python.h>
33

4-
#if PY_VERSION_HEX < 0x02050000
5-
typedef int Py_ssize_t;
6-
#endif
7-
8-
#if PY_VERSION_HEX < 0x02060000
9-
#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
10-
#endif
11-
124
static PyObject*
135
escape_html_unicode(PyUnicodeObject *s)
146
{
@@ -86,23 +78,15 @@ escape_html_unicode(PyUnicodeObject *s)
8678
static PyObject*
8779
escape_html_string(PyObject *s)
8880
{
89-
#if PY_MAJOR_VERSION < 3
90-
const Py_ssize_t s_size = PyString_GET_SIZE(s);
91-
#else
9281
const Py_ssize_t s_size = PyBytes_GET_SIZE(s);
93-
#endif
9482
if (s_size == 0)
9583
{
9684
Py_INCREF(s);
9785
return (PyObject*)s;
9886
}
9987

10088
Py_ssize_t count = 0;
101-
#if PY_MAJOR_VERSION < 3
102-
char *start = PyString_AS_STRING(s);
103-
#else
10489
char *start = PyBytes_AS_STRING(s);
105-
#endif
10690
const char *end = start + s_size;
10791
char *p = start;
10892
while(p < end)
@@ -127,22 +111,14 @@ escape_html_string(PyObject *s)
127111
return (PyObject*)s;
128112
}
129113

130-
#if PY_MAJOR_VERSION < 3
131-
PyObject *result = PyString_FromStringAndSize(NULL, s_size + count);
132-
#else
133114
PyObject *result = PyBytes_FromStringAndSize(NULL, s_size + count);
134-
#endif
135115
if (! result)
136116
{
137117
return NULL;
138118
}
139119

140120
p = start;
141-
#if PY_MAJOR_VERSION < 3
142-
char *r = PyString_AS_STRING(result);
143-
#else
144121
char *r = PyBytes_AS_STRING(result);
145-
#endif
146122
while(p < end)
147123
{
148124
char ch = *p++;
@@ -186,21 +162,13 @@ escape_html(PyObject *self, PyObject *args)
186162
return escape_html_unicode((PyUnicodeObject*)s);
187163
}
188164

189-
#if PY_MAJOR_VERSION < 3
190-
if (PyString_CheckExact(s))
191-
#else
192165
if (PyBytes_CheckExact(s))
193-
#endif
194166
{
195167
return escape_html_string(s);
196168
}
197169

198170
if (s == Py_None) {
199-
#if PY_MAJOR_VERSION < 3
200-
return PyString_FromStringAndSize(NULL, 0);
201-
#else
202171
return PyUnicode_FromStringAndSize(NULL, 0);
203-
#endif
204172
}
205173

206174
PyErr_Format(PyExc_TypeError,
@@ -217,16 +185,6 @@ static PyMethodDef module_methods[] = {
217185
};
218186

219187

220-
#if PY_MAJOR_VERSION < 3
221-
222-
PyMODINIT_FUNC
223-
initboost(void)
224-
{
225-
Py_InitModule("wheezy.html.boost", module_methods);
226-
}
227-
228-
#else
229-
230188
static struct PyModuleDef module_definition = {
231189
PyModuleDef_HEAD_INIT,
232190
"wheezy.html.boost",
@@ -240,5 +198,3 @@ PyInit_boost(void)
240198
{
241199
return PyModule_Create(&module_definition);
242200
}
243-
244-
#endif

src/wheezy/html/comp.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/wheezy/html/ext/template.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import re
55

6-
from wheezy.html.comp import xrange
76
from wheezy.html.ext.lexer import (
87
InlinePreprocessor,
98
Preprocessor,
@@ -133,7 +132,7 @@ class WidgetExtension(object):
133132

134133

135134
def whitespace_postprocessor(tokens):
136-
for i in xrange(len(tokens)):
135+
for i in range(len(tokens)):
137136
lineno, token, value = tokens[i]
138137
if token == "markup":
139138
value = whitespace_preprocessor(value)

src/wheezy/html/utils.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
from datetime import date, datetime
55

6-
from wheezy.html.comp import str_type
7-
86

97
def escape_html(s):
108
"""Escapes a string so it is valid within HTML. Converts `None`
@@ -66,7 +64,7 @@ def my_formatter(value, format_spec):
6664
>>> format_value([])
6765
()
6866
69-
If format provider is unknown apply str_type.
67+
If format provider is unknown apply str.
7068
7169
>>> str(format_value({}))
7270
'{}'
@@ -87,12 +85,12 @@ def my_formatter(value, format_spec):
8785
if formatter_name in format_providers:
8886
format_provider = format_providers[formatter_name]
8987
else:
90-
return str_type(value)
88+
return str(value)
9189
return format_provider(value, format_spec)
9290

9391

9492
def str_format_provider(value, format_spec):
95-
return str_type(value)
93+
return str(value)
9694

9795

9896
min_date = date(1900, 1, 1)
@@ -138,7 +136,7 @@ def datetime_format_provider(value, format_spec=None):
138136

139137

140138
format_providers = {
141-
"str": lambda value, format_spec: html_escape(str_type(value)),
139+
"str": lambda value, format_spec: html_escape(str(value)),
142140
"unicode": lambda value, format_spec: html_escape(value),
143141
"int": str_format_provider,
144142
"Decimal": str_format_provider,

tox.ini

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
[tox]
2-
envlist = py27,py37,py38,py39,pypy3,lint,docs
2+
envlist = py36,py37,py38,py39,pypy3,lint,docs
33
skipsdist = True
44

55
[testenv]
66
usedevelop = True
77
deps =
8-
py27: -r requirements/dev-py2.txt
9-
py37: -r requirements/dev-py3.txt
10-
py38: -r requirements/dev-py3.txt
11-
py39: -r requirements/dev-py3.txt
12-
pypy3: -r requirements/dev-py3.txt
8+
py36: -r requirements/dev.txt
9+
py37: -r requirements/dev.txt
10+
py38: -r requirements/dev.txt
11+
py39: -r requirements/dev.txt
12+
pypy3: -r requirements/dev.txt
1313
commands =
1414
pytest -q -x --disable-pytest-warnings --doctest-modules \
1515
--cov-report term-missing --cov wheezy.html

0 commit comments

Comments
 (0)