# Buggy code
def tls_session_update(self, msg_str):
    """
    Either for parsing or building, we store the client_random
    along with the raw string representing this handshake message.
    """
    super(TLS13ClientHello, self).tls_session_update(msg_str)
    s = self.tls_session

    if self.sidlen and self.sidlen > 0:
        s.sid = self.sid
        s.middlebox_compatibility = True

    self.random_bytes = msg_str[10:38]
    s.client_random = self.random_bytes
    if self.ext:
        for e in self.ext:
            if isinstance(e, TLS_Ext_SupportedVersion_CH):
                for ver in e.versions:
                    # RFC 8701: GREASE of TLS will send unknown versions
                    # here. We have to ignore them
                    if ver in _tls_version:
                        self.tls_session.advertised_tls_version = ver
                        break
            if isinstance(e, TLS_Ext_SignatureAlgorithms):
                s.advertised_sig_algs = e.sig_algs


# Traceback (TypeError)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-4c9f13dcdcd8> in <module>
----> 1 r2 = TLS(pcap[1].load, tls_session=r1.tls_session.mirror())

~/scapy_venv/lib/python3.7/site-packages/scapy/base_classes.py in __call__(cls, *args, **kargs)
264                 cls = config.conf.raw_layer
265         i = cls.__new__(cls, cls.__name__, cls.__bases__, cls.__dict__)
--> 266         i.__init__(*args, **kargs)
267         return i
268

~/scapy_venv/lib/python3.7/site-packages/scapy/layers/tls/record.py in __init__(self, *args, **kargs)
302     def __init__(self, *args, **kargs):
303         self.deciphered_len = kargs.get("deciphered_len", None)
--> 304         super(TLS, self).__init__(*args, **kargs)
305
306     @classmethod

~/scapy_venv/lib/python3.7/site-packages/scapy/layers/tls/session.py in __init__(self, _pkt, post_transform, _internal, _underlayer, tls_session, **fields)
902         Packet.__init__(self, _pkt=_pkt, post_transform=post_transform,
903                         _internal=_internal, _underlayer=_underlayer,
--> 904                         **fields)
905
906     def __getattr__(self, attr):

~/scapy_venv/lib/python3.7/site-packages/scapy/packet.py in __init__(self, _pkt, post_transform, _internal, _underlayer, **fields)
156         self.sniffed_on = None
157         if _pkt:
--> 158             self.dissect(_pkt)
159             if not _internal:
160                 self.dissection_done(self)

~/scapy_venv/lib/python3.7/site-packages/scapy/packet.py in dissect(self, s)
873         s = self.pre_dissect(s)
874
--> 875         s = self.do_dissect(s)
876
877         s = self.post_dissect(s)

~/scapy_venv/lib/python3.7/site-packages/scapy/packet.py in do_dissect(self, s)
837             if not s:
838                 break
--> 839             s, fval = f.getfield(self, s)
840             # We need to track fields with mutable values to discard
841             # .raw_packet_cache when needed.

~/scapy_venv/lib/python3.7/site-packages/scapy/layers/tls/record.py in getfield(self, pkt, s)
166                 if isinstance(p, _GenericTLSSessionInheritance):
167                     if not p.tls_session.frozen:
--> 168                         p.post_dissection_tls_session_update(raw_msg)
169
170                 lst.append(p)

~/scapy_venv/lib/python3.7/site-packages/scapy/layers/tls/session.py in post_dissection_tls_session_update(self, msg_str)
924
925     def post_dissection_tls_session_update(self, msg_str):
--> 926         self.tls_session_update(msg_str)
927
928     def copy(self):

~/scapy_venv/lib/python3.7/site-packages/scapy/layers/tls/handshake.py in tls_session_update(self, msg_str)
648             s.prcs = readConnState(ciphersuite=cs_cls,
649                                    connection_end=connection_end,
--> 650                                    tls_version=s.tls_version)
651             if not s.middlebox_compatibility:
652                 s.triggered_prcs_commit = True

~/scapy_venv/lib/python3.7/site-packages/scapy/layers/tls/session.py in __init__(self, **kargs)
279 class readConnState(connState):
280     def __init__(self, **kargs):
--> 281         connState.__init__(self, read_or_write="read", **kargs)
282
283

~/scapy_venv/lib/python3.7/site-packages/scapy/layers/tls/session.py in __init__(self, connection_end, read_or_write, seq_num, compression_alg, ciphersuite, tls_version)
89             from scapy.layers.tls.crypto.suites import TLS_NULL_WITH_NULL_NULL
90             ciphersuite = TLS_NULL_WITH_NULL_NULL
---> 91         self.ciphersuite = ciphersuite(tls_version=tls_version)
92
93         if not self.ciphersuite.usable:

~/scapy_venv/lib/python3.7/site-packages/scapy/layers/tls/crypto/suites.py in __init__(self, tls_version)
140         """
141         super(_GenericCipherSuite, self).__init__()
--> 142         if tls_version <= 0x301:
143             self.key_block_len = self._key_block_len_v1_0
144

TypeError: '<=' not supported between instances of 'NoneType' and 'int'

# Fixed code
def tls_session_update(self, msg_str):
    """
    Either for parsing or building, we store the client_random
    along with the raw string representing this handshake message.
    """
    super(TLS13ClientHello, self).tls_session_update(msg_str)
    s = self.tls_session

    if self.sidlen and self.sidlen > 0:
        s.sid = self.sid
        s.middlebox_compatibility = True

    self.random_bytes = msg_str[10:38]
    s.client_random = self.random_bytes
    if self.ext:
        for e in self.ext:
            if isinstance(e, TLS_Ext_SupportedVersion_CH):
                for ver in sorted(e.versions, reverse=True):
                    # RFC 8701: GREASE of TLS will send unknown versions
                    # here. We have to ignore them
                    if ver in _tls_version:
                        self.tls_session.advertised_tls_version = ver
                        break
            if isinstance(e, TLS_Ext_SignatureAlgorithms):
                s.advertised_sig_algs = e.sig_algs