|
48 | 48 |
|
49 | 49 | /* Use byte string on PY2 */ |
50 | 50 | #if PY_MAJOR_VERSION < 3 |
51 | | -#define PyUnicode_FromStringAndSize PyString_FromStringAndSize |
| 51 | +#define MyPyUnicode_FromStringAndSize PyString_FromStringAndSize |
52 | 52 | #define PyBytes_FromStringAndSize PyString_FromStringAndSize |
| 53 | +#else |
| 54 | +#define MyPyUnicode_FromStringAndSize PyUnicode_FromStringAndSize |
53 | 55 | #endif |
54 | 56 |
|
55 | 57 | /***************************************************************************** |
@@ -127,7 +129,7 @@ static PyObject *xxh32_hexdigest(PyObject *self, PyObject *args, PyObject *kwarg |
127 | 129 | retbuf[j++] = c; |
128 | 130 | } |
129 | 131 |
|
130 | | - return PyUnicode_FromStringAndSize(retbuf, sizeof(retbuf)); |
| 132 | + return MyPyUnicode_FromStringAndSize(retbuf, sizeof(retbuf)); |
131 | 133 | } |
132 | 134 |
|
133 | 135 | /* XXH64 */ |
@@ -204,7 +206,7 @@ static PyObject *xxh64_hexdigest(PyObject *self, PyObject *args, PyObject *kwarg |
204 | 206 | retbuf[j++] = c; |
205 | 207 | } |
206 | 208 |
|
207 | | - return PyUnicode_FromStringAndSize(retbuf, sizeof(retbuf)); |
| 209 | + return MyPyUnicode_FromStringAndSize(retbuf, sizeof(retbuf)); |
208 | 210 | } |
209 | 211 |
|
210 | 212 | /* XXH3_64 */ |
@@ -282,7 +284,7 @@ static PyObject *xxh3_64_hexdigest(PyObject *self, PyObject *args, PyObject *kwa |
282 | 284 | retbuf[j++] = c; |
283 | 285 | } |
284 | 286 |
|
285 | | - return PyUnicode_FromStringAndSize(retbuf, sizeof(retbuf)); |
| 287 | + return MyPyUnicode_FromStringAndSize(retbuf, sizeof(retbuf)); |
286 | 288 | } |
287 | 289 |
|
288 | 290 | /* XXH3_128 */ |
@@ -372,7 +374,7 @@ static PyObject *xxh3_128_hexdigest(PyObject *self, PyObject *args, PyObject *kw |
372 | 374 | retbuf[j++] = c; |
373 | 375 | } |
374 | 376 |
|
375 | | - return PyUnicode_FromStringAndSize(retbuf, sizeof(retbuf)); |
| 377 | + return MyPyUnicode_FromStringAndSize(retbuf, sizeof(retbuf)); |
376 | 378 | } |
377 | 379 |
|
378 | 380 | /***************************************************************************** |
@@ -513,7 +515,7 @@ static PyObject *PYXXH32_hexdigest(PYXXH32Object *self) |
513 | 515 | retbuf[j++] = c; |
514 | 516 | } |
515 | 517 |
|
516 | | - return PyUnicode_FromStringAndSize(retbuf, sizeof(retbuf)); |
| 518 | + return MyPyUnicode_FromStringAndSize(retbuf, sizeof(retbuf)); |
517 | 519 | } |
518 | 520 |
|
519 | 521 | PyDoc_STRVAR( |
@@ -586,7 +588,7 @@ PYXXH32_get_digest_size(PYXXH32Object *self, void *closure) |
586 | 588 | static PyObject * |
587 | 589 | PYXXH32_get_name(PYXXH32Object *self, void *closure) |
588 | 590 | { |
589 | | - return PyUnicode_FromStringAndSize("XXH32", sizeof("XXH32")); |
| 591 | + return MyPyUnicode_FromStringAndSize("XXH32", sizeof("XXH32")); |
590 | 592 | } |
591 | 593 |
|
592 | 594 | static PyObject * |
@@ -820,7 +822,7 @@ static PyObject *PYXXH64_hexdigest(PYXXH64Object *self) |
820 | 822 | retbuf[j++] = c; |
821 | 823 | } |
822 | 824 |
|
823 | | - return PyUnicode_FromStringAndSize(retbuf, sizeof(retbuf)); |
| 825 | + return MyPyUnicode_FromStringAndSize(retbuf, sizeof(retbuf)); |
824 | 826 | } |
825 | 827 |
|
826 | 828 |
|
@@ -894,7 +896,7 @@ PYXXH64_get_digest_size(PYXXH64Object *self, void *closure) |
894 | 896 | static PyObject * |
895 | 897 | PYXXH64_get_name(PYXXH64Object *self, void *closure) |
896 | 898 | { |
897 | | - return PyUnicode_FromStringAndSize("XXH64", sizeof("XXH64")); |
| 899 | + return MyPyUnicode_FromStringAndSize("XXH64", sizeof("XXH64")); |
898 | 900 | } |
899 | 901 |
|
900 | 902 | static PyObject * |
@@ -1129,7 +1131,7 @@ static PyObject *PYXXH3_64_hexdigest(PYXXH3_64Object *self) |
1129 | 1131 | retbuf[j++] = c; |
1130 | 1132 | } |
1131 | 1133 |
|
1132 | | - return PyUnicode_FromStringAndSize(retbuf, sizeof(retbuf)); |
| 1134 | + return MyPyUnicode_FromStringAndSize(retbuf, sizeof(retbuf)); |
1133 | 1135 | } |
1134 | 1136 |
|
1135 | 1137 |
|
@@ -1210,7 +1212,7 @@ PYXXH3_64_get_digest_size(PYXXH3_64Object *self, void *closure) |
1210 | 1212 | static PyObject * |
1211 | 1213 | PYXXH3_64_get_name(PYXXH3_64Object *self, void *closure) |
1212 | 1214 | { |
1213 | | - return PyUnicode_FromStringAndSize("XXH3_64", sizeof("XXH3_64")); |
| 1215 | + return MyPyUnicode_FromStringAndSize("XXH3_64", sizeof("XXH3_64")); |
1214 | 1216 | } |
1215 | 1217 |
|
1216 | 1218 | static PyObject * |
@@ -1446,7 +1448,7 @@ static PyObject *PYXXH3_128_hexdigest(PYXXH3_128Object *self) |
1446 | 1448 | retbuf[j++] = c; |
1447 | 1449 | } |
1448 | 1450 |
|
1449 | | - return PyUnicode_FromStringAndSize(retbuf, sizeof(retbuf)); |
| 1451 | + return MyPyUnicode_FromStringAndSize(retbuf, sizeof(retbuf)); |
1450 | 1452 | } |
1451 | 1453 |
|
1452 | 1454 |
|
@@ -1542,7 +1544,7 @@ PYXXH3_128_get_digest_size(PYXXH3_128Object *self, void *closure) |
1542 | 1544 | static PyObject * |
1543 | 1545 | PYXXH3_128_get_name(PYXXH3_128Object *self, void *closure) |
1544 | 1546 | { |
1545 | | - return PyUnicode_FromStringAndSize("XXH3_128", sizeof("XXH3_128")); |
| 1547 | + return MyPyUnicode_FromStringAndSize("XXH3_128", sizeof("XXH3_128")); |
1546 | 1548 | } |
1547 | 1549 |
|
1548 | 1550 | static PyObject * |
|
0 commit comments