Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
c90c90 opened this issue Feb 3, 2022 · 1 comment

Comments

@c90c90
Copy link

c90c90 commented Feb 3, 2022

########################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
Copy link

yorks commented Feb 7, 2022

这个好像是 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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants