From 07f19b6350bfa2c293b11ba781394052ee333a54 Mon Sep 17 00:00:00 2001 From: lovetox Date: Sun, 30 Jan 2022 17:13:02 +0100 Subject: Remove superfluous isinstance() call (#1087) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - hex() returns always str - don’t redefine variable --- src/OpenSSL/crypto.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/OpenSSL') diff --git a/src/OpenSSL/crypto.py b/src/OpenSSL/crypto.py index c3ac618..ff23062 100644 --- a/src/OpenSSL/crypto.py +++ b/src/OpenSSL/crypto.py @@ -1299,15 +1299,14 @@ class X509(object): raise TypeError("serial must be an integer") hex_serial = hex(serial)[2:] - if not isinstance(hex_serial, bytes): - hex_serial = hex_serial.encode("ascii") + hex_serial_bytes = hex_serial.encode("ascii") bignum_serial = _ffi.new("BIGNUM**") # BN_hex2bn stores the result in &bignum. Unless it doesn't feel like # it. If bignum is still NULL after this call, then the return value # is actually the result. I hope. -exarkun - small_serial = _lib.BN_hex2bn(bignum_serial, hex_serial) + small_serial = _lib.BN_hex2bn(bignum_serial, hex_serial_bytes) if bignum_serial[0] == _ffi.NULL: set_result = _lib.ASN1_INTEGER_set( -- cgit v1.2.1