Merge pull request #3726 from 0xDEADFED5/main

fix create/destroy bug that surfaced in Twisted 24, get rid of some uses of returnValue()
This commit is contained in:
Griatch 2025-02-15 10:15:31 +01:00 committed by GitHub
commit 0e5840dc7e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 17 deletions

View file

@ -37,7 +37,7 @@ from weakref import WeakValueDictionary
from django.conf import settings from django.conf import settings
from django.utils.translation import gettext as _ from django.utils.translation import gettext as _
from twisted.internet import reactor from twisted.internet import reactor
from twisted.internet.defer import inlineCallbacks, returnValue from twisted.internet.defer import inlineCallbacks
from twisted.internet.task import deferLater from twisted.internet.task import deferLater
from evennia.commands.cmdset import CmdSet from evennia.commands.cmdset import CmdSet
@ -390,7 +390,7 @@ def get_and_merge_cmdsets(
# explicitly. # explicitly.
cset.old_duplicates = cset.duplicates cset.old_duplicates = cset.duplicates
cset.duplicates = True if cset.duplicates is None else cset.duplicates cset.duplicates = True if cset.duplicates is None else cset.duplicates
returnValue(local_obj_cmdsets) return local_obj_cmdsets
except Exception: except Exception:
_msg_err(caller, _ERROR_CMDSETS) _msg_err(caller, _ERROR_CMDSETS)
raise ErrorReported(raw_string) raise ErrorReported(raw_string)
@ -408,9 +408,9 @@ def get_and_merge_cmdsets(
_msg_err(caller, _ERROR_CMDSETS) _msg_err(caller, _ERROR_CMDSETS)
raise ErrorReported(raw_string) raise ErrorReported(raw_string)
try: try:
returnValue(obj.get_cmdsets(caller=caller, current=current)) return obj.get_cmdsets(caller=caller, current=current)
except AttributeError: except AttributeError:
returnValue((CmdSet(), [])) return (CmdSet(), [])
local_obj_cmdsets = [] local_obj_cmdsets = []
@ -486,7 +486,7 @@ def get_and_merge_cmdsets(
# if cmdset: # if cmdset:
# caller.cmdset.current = cmdset # caller.cmdset.current = cmdset
returnValue(cmdset) return cmdset
except ErrorReported: except ErrorReported:
raise raise
except Exception: except Exception:
@ -600,7 +600,7 @@ def cmdhandler(
if _testing: if _testing:
# only return the command instance # only return the command instance
returnValue(cmd) return cmd
# assign custom kwargs to found cmd object # assign custom kwargs to found cmd object
for key, val in kwargs.items(): for key, val in kwargs.items():
@ -619,7 +619,7 @@ def cmdhandler(
abort = yield cmd.at_pre_cmd() abort = yield cmd.at_pre_cmd()
if abort: if abort:
# abort sequence # abort sequence
returnValue(abort) return abort
# Parse and execute # Parse and execute
yield cmd.parse() yield cmd.parse()
@ -630,14 +630,12 @@ def cmdhandler(
if isinstance(ret, types.GeneratorType): if isinstance(ret, types.GeneratorType):
# cmd.func() is a generator, execute progressively # cmd.func() is a generator, execute progressively
_progressive_cmd_run(cmd, ret) _progressive_cmd_run(cmd, ret)
ret = yield ret
# note that the _progressive_cmd_run will itself run # note that the _progressive_cmd_run will itself run
# the at_post_cmd etc as it finishes; this is a bit of # the at_post_cmd etc as it finishes; this is a bit of
# code duplication but there seems to be no way to # code duplication but there seems to be no way to
# catch the StopIteration here (it's not in the same # catch the StopIteration here (it's not in the same
# frame since this is in a deferred chain) # frame since this is in a deferred chain)
else: else:
ret = yield ret
# post-command hook # post-command hook
yield cmd.at_post_cmd() yield cmd.at_post_cmd()
@ -648,9 +646,6 @@ def cmdhandler(
else: else:
caller.ndb.last_cmd = None caller.ndb.last_cmd = None
# return result to the deferred
returnValue(ret)
except InterruptCommand: except InterruptCommand:
# Do nothing, clean exit # Do nothing, clean exit
pass pass
@ -759,10 +754,9 @@ def cmdhandler(
cmd = copy(cmd) cmd = copy(cmd)
# A normal command. # A normal command.
ret = yield _run_command( yield _run_command(
cmd, cmdname, args, raw_cmdname, cmdset, session, account, cmdset_providers cmd, cmdname, args, raw_cmdname, cmdset, session, account, cmdset_providers
) )
returnValue(ret)
except ErrorReported as exc: except ErrorReported as exc:
# this error was already reported, so we # this error was already reported, so we
@ -776,7 +770,7 @@ def cmdhandler(
sysarg = exc.sysarg sysarg = exc.sysarg
if syscmd: if syscmd:
ret = yield _run_command( yield _run_command(
syscmd, syscmd,
syscmd.key, syscmd.key,
sysarg, sysarg,
@ -786,7 +780,7 @@ def cmdhandler(
account, account,
cmdset_providers, cmdset_providers,
) )
returnValue(ret) return
elif sysarg: elif sysarg:
# return system arg # return system arg
error_to.msg(err_helper(exc.sysarg, cmdid=cmdid)) error_to.msg(err_helper(exc.sysarg, cmdid=cmdid))

View file

@ -111,7 +111,7 @@ extra = [
"django-extensions >= 3.1.0", "django-extensions >= 3.1.0",
# xyzroom contrib # xyzroom contrib
"scipy == 1.12.0", "scipy == 1.15.1",
# Git contrib # Git contrib
"gitpython >= 3.1.27", "gitpython >= 3.1.27",