agronholm / apscheduler

Task scheduling library for Python
MIT License
6.31k stars 713 forks source link

运行时会报UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte #976

Closed liuHongyang0207 closed 1 month ago

liuHongyang0207 commented 1 month ago

Things to check first

Version

3.10.4

What happened?

每次执行时都会报这个错误: easy audit had a pre_save exception. Traceback (most recent call last): File "C:\Users\liuhongyang03\PycharmProjects\django-base\.venv\Lib\site-packages\django\utils\encoding.py", line 71, in force_str s = str(s, encoding, errors) ^^^^^^^^^^^^^^^^^^^^^^^^ UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\liuhongyang03\PycharmProjects\django-base\.venv\Lib\site-packages\easyaudit\signals\model_signals.py", line 103, in pre_save delta = model_delta(old_model, instance) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\liuhongyang03\PycharmProjects\django-base\.venv\Lib\site-packages\easyaudit\utils.py", line 53, in model_delta old_value = get_field_value(old_model, field) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\liuhongyang03\PycharmProjects\django-base\.venv\Lib\site-packages\easyaudit\utils.py", line 31, in get_field_value value = smart_str(getattr(obj, field.name, None)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\liuhongyang03\PycharmProjects\django-base\.venv\Lib\site-packages\django\utils\encoding.py", line 34, in smart_str return force_str(s, encoding, strings_only, errors) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\liuhongyang03\PycharmProjects\django-base\.venv\Lib\site-packages\django\utils\encoding.py", line 75, in force_str raise DjangoUnicodeDecodeError(s, *e.args) django.utils.encoding.DjangoUnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte. You passed in b'\x80\x05\x95#\x04\x00\x00\x00\x00\x00\x00}\x94(\x8c\x07version\x94K\x01\x8c\x02id\x94\x8c$3be96141-8af5-11ef-beb7-0c9a3c2b86f7\x94\x8c\x04func\x94\x8c&apps.system.jobs.tasks:database_backup\x94\x8c\x07trigger\x94\x8c\x19apscheduler.triggers.cron\x94\x8c\x0bCronTrigger\x94\x93\x94)\x81\x94}\x94(h\x01K\x02\x8c\x08timezone\x94\x8c\x08builtins\x94\x8c\x07getattr\x94\x93\x94\x8c\x08zoneinfo\x94\x8c\x08ZoneInfo\x94\x93\x94\x8c\t_unpickle\x94\x86\x94R\x94\x8c\rAsia/Shanghai\x94K\x01\x86\x94R\x94\x8c\nstart_date\x94N\x8c\x08end_date\x94N\x8c\x06fields\x94]\x94(\x8c apscheduler.triggers.cron.fields\x94\x8c\tBaseField\x94\x93\x94)\x81\x94}\x94(\x8c\x04name\x94\x8c\x04year\x94\x8c\nis_default\x94\x88\x8c\x0bexpressions\x94]\x94\x8c%apscheduler.triggers.cron.expressions\x94\x8c\rAllExpression\x94\x93\x94)\x81\x94}\x94\x8c\x04step\x94Nsbaubh\x1d\x8c\nMonthField\x94\x93\x94)\x81\x94}\x94(h"\x8c\x05month\x94h$\x89h%]\x94h))\x81\x94}\x94h,Nsbaubh\x1d\x8c\x0fDayOfMonthField\x94\x93\x94)\x81\x94}\x94(h"\x8c\x03day\x94h$\x89h%]\x94h))\x81\x94}\x94h,Nsbaubh\x1d\x8c\tWeekField\x94\x93\x94)\x81\x94}\x94(h"\x8c\x04week\x94h$\x88h%]\x94h))\x81\x94}\x94h,Nsbaubh\x1d\x8c\x0eDayOfWeekField\x94\x93\x94)\x81\x94}\x94(h"\x8c\x0bday_of_week\x94h$\x89h%]\x94h))\x81\x94}\x94h,Nsbaubh\x1f)\x81\x94}\x94(h"\x8c\x04hour\x94h$\x89h%]\x94h))\x81\x94}\x94h,Nsbaubh\x1f)\x81\x94}\x94(h"\x8c\x06minute\x94h$\x89h%]\x94h))\x81\x94}\x94h,Nsbaubh\x1f)\x81\x94}\x94(h"\x8c\x06second\x94h$\x88h%]\x94h\'\x8c\x0fRangeExpression\x94\x93\x94)\x81\x94}\x94(h,N\x8c\x05first\x94K\x00\x8c\x04last\x94K\x00ubaube\x8c\x06jitter\x94Nub\x8c\x08executor\x94\x8c\x07default\x94\x8c\x04args\x94)\x8c\x06kwargs\x94}\x94h"\x8c\x0fdatabase_backup\x94\x8c\x12misfire_grace_time\x94K\n\x8c\x08coalesce\x94\x88\x8c\rmax_instances\x94K\x01\x8c\rnext_run_time\x94\x8c\x08datetime\x94\x8c\x08datetime\x94\x93\x94C\n\x07\xe8\n\x10\x0f\r\x00\x00\x00\x00\x94h\x18\x86\x94R\x94u.' (<class 'bytes'>)

How can we reproduce the bug?

每次定时任务执行时,目前发现的是job_state 导致的,执行到这里时就会报错: value = smart_str(getattr(obj, field.name, None))

image

agronholm commented 1 month ago

Why are you reporting something like this against APScheduler when the traceback clearly shows it didn't happen in APScheduler code? Also, how am I supposed to reproduce this with those instructions? Last of all, speak English. I can't read Chinese (any variant of it).