Fix legacy bytes conversion for older twisted

This commit is contained in:
Griatch 2021-06-19 14:57:24 +02:00
parent 41986e1288
commit 9df1f9f25f
7 changed files with 19 additions and 28 deletions

View file

@ -15,10 +15,9 @@ This protocol is implemented by the telnet protocol importing
mccp_compress and calling it from its write methods.
"""
import zlib
from twisted.python.compat import _bytesChr as chr
# negotiations for v1 and v2 of the protocol
MCCP = chr(86) # b"\x56"
MCCP = bytes([86]) # b"\x56"
FLUSH = zlib.Z_SYNC_FLUSH

View file

@ -12,11 +12,10 @@ active players and so on.
"""
from django.conf import settings
from evennia.utils import utils
from twisted.python.compat import _bytesChr as bchr
MSSP = bchr(70) # b"\x46"
MSSP_VAR = bchr(1) # b"\x01"
MSSP_VAL = bchr(2) # b"\x02"
MSSP = bytes([70]) # b"\x46"
MSSP_VAR = bytes([1]) # b"\x01"
MSSP_VAL = bytes([2]) # b"\x02"
# try to get the customized mssp info, if it exists.
MSSPTable_CUSTOM = utils.variable_from_module(settings.MSSP_META_MODULE, "MSSPTable", default={})

View file

@ -14,12 +14,11 @@ http://www.gammon.com.au/mushclient/addingservermxp.htm
"""
import re
from twisted.python.compat import _bytesChr as bchr
LINKS_SUB = re.compile(r"\|lc(.*?)\|lt(.*?)\|le", re.DOTALL)
# MXP Telnet option
MXP = bchr(91) # b"\x5b"
MXP = bytes([91]) # b"\x5b"
MXP_TEMPSECURE = "\x1B[4z"
MXP_SEND = MXP_TEMPSECURE + '<SEND HREF="\\1">' + "\\2" + MXP_TEMPSECURE + "</SEND>"

View file

@ -11,10 +11,9 @@ client and update it when the size changes
"""
from codecs import encode as codecs_encode
from django.conf import settings
from twisted.python.compat import _bytesChr as bchr
NAWS = bchr(31) # b"\x1f"
IS = bchr(0) # b"\x00"
NAWS = bytes([31]) # b"\x1f"
IS = bytes([0]) # b"\x00"
# default taken from telnet specification
DEFAULT_WIDTH = settings.CLIENT_DEFAULT_WIDTH
DEFAULT_HEIGHT = settings.CLIENT_DEFAULT_HEIGHT

View file

@ -13,9 +13,7 @@ It is set as the NOGOAHEAD protocol_flag option.
http://www.faqs.org/rfcs/rfc858.html
"""
from twisted.python.compat import _bytesChr as bchr
SUPPRESS_GA = bchr(3) # b"\x03"
SUPPRESS_GA = bytes([3]) # b"\x03"
# default taken from telnet specification

View file

@ -31,23 +31,22 @@ applicable.
import re
import json
from evennia.utils.utils import is_iter
from twisted.python.compat import _bytesChr as bchr
# General Telnet
from twisted.conch.telnet import IAC, SB, SE
# MSDP-relevant telnet cmd/opt-codes
MSDP = bchr(69)
MSDP_VAR = bchr(1)
MSDP_VAL = bchr(2)
MSDP_TABLE_OPEN = bchr(3)
MSDP_TABLE_CLOSE = bchr(4)
MSDP = bytes([69])
MSDP_VAR = bytes([1])
MSDP_VAL = bytes([2])
MSDP_TABLE_OPEN = bytes([3])
MSDP_TABLE_CLOSE = bytes([4])
MSDP_ARRAY_OPEN = bchr(5)
MSDP_ARRAY_CLOSE = bchr(6)
MSDP_ARRAY_OPEN = bytes([5])
MSDP_ARRAY_CLOSE = bytes([6])
# GMCP
GMCP = bchr(201)
GMCP = bytes([201])
# pre-compiled regexes

View file

@ -10,12 +10,10 @@ etc. If the client does not support TTYPE, this will be ignored.
All data will be stored on the protocol's protocol_flags dictionary,
under the 'TTYPE' key.
"""
from twisted.python.compat import _bytesChr as bchr
# telnet option codes
TTYPE = bchr(24) # b"\x18"
IS = bchr(0) # b"\x00"
SEND = bchr(1) # b"\x01"
TTYPE = bytes([24]) # b"\x18"
IS = bytes([0]) # b"\x00"
SEND = bytes([1]) # b"\x01"
# terminal capabilities and their codes
MTTS = [