~mdw
/
catacomb-python
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ec.c: Reject strings with trailing junk in the curve-point constructor.
[catacomb-python]
/
bytestring.c
diff --git
a/bytestring.c
b/bytestring.c
index
ced62b4
..
89f3e4a
100644
(file)
--- a/
bytestring.c
+++ b/
bytestring.c
@@
-42,7
+42,9
@@
static PyObject *allocate(PyTypeObject *ty, size_t n)
#if defined(CACHE_HASH) || PY_VERSION_HEX >= 0x02030000
x->ob_shash = -1;
#endif
#if defined(CACHE_HASH) || PY_VERSION_HEX >= 0x02030000
x->ob_shash = -1;
#endif
+#ifdef PY2
x->ob_sstate = SSTATE_NOT_INTERNED;
x->ob_sstate = SSTATE_NOT_INTERNED;
+#endif
return ((PyObject *)x);
}
return ((PyObject *)x);
}
@@
-172,7
+174,11
@@
static PyObject *bytestring_pyitem(PyObject *me, Py_ssize_t i)
PyObject *rc = 0;
if (i < 0 || i >= BIN_LEN(me)) IXERR("out of range");
PyObject *rc = 0;
if (i < 0 || i >= BIN_LEN(me)) IXERR("out of range");
+#ifdef PY3
+ rc = getulong(BIN_PTR(me)[i]&0xff);
+#else
rc = bytestring_pywrap(BIN_PTR(me) + i, 1);
rc = bytestring_pywrap(BIN_PTR(me) + i, 1);
+#endif
end:
return (rc);
}
end:
return (rc);
}
@@
-206,8
+212,8
@@
static PyObject *bytestring_pysubscript(PyObject *me, PyObject *ix)
if (i < 0) i += BIN_LEN(me);
rc = bytestring_pyitem(me, i);
} else if (PySlice_Check(ix)) {
if (i < 0) i += BIN_LEN(me);
rc = bytestring_pyitem(me, i);
} else if (PySlice_Check(ix)) {
- if (PySlice_GetIndicesEx(
(PySliceObject *)ix, BIN_LEN(me)
,
- &i, &j, &k, &n))
+ if (PySlice_GetIndicesEx(
PY23((PySliceObject *), NOTHING)ix
,
+
BIN_LEN(me),
&i, &j, &k, &n))
return (0);
if (k == 1) return bytestring_pyslice(me, i, j);
rc = bytestring_pywrap(0, n);
return (0);
if (k == 1) return bytestring_pyslice(me, i, j);
rc = bytestring_pywrap(0, n);
@@
-266,7
+272,9
@@
static const PyNumberMethods bytestring_pynumber = {
0, /* @nb_add@ */
0, /* @nb_subtract@ */
0, /* @nb_multiply@ */
0, /* @nb_add@ */
0, /* @nb_subtract@ */
0, /* @nb_multiply@ */
+#ifdef PY2
0, /* @nb_divide@ */
0, /* @nb_divide@ */
+#endif
0, /* @nb_remainder@ */
0, /* @nb_divmod@ */
0, /* @nb_power@ */
0, /* @nb_remainder@ */
0, /* @nb_divmod@ */
0, /* @nb_power@ */