问题描述
我使用的是 simplefix (https://github.com/da4089/simplefix) 版本 1.0.14。出于某种原因,我似乎从库中使用了过时的方法。这是错误信息:
Traceback (most recent call last):
File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py",line 954,in _bootstrap_inner
self.run()
File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py",line 892,in run
self._target(*self._args,**self._kwargs)
File "/Users/recapital/Git/tt-fix/client.py",line 59,in run
self._reader.on_message(msg)
File "/Users/recapital/Git/tt-fix/message_handler.py",line 31,in on_message
self.handle_logon(message)
File "/Users/recapital/Git/tt-fix/message_handler.py",line 39,in handle_logon
logon.decode(message)
File "/Users/recapital/Git/tt-fix/tt_messages.py",line 9517,in decode
if (val := message.get(FIELD_ENCRYPT_METHOD,nth)) is not None:
TypeError: <lambda>() takes 1 positional argument but 2 were given
def decode(self,message: FixMessage,nth: int = 1):
if (val := message.get(FIELD_ENCRYPT_METHOD,nth)) is not None:
self.encrypt_method = EncryptMethod(int(val))
这里是 simplefix 中的 get 方法:
def get(self,tag,nth=1):
"""Return n-th value for tag.
:param tag: FIX field tag number.
:param nth: Index of tag if repeating,first is 1.
:return: None if nothing found,otherwise value matching tag.
Defaults to returning the first matching value of 'tag',but if
the 'nth' parameter is overridden,can get repeated fields."""
tag = fix_tag(tag)
nth = int(nth)
for t,v in self.pairs:
if t == tag:
nth -= 1
if nth == 0:
return v
return None
如果我不传递第 n 个参数,它会起作用,但是提供这个(由于重复,我必须这样做)会产生这个奇怪的错误。
编辑:2021.06.23 11:44 CET
def get_field(message: FixMessage,nth=1):
tag = fix_tag(tag)
nth = int(nth)
for t,v in message.pairs:
if t == tag:
nth -= 1
if nth == 0:
return v
return None
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)