Skip to content

Commit e51103f

Browse files
committed
Deal with warning: 'PyUnicode_FromStringAndSize' macro redefined
1 parent 167ef42 commit e51103f

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

src/_xxhash.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@
4848

4949
/* Use byte string on PY2 */
5050
#if PY_MAJOR_VERSION < 3
51-
#define PyUnicode_FromStringAndSize PyString_FromStringAndSize
51+
#define MyPyUnicode_FromStringAndSize PyString_FromStringAndSize
5252
#define PyBytes_FromStringAndSize PyString_FromStringAndSize
53+
#else
54+
#define MyPyUnicode_FromStringAndSize PyUnicode_FromStringAndSize
5355
#endif
5456

5557
/*****************************************************************************
@@ -127,7 +129,7 @@ static PyObject *xxh32_hexdigest(PyObject *self, PyObject *args, PyObject *kwarg
127129
retbuf[j++] = c;
128130
}
129131

130-
return PyUnicode_FromStringAndSize(retbuf, sizeof(retbuf));
132+
return MyPyUnicode_FromStringAndSize(retbuf, sizeof(retbuf));
131133
}
132134

133135
/* XXH64 */
@@ -204,7 +206,7 @@ static PyObject *xxh64_hexdigest(PyObject *self, PyObject *args, PyObject *kwarg
204206
retbuf[j++] = c;
205207
}
206208

207-
return PyUnicode_FromStringAndSize(retbuf, sizeof(retbuf));
209+
return MyPyUnicode_FromStringAndSize(retbuf, sizeof(retbuf));
208210
}
209211

210212
/* XXH3_64 */
@@ -282,7 +284,7 @@ static PyObject *xxh3_64_hexdigest(PyObject *self, PyObject *args, PyObject *kwa
282284
retbuf[j++] = c;
283285
}
284286

285-
return PyUnicode_FromStringAndSize(retbuf, sizeof(retbuf));
287+
return MyPyUnicode_FromStringAndSize(retbuf, sizeof(retbuf));
286288
}
287289

288290
/* XXH3_128 */
@@ -372,7 +374,7 @@ static PyObject *xxh3_128_hexdigest(PyObject *self, PyObject *args, PyObject *kw
372374
retbuf[j++] = c;
373375
}
374376

375-
return PyUnicode_FromStringAndSize(retbuf, sizeof(retbuf));
377+
return MyPyUnicode_FromStringAndSize(retbuf, sizeof(retbuf));
376378
}
377379

378380
/*****************************************************************************
@@ -513,7 +515,7 @@ static PyObject *PYXXH32_hexdigest(PYXXH32Object *self)
513515
retbuf[j++] = c;
514516
}
515517

516-
return PyUnicode_FromStringAndSize(retbuf, sizeof(retbuf));
518+
return MyPyUnicode_FromStringAndSize(retbuf, sizeof(retbuf));
517519
}
518520

519521
PyDoc_STRVAR(
@@ -586,7 +588,7 @@ PYXXH32_get_digest_size(PYXXH32Object *self, void *closure)
586588
static PyObject *
587589
PYXXH32_get_name(PYXXH32Object *self, void *closure)
588590
{
589-
return PyUnicode_FromStringAndSize("XXH32", sizeof("XXH32"));
591+
return MyPyUnicode_FromStringAndSize("XXH32", sizeof("XXH32"));
590592
}
591593

592594
static PyObject *
@@ -820,7 +822,7 @@ static PyObject *PYXXH64_hexdigest(PYXXH64Object *self)
820822
retbuf[j++] = c;
821823
}
822824

823-
return PyUnicode_FromStringAndSize(retbuf, sizeof(retbuf));
825+
return MyPyUnicode_FromStringAndSize(retbuf, sizeof(retbuf));
824826
}
825827

826828

@@ -894,7 +896,7 @@ PYXXH64_get_digest_size(PYXXH64Object *self, void *closure)
894896
static PyObject *
895897
PYXXH64_get_name(PYXXH64Object *self, void *closure)
896898
{
897-
return PyUnicode_FromStringAndSize("XXH64", sizeof("XXH64"));
899+
return MyPyUnicode_FromStringAndSize("XXH64", sizeof("XXH64"));
898900
}
899901

900902
static PyObject *
@@ -1129,7 +1131,7 @@ static PyObject *PYXXH3_64_hexdigest(PYXXH3_64Object *self)
11291131
retbuf[j++] = c;
11301132
}
11311133

1132-
return PyUnicode_FromStringAndSize(retbuf, sizeof(retbuf));
1134+
return MyPyUnicode_FromStringAndSize(retbuf, sizeof(retbuf));
11331135
}
11341136

11351137

@@ -1210,7 +1212,7 @@ PYXXH3_64_get_digest_size(PYXXH3_64Object *self, void *closure)
12101212
static PyObject *
12111213
PYXXH3_64_get_name(PYXXH3_64Object *self, void *closure)
12121214
{
1213-
return PyUnicode_FromStringAndSize("XXH3_64", sizeof("XXH3_64"));
1215+
return MyPyUnicode_FromStringAndSize("XXH3_64", sizeof("XXH3_64"));
12141216
}
12151217

12161218
static PyObject *
@@ -1446,7 +1448,7 @@ static PyObject *PYXXH3_128_hexdigest(PYXXH3_128Object *self)
14461448
retbuf[j++] = c;
14471449
}
14481450

1449-
return PyUnicode_FromStringAndSize(retbuf, sizeof(retbuf));
1451+
return MyPyUnicode_FromStringAndSize(retbuf, sizeof(retbuf));
14501452
}
14511453

14521454

@@ -1542,7 +1544,7 @@ PYXXH3_128_get_digest_size(PYXXH3_128Object *self, void *closure)
15421544
static PyObject *
15431545
PYXXH3_128_get_name(PYXXH3_128Object *self, void *closure)
15441546
{
1545-
return PyUnicode_FromStringAndSize("XXH3_128", sizeof("XXH3_128"));
1547+
return MyPyUnicode_FromStringAndSize("XXH3_128", sizeof("XXH3_128"));
15461548
}
15471549

15481550
static PyObject *

0 commit comments

Comments
 (0)