Skip to content

Commit 8d99afc

Browse files
jamaddenMichael Howitz
and
Michael Howitz
authored
Add support for 3.10. (#61)
Fixes #60 and fixes #58. Co-authored-by: Michael Howitz <mh@gocept.com>
1 parent b52a657 commit 8d99afc

File tree

9 files changed

+40
-5
lines changed

9 files changed

+40
-5
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ jobs:
103103
- 3.7
104104
- 3.8
105105
- 3.9
106+
- 3.10.0-rc.2
106107
os: [ubuntu-20.04, macos-latest]
107108
exclude:
108109
- os: macos-latest
@@ -189,6 +190,7 @@ jobs:
189190
- 3.7
190191
- 3.8
191192
- 3.9
193+
- 3.10.0-rc.2
192194
os: [ubuntu-20.04, macos-latest]
193195
exclude:
194196
- os: macos-latest

.manylinux-install.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ for PYBIN in /opt/python/*/bin; do
3333
[[ "${PYBIN}" == *"cp36"* ]] || \
3434
[[ "${PYBIN}" == *"cp37"* ]] || \
3535
[[ "${PYBIN}" == *"cp38"* ]] || \
36+
[[ "${PYBIN}" == *"cp310"* ]] || \
3637
[[ "${PYBIN}" == *"cp39"* ]]; then
3738
"${PYBIN}/pip" install -e /io/
3839
"${PYBIN}/pip" wheel /io/ -w wheelhouse/

.meta.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ with-windows = false
1010
with-pypy = true
1111
with-legacy-python = true
1212
with-sphinx-doctests = false
13-
with-future-python = false
13+
with-future-python = true
1414

1515
[tox]
1616
use-flake8 = false

CHANGES.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
2.1.1 (unreleased)
66
==================
77

8-
- Nothing changed yet.
8+
- Add support for Python 3.10.
99

1010

1111
2.1.0 (2021-09-24)

appveyor.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ environment:
2121
- python: 38-x64
2222
- python: 39
2323
- python: 39-x64
24+
# `multibuild` cannot install non-final versions as they are not on
25+
# ftp.python.org, so we skip Python 3.10 until its final release:
26+
# - python: 310
27+
# - python: 310-x64
2428

2529
install:
2630
- "SET PYTHONVERSION=%PYTHON%"

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def read(fname):
6767
'Programming Language :: Python :: 3.7',
6868
'Programming Language :: Python :: 3.8',
6969
'Programming Language :: Python :: 3.9',
70+
'Programming Language :: Python :: 3.10',
7071
'Programming Language :: Python :: Implementation :: CPython',
7172
'Programming Language :: Python :: Implementation :: PyPy',
7273
'Programming Language :: Python :: Implementation :: Jython',

src/zodbpickle/_pickle_33.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,28 @@
44
PyDoc_STRVAR(pickle_module_doc,
55
"Optimized C implementation for the Python pickle module.");
66

7+
8+
#if (PY_VERSION_HEX >= 0x30A00B1) /* 3.10.0b1 */
9+
#ifndef Py_SIZE
10+
#define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)
11+
#endif
12+
#define _PyUnicode_AsStringAndSize PyUnicode_AsUTF8AndSize
13+
/**
14+
* The function ``_PyObject_LookupAttrId`` function replaces the combo of
15+
* ``_PyObject_HasAttrId`` followed by ``_PyObject_GetAttrId``; our code isn't
16+
* structured to take advantage of that, so for now we throw away the
17+
* resulting attribute value and continue to make the extra ``Get`` call.
18+
*/
19+
static int _PyObject_HasAttrId(PyObject* obj, void* id)
20+
{
21+
int result;
22+
PyObject* attr_val;
23+
result = _PyObject_LookupAttrId(obj, id, &attr_val);
24+
Py_XDECREF(attr_val);
25+
return result;
26+
}
27+
#endif
28+
729
/* Bump this when new opcodes are added to the pickle protocol. */
830
enum {
931
HIGHEST_PROTOCOL = 3,
@@ -1633,7 +1655,7 @@ save_long(PicklerObject *self, PyObject *obj)
16331655
goto error;
16341656
}
16351657
else {
1636-
char *string;
1658+
const char *string;
16371659

16381660
/* proto < 2: write the repr and newline. This is quadratic-time (in
16391661
the number of digits), in both directions. We add a trailing 'L'
@@ -2929,7 +2951,7 @@ save_pers(PicklerObject *self, PyObject *obj, PyObject *func)
29292951
}
29302952
else {
29312953
PyObject *pid_str = NULL;
2932-
char *pid_ascii_bytes;
2954+
const char *pid_ascii_bytes;
29332955
Py_ssize_t size;
29342956

29352957
pid_str = PyObject_Str(pid);

src/zodbpickle/tests/pickletester_3.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import io
2+
import os
23
import unittest
34
import sys
45
import copyreg
56
import weakref
7+
import tempfile
68
from http.cookies import SimpleCookie
79
from zodbpickle import pickle_3 as pickle
810
from zodbpickle import pickletools_3 as pickletools
911

1012
from test.support import (
11-
TestFailed, TESTFN, run_with_locale,
13+
TestFailed, run_with_locale,
1214
_2G, _4G, bigmemtest,
1315
)
1416

@@ -41,6 +43,8 @@ def wrapper(*args, **kwargs):
4143

4244
ascii_char_size = 1
4345

46+
fd, TESTFN = tempfile.mkstemp('.pickletester_3')
47+
os.close(fd)
4448

4549
# Return True if opcode code appears in the pickle, else False.
4650
def opcode_in_pickle(code, pickle):

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ envlist =
1010
py37,py37-pure
1111
py38,py38-pure
1212
py39,py39-pure
13+
py310,py310-pure
1314
pypy
1415
pypy3
1516
coverage

0 commit comments

Comments
 (0)