tlslite: restore python3 compatibility

dhe_rsa.patch uses some python 2 only constructs, replace with code
that is compatible with both 2 and 3.

Bug: chromium:1041448
Test: tast run <ip> policy.*
Change-Id: I4bba7c77512a2fb51b9b26a05781767f330da97e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2035415
Reviewed-by: David Benjamin <davidben@chromium.org>
Commit-Queue: Victor-Gabriel Savu <vsavu@google.com>
Cr-Original-Commit-Position: refs/heads/master@{#737800}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 8ab71f107c2ee5cf9c1f275db24b6036dc9c2e78
diff --git a/patches/dhe_rsa.patch b/patches/dhe_rsa.patch
index 40218a4..5bb12f0 100644
--- a/patches/dhe_rsa.patch
+++ b/patches/dhe_rsa.patch
@@ -333,7 +333,7 @@
 +    s = s.replace(" ", "").replace("\n", "")
 +    if len(s) % 2 != 0:
 +        raise ValueError("Length is not even")
-+    return bytesToNumber(bytearray(s.decode("hex")))
++    return bytesToNumber(bytearray.fromhex(s))
 +
 +class DHE_RSAKeyExchange(KeyExchange):
 +    # 2048-bit MODP Group (RFC 3526, Section 3)
@@ -486,7 +486,7 @@
 +        try:
 +            premasterSecret = \
 +                keyExchange.processClientKeyExchange(clientKeyExchange)
-+        except TLSLocalAlert, alert:
++        except alert as TLSLocalAlert:
 +            for result in self._sendError(alert.description, alert.message):
 +                yield result
  
diff --git a/tlslite/tlsconnection.py b/tlslite/tlsconnection.py
index cb7160f..efe2b9f 100644
--- a/tlslite/tlsconnection.py
+++ b/tlslite/tlsconnection.py
@@ -78,7 +78,7 @@
     s = s.replace(" ", "").replace("\n", "")
     if len(s) % 2 != 0:
         raise ValueError("Length is not even")
-    return bytesToNumber(bytearray(s.decode("hex")))
+    return bytesToNumber(bytearray.fromhex(s))
 
 class DHE_RSAKeyExchange(KeyExchange):
     # 2048-bit MODP Group (RFC 3526, Section 3)
@@ -1817,7 +1817,7 @@
         try:
             premasterSecret = \
                 keyExchange.processClientKeyExchange(clientKeyExchange)
-        except TLSLocalAlert, alert:
+        except alert as TLSLocalAlert:
             for result in self._sendError(alert.description, alert.message):
                 yield result