Skip to content

Commit f3a9968

Browse files
author
Alex Grönholm
committed
Convert the host name to a binary string before hashing (hashing does not work on unicode objects)
1 parent fd08f8c commit f3a9968

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

bson/objectid.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@
3232

3333
from bson.errors import InvalidId
3434
from bson.tz_util import utc
35+
from bson.compat import b
3536

3637

3738
def _machine_bytes():
3839
"""Get the machine portion of an ObjectId.
3940
"""
4041
machine_hash = _md5func()
41-
machine_hash.update(socket.gethostname())
42+
machine_hash.update(b(socket.gethostname()))
4243
return machine_hash.digest()[0:3]
4344

4445

0 commit comments

Comments
 (0)