8000 Simplify check for bool type (#362) · ossdev07/msgpack-python@5fd6119 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5fd6119

Browse files
brmmm3methane
authored andcommitted
Simplify check for bool type (msgpack#362)
1 parent d10f12d commit 5fd6119

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

msgpack/_packer.pyx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,10 @@ cdef class Packer(object):
153153
while True:
154154
if o is None:
155155
ret = msgpack_pack_nil(&self.pk)
156-
elif PyBool_Check(o) if strict_types else isinstance(o, bool):
157-
if o:
158-
ret = msgpack_pack_true(&self.pk)
159-
else:
160-
ret = msgpack_pack_false(&self.pk)
156+
elif o is True:
157+
ret = msgpack_pack_true(&self.pk)
158+
elif o is False:
159+
ret = msgpack_pack_false(&self.pk)
161160
elif PyLong_CheckExact(o) if strict_types else PyLong_Check(o):
162161
# PyInt_Check(long) is True for Python 3.
163162
# So we should test long before int.

0 commit comments

Comments
 (0)
0