chiark / gitweb /
bytestring.c: Check for cached hash more carefully.
[catacomb-python] / bytestring.c
index 99c114cc26ceb497cd8b8a5e5dc4f5f9815fae02..4a7378da218e2315ec4d99b246750754c7217011 100644 (file)
@@ -37,7 +37,7 @@ static PyObject *dowrap(PyTypeObject *ty, const void *p, size_t n)
   PyStringObject *x = (PyStringObject *)ty->tp_alloc(ty, n);
   if (p) memcpy(x->ob_sval, p, n);
   x->ob_sval[n] = 0;
-#ifdef CACHE_HASH
+#if defined(CACHE_HASH) || PY_VERSION_HEX >= 0x02030000
   x->ob_shash = -1;
 #endif
   x->ob_sstate = SSTATE_NOT_INTERNED;
@@ -66,7 +66,7 @@ static PyObject *bytestring_pynew(PyTypeObject *ty,
     const void *xv, *yv;                                               \
     const unsigned char *xp, *yp;                                      \
     unsigned char *zp;                                                 \
-    int xsz, ysz;                                                      \
+    Py_ssize_t xsz, ysz;                                               \
     int i;                                                             \
     PyObject *rc = 0;                                                  \
     if (PyObject_AsReadBuffer(x, &xv, &xsz) ||                         \
@@ -88,7 +88,7 @@ BINOP(xor, ^)
     const void *xv;                                                    \
     const unsigned char *xp;                                           \
     unsigned char *zp;                                                 \
-    int xsz;                                                           \
+    Py_ssize_t xsz;                                                    \
     int i;                                                             \
     PyObject *rc = 0;                                                  \
     if (PyObject_AsReadBuffer(x, &xv, &xsz)) goto end;                 \