chiark / gitweb /
*.c: Introduce a new input conversion for binary strings.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 21 Oct 2019 00:43:54 +0000 (01:43 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 11 Apr 2020 11:44:21 +0000 (12:44 +0100)
commit67c75893d1c2802da465c8973276096a4d862436
tree28d8f1d31f8b684b0d49ee9d06ea5e4b63d1633c
parentd6d78edc37c28e4cae1166fd53a21e3e5293f62b
*.c: Introduce a new input conversion for binary strings.

One of the major differences in Python 3 is that it firmly distinguishes
between binary and text strings: the former consist of small integers,
while the latter consist of Unicode scalars.  The Python 3 `s#'
conversion's main purpose is to accept text strings, and though it will
also accept binary strings it's not really ideal for the purpose.
Python 3 introduces a new conversion `y#' specifically for binary
strings, though this isn't quite what we want because, for some reason,
it /doesn't/ work with bufferish objects which require explicit release.

The best answer seems to be to introduce our own custom conversion for
binary strings, so we do this here, replacing all of the binary-input
argument conversions.  While we're at it, replace all of the by-steam
argument conversions using `PyObject_AsReadBuffer' too.
13 files changed:
algorithms.c
buffer.c
bytestring.c
ec.c
group.c
key.c
mp.c
pubkey.c
pyke/pyke.c
pyke/pyke.h
rand.c
share.c
t/t-buffer.py