Skip to content
This repository was archived by the owner on Apr 19, 2024. It is now read-only.

Commit 0da4962

Browse files
committed
note exceptions on looking up missing codecs
1 parent c04ef0a commit 0da4962

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

multihash.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,13 @@ def encode(self, encoding=None):
306306
>>> mh.encode()
307307
b'\x01\x04TEST'
308308
309-
If an `encoding` is specified, it is used to encode the binary digest
310-
before returning it (see `Codecs` for supported codecs):
309+
If the name of an `encoding` is specified, it is used to encode the
310+
binary digest before returning it (see `Codecs` for supported codecs):
311311
312312
>>> mh.encode('base64')
313313
b'AQRURVNU'
314+
315+
If the `encoding` is not available, a `KeyError` is raised.
314316
"""
315317
try:
316318
fc = self.func.value
@@ -374,7 +376,7 @@ def decode(mhash, encoding=None):
374376
>>> mh == (Func.sha1, mhash[2:])
375377
True
376378
377-
If an `encoding` is specified, it is used to decode the digest
379+
If the name of an `encoding` is specified, it is used to decode the digest
378380
before parsing it (see `Codecs` for supported codecs):
379381
380382
>>> import base64
@@ -383,8 +385,8 @@ def decode(mhash, encoding=None):
383385
>>> emh == mh
384386
True
385387
386-
If the digest has an invalid format or contains invalid data, a
387-
`ValueError` is raised.
388+
If the `encoding` is not available, a `KeyError` is raised. If the digest
389+
has an invalid format or contains invalid data, a `ValueError` is raised.
388390
"""
389391
mhash = bytes(mhash)
390392
if encoding:

0 commit comments

Comments
 (0)