From 41986e12886f96b9d2d3b540f7c36497e648ccb3 Mon Sep 17 00:00:00 2001 From: Griatch Date: Fri, 18 Jun 2021 19:34:39 +0200 Subject: [PATCH 1/3] Try reporting a little more info from taskhandler deserialization error --- evennia/scripts/taskhandler.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/evennia/scripts/taskhandler.py b/evennia/scripts/taskhandler.py index ab1b29666d..3b826844a1 100644 --- a/evennia/scripts/taskhandler.py +++ b/evennia/scripts/taskhandler.py @@ -340,11 +340,11 @@ class TaskHandler(object): # an unsaveable callback should immediately abort try: dbserialize(callback) - except (TypeError, AttributeError, PickleError): + except (TypeError, AttributeError, PickleError) as err: raise ValueError( - "the specified callback {} cannot be pickled. " + "the specified callback {callback} cannot be pickled. " "It must be a top-level function in a module or an " - "instance method.".format(callback) + "instance method ({err}).".format(callback=callback, err=err) ) return From 9df1f9f25f39d069b94ae816f08bda2748d37840 Mon Sep 17 00:00:00 2001 From: Griatch Date: Sat, 19 Jun 2021 14:57:24 +0200 Subject: [PATCH 2/3] Fix legacy bytes conversion for older twisted --- evennia/server/portal/mccp.py | 3 +-- evennia/server/portal/mssp.py | 7 +++---- evennia/server/portal/mxp.py | 3 +-- evennia/server/portal/naws.py | 5 ++--- evennia/server/portal/suppress_ga.py | 4 +--- evennia/server/portal/telnet_oob.py | 17 ++++++++--------- evennia/server/portal/ttype.py | 8 +++----- 7 files changed, 19 insertions(+), 28 deletions(-) diff --git a/evennia/server/portal/mccp.py b/evennia/server/portal/mccp.py index 2d00e479b6..7ecba2d9d4 100644 --- a/evennia/server/portal/mccp.py +++ b/evennia/server/portal/mccp.py @@ -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 diff --git a/evennia/server/portal/mssp.py b/evennia/server/portal/mssp.py index d939bcc37b..227a713cbf 100644 --- a/evennia/server/portal/mssp.py +++ b/evennia/server/portal/mssp.py @@ -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={}) diff --git a/evennia/server/portal/mxp.py b/evennia/server/portal/mxp.py index 8ff773036d..7c0f2325a5 100644 --- a/evennia/server/portal/mxp.py +++ b/evennia/server/portal/mxp.py @@ -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 + '' + "\\2" + MXP_TEMPSECURE + "" diff --git a/evennia/server/portal/naws.py b/evennia/server/portal/naws.py index caa9f73402..23bc6f2e7b 100644 --- a/evennia/server/portal/naws.py +++ b/evennia/server/portal/naws.py @@ -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 diff --git a/evennia/server/portal/suppress_ga.py b/evennia/server/portal/suppress_ga.py index 21332ea070..4bd8dc2c45 100644 --- a/evennia/server/portal/suppress_ga.py +++ b/evennia/server/portal/suppress_ga.py @@ -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 diff --git a/evennia/server/portal/telnet_oob.py b/evennia/server/portal/telnet_oob.py index 1570feb003..656aac9eaa 100644 --- a/evennia/server/portal/telnet_oob.py +++ b/evennia/server/portal/telnet_oob.py @@ -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 diff --git a/evennia/server/portal/ttype.py b/evennia/server/portal/ttype.py index d74b3ae9db..e74b8e638d 100644 --- a/evennia/server/portal/ttype.py +++ b/evennia/server/portal/ttype.py @@ -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 = [ From 8964c903740f3571e5680570ca58ab0b43d8b3ea Mon Sep 17 00:00:00 2001 From: Griatch Date: Sat, 19 Jun 2021 15:29:15 +0200 Subject: [PATCH 3/3] Python 3.9 support. Resolves #2436. --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24de2405fa..5aff3dc50c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,12 @@ - Latin (la) i18n translation (jamalainm) - Made the `evennia` dir possible to use without gamedir for purpose of doc generation. +### Backports from 1.0 to 0.9.5 since 0.9.5 release + +- Fix to TaskHandler to complate api and allow manipulation of `utils.delay` + return as originall intended. +- Support for Python 3.9. + ### Evennia 0.9.5 (Nov 2020) A transitional release, including new doc system.