rhming / UnicomDailyTask

联通日常任务 腾讯云函数定时执行
MIT License
152 stars 77 forks source link

日志中报错TypeError: __init__() got an unexpected keyword argument 'encoding' #70

Open c90c90 opened 2 years ago

c90c90 commented 2 years ago
########################queryParamToDict######################## 1**********
#############################index############################## 1**********
收货地址存在
Exception in thread Thread-9:
Traceback (most recent call last):
  File "/usr/lib/python3.9/threading.py", line 973, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.9/threading.py", line 910, in run
    self._target(*self._args, **self._kwargs)
  File "/ql/scripts/UnicomDailyTask/activity/woread/prizedetail.py", line 110, in run
    self.index(item)
  File "/ql/scripts/UnicomDailyTask/activity/woread/prizedetail.py", line 56, in index
    self.addrInfo = json.loads(
  File "/ql/scripts/UnicomDailyTask/utils/jsonencode.py", line 13, in loads
    return jsonpickle.loads(value)
  File "/usr/lib/python3.9/site-packages/jsonpickle/unpickler.py", line 64, in decode
    data = backend.decode(string)
  File "/usr/lib/python3.9/site-packages/jsonpickle/backend.py", line 207, in decode
    return self.backend_decode(name, string)
  File "/usr/lib/python3.9/site-packages/jsonpickle/backend.py", line 220, in backend_decode
    return self._decoders[name](string, *optargs, **decoder_kwargs)
  File "/usr/lib/python3.9/json/__init__.py", line 359, in loads
    return cls(**kw).decode(s)
TypeError: __init__() got an unexpected keyword argument 'encoding'

相关信息:中午12:06分设置debug=true运行脚本,双账号配置,另一账号中了蜻蜓FM月卡,日志无此报错,而报错账号在前面无中奖信息

yorks commented 2 years ago

这个好像是 Python3 的 jsonpckle 改动 不用 encoding 参数了。


git diff jsonencode.py 
diff --git a/utils/jsonencode.py b/utils/jsonencode.py
index 8597c00..8591504 100644
--- a/utils/jsonencode.py
+++ b/utils/jsonencode.py
@@ -9,7 +9,7 @@ def dumps(value, indent=4, ensure_ascii=False, max_depth=3):

 def loads(value):
     jsonpickle.set_preferred_backend('json')
-    jsonpickle.set_decoder_options('json', encoding='utf8')
+    jsonpickle.set_decoder_options('json') #, encoding='utf8')
     return jsonpickle.loads(value)