chiark / gitweb /
bytestring.c: Check for cached hash more carefully.
[catacomb-python] / bytestring.c
index 6b45d24723ac13c0029522519b3555b643749108..7dcc4065238ffbc14c7d532afa8b76be5c5520c0 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;
@@ -54,7 +54,7 @@ static PyObject *bytestring_pynew(PyTypeObject *ty,
                                  PyObject *arg, PyObject *kw)
 {
   const char *p;
-  int n;
+  Py_ssize_t n;
   static char *kwlist[] = { "data", 0 };
   if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#:new", kwlist, &p, &n))
     return (0);
@@ -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;                 \
@@ -130,7 +130,7 @@ static PyBufferProcs bytestring_pybuffer;
 
 static PyTypeObject bytestring_pytype_skel = {
   PyObject_HEAD_INIT(0) 0,             /* Header */
-  "catacomb.ByteString",               /* @tp_name@ */
+  "ByteString",                                /* @tp_name@ */
   0,                                   /* @tp_basicsize@ */
   0,                                   /* @tp_itemsize@ */