Skip to content

Commit 217b59c

Browse files
committed
docs: update docstrings to reflect bytes-only input
- 'string data' -> 'bytes-like data' in update() docstrings - 'strings passed' -> 'data passed' in digest() docstrings - Add docstring tests to verify no 'string' references
1 parent d63600c commit 217b59c

2 files changed

Lines changed: 23 additions & 8 deletions

File tree

src/_xxhash.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ static int PYXXH32_init(PYXXH32Object *self, PyObject *args, PyObject *kwargs)
572572
PyDoc_STRVAR(
573573
PYXXH32_update_doc,
574574
"update (data)\n\n"
575-
"Update the xxh32 object with the string data. Repeated calls are\n"
575+
"Update the xxh32 object with bytes-like data. Repeated calls are\n"
576576
"equivalent to a single call with the concatenation of all the arguments.");
577577

578578
static PyObject *PYXXH32_update(PYXXH32Object *self, PyObject *arg)
@@ -593,7 +593,7 @@ static PyObject *PYXXH32_update(PYXXH32Object *self, PyObject *arg)
593593
PyDoc_STRVAR(
594594
PYXXH32_digest_doc,
595595
"digest() -> string\n\n"
596-
"Return the digest of the strings passed to the update() method so\n"
596+
"Return the digest of the data passed to the update() method so\n"
597597
"far. This is a 4-byte string which may contain non-ASCII characters,\n"
598598
"including null bytes.");
599599

@@ -927,7 +927,7 @@ static int PYXXH64_init(PYXXH64Object *self, PyObject *args, PyObject *kwargs)
927927
PyDoc_STRVAR(
928928
PYXXH64_update_doc,
929929
"update (data)\n\n"
930-
"Update the xxh64 object with the string data. Repeated calls are\n"
930+
"Update the xxh64 object with bytes-like data. Repeated calls are\n"
931931
"equivalent to a single call with the concatenation of all the arguments.");
932932

933933
static PyObject *PYXXH64_update(PYXXH64Object *self, PyObject *arg)
@@ -947,7 +947,7 @@ static PyObject *PYXXH64_update(PYXXH64Object *self, PyObject *arg)
947947
PyDoc_STRVAR(
948948
PYXXH64_digest_doc,
949949
"digest() -> string\n\n"
950-
"Return the digest of the strings passed to the update() method so\n"
950+
"Return the digest of the data passed to the update() method so\n"
951951
"far. This is a 8-byte string which may contain non-ASCII characters,\n"
952952
"including null bytes.");
953953

@@ -1281,7 +1281,7 @@ static int PYXXH3_64_init(PYXXH3_64Object *self, PyObject *args, PyObject *kwarg
12811281
PyDoc_STRVAR(
12821282
PYXXH3_64_update_doc,
12831283
"update (data)\n\n"
1284-
"Update the xxh3_64 object with the string data. Repeated calls are\n"
1284+
"Update the xxh3_64 object with bytes-like data. Repeated calls are\n"
12851285
"equivalent to a single call with the concatenation of all the arguments.");
12861286

12871287
static PyObject *PYXXH3_64_update(PYXXH3_64Object *self, PyObject *arg)
@@ -1301,7 +1301,7 @@ static PyObject *PYXXH3_64_update(PYXXH3_64Object *self, PyObject *arg)
13011301
PyDoc_STRVAR(
13021302
PYXXH3_64_digest_doc,
13031303
"digest() -> string\n\n"
1304-
"Return the digest of the strings passed to the update() method so\n"
1304+
"Return the digest of the data passed to the update() method so\n"
13051305
"far. This is a 8-byte string which may contain non-ASCII characters,\n"
13061306
"including null bytes.");
13071307

@@ -1644,7 +1644,7 @@ static int PYXXH3_128_init(PYXXH3_128Object *self, PyObject *args, PyObject *kwa
16441644
PyDoc_STRVAR(
16451645
PYXXH3_128_update_doc,
16461646
"update (data)\n\n"
1647-
"Update the xxh3_128 object with the string data. Repeated calls are\n"
1647+
"Update the xxh3_128 object with bytes-like data. Repeated calls are\n"
16481648
"equivalent to a single call with the concatenation of all the arguments.");
16491649

16501650
static PyObject *PYXXH3_128_update(PYXXH3_128Object *self, PyObject *arg)
@@ -1664,7 +1664,7 @@ static PyObject *PYXXH3_128_update(PYXXH3_128Object *self, PyObject *arg)
16641664
PyDoc_STRVAR(
16651665
PYXXH3_128_digest_doc,
16661666
"digest() -> string\n\n"
1667-
"Return the digest of the strings passed to the update() method so\n"
1667+
"Return the digest of the data passed to the update() method so\n"
16681668
"far. This is a 16-byte string which may contain non-ASCII characters,\n"
16691669
"including null bytes.");
16701670

tests/test_hashlib_compat.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,21 @@ def test_str_rejected_update(self):
3939
'Strings must be encoded before hashing'):
4040
obj.update('hello')
4141

42+
# ── docstrings reflect bytes-only input ─────────────────────────
43+
44+
def test_update_docstring(self):
45+
for algo in ('xxh32', 'xxh64', 'xxh3_64', 'xxh3_128'):
46+
obj = getattr(xxhash, algo)()
47+
doc = obj.update.__doc__
48+
self.assertIn('bytes-like', doc)
49+
self.assertNotIn('string', doc)
50+
51+
def test_digest_docstring(self):
52+
for algo in ('xxh32', 'xxh64', 'xxh3_64', 'xxh3_128'):
53+
obj = getattr(xxhash, algo)()
54+
doc = obj.digest.__doc__
55+
self.assertNotIn('strings passed', doc)
56+
4257
# ── data keyword ───────────────────────────────────────────────
4358

4459
def test_data_keyword(self):

0 commit comments

Comments
 (0)