summaryrefslogtreecommitdiffstats
path: root/ffi
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2019-01-25 15:48:50 +0100
committerNeal H. Walfield <neal@pep.foundation>2019-01-25 15:48:50 +0100
commit261c5b8a2aada7fb88e95828293d2d0a90144d84 (patch)
tree80a195d53400d2b80ee98e27986747e3e80927bf /ffi
parent2a162dcaf165e59b72a24825bdc2e1c627979d23 (diff)
python: Only use features found in Debian Stable (Debian 9)
- CDefError is not exposed as cffi.error.CDefError, but as cffi.api.CDefError in python3-cffi 1.9.1-2. This change is forwards compatible with python3-cffi 1.11.5-3 (from Debian Testing). - enum.auto is only available in Python v3.6. Albeit uglier, manually assigning values works in Python v3.5 (and later).
Diffstat (limited to 'ffi')
-rw-r--r--ffi/lang/python/sequoia/sequoia_build.py5
-rw-r--r--ffi/lang/python/tests/test_packet_parser.py13
2 files changed, 11 insertions, 7 deletions
diff --git a/ffi/lang/python/sequoia/sequoia_build.py b/ffi/lang/python/sequoia/sequoia_build.py
index ea0ad9df..7345097b 100644
--- a/ffi/lang/python/sequoia/sequoia_build.py
+++ b/ffi/lang/python/sequoia/sequoia_build.py
@@ -1,5 +1,6 @@
from os.path import join, dirname
-from cffi import FFI, error
+from cffi import FFI
+from cffi.api import CDefError
from itertools import chain
sq_inc = join(dirname(__file__), '../../../include/sequoia')
@@ -29,7 +30,7 @@ ffibuilder.cdef('void free (void *ptr);')
try:
ffibuilder.cdef(defs, override=True)
-except error.CDefError as e:
+except CDefError as e:
try:
current_decl = e.args[1]
linenum = current_decl.coord.line
diff --git a/ffi/lang/python/tests/test_packet_parser.py b/ffi/lang/python/tests/test_packet_parser.py
index 1c134f6f..de126bc3 100644
--- a/ffi/lang/python/tests/test_packet_parser.py
+++ b/ffi/lang/python/tests/test_packet_parser.py
@@ -1,4 +1,4 @@
-from enum import Enum, auto
+from enum import Enum
from sequoia.core import Context, NetworkPolicy
from sequoia.openpgp import Tag, PacketParser
@@ -11,10 +11,13 @@ def test_decryption():
ephemeral=True)
class State(Enum):
- Start = auto()
- Decrypted = auto()
- Deciphered = auto()
- Done = auto()
+ # XXX: In Python 3.6, we can use enum.auto() to assign values.
+ # But we want to support Debian 9, which uses Python 3.5, as
+ # long as it is Debian stable.
+ Start = 1
+ Decrypted = 2
+ Deciphered = 3
+ Done = 4
state = State.Start
algo, key = None, None