Skip to content

Commit 07f19b6

Browse files
authored
Remove superfluous isinstance() call (#1087)
- hex() returns always str - don’t redefine variable
1 parent ee3a7c2 commit 07f19b6

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/OpenSSL/crypto.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,15 +1299,14 @@ def set_serial_number(self, serial):
12991299
raise TypeError("serial must be an integer")
13001300

13011301
hex_serial = hex(serial)[2:]
1302-
if not isinstance(hex_serial, bytes):
1303-
hex_serial = hex_serial.encode("ascii")
1302+
hex_serial_bytes = hex_serial.encode("ascii")
13041303

13051304
bignum_serial = _ffi.new("BIGNUM**")
13061305

13071306
# BN_hex2bn stores the result in &bignum. Unless it doesn't feel like
13081307
# it. If bignum is still NULL after this call, then the return value
13091308
# is actually the result. I hope. -exarkun
1310-
small_serial = _lib.BN_hex2bn(bignum_serial, hex_serial)
1309+
small_serial = _lib.BN_hex2bn(bignum_serial, hex_serial_bytes)
13111310

13121311
if bignum_serial[0] == _ffi.NULL:
13131312
set_result = _lib.ASN1_INTEGER_set(

0 commit comments

Comments
 (0)