Open kussatom opened 5 years ago
So I see in the system version, the locale is UTF-8
, so I'm not entirely sure why you're getting the UnicodeDecodeError
. In the file you're trying to read in, does it declare an encoding at the top? I'm thinking there's a Chinese character in there and it's not being handled correctly.
@xeacott thanks, i use python3.6 it seems that there is no need to declare an encoding at the top,right? though the problem is the encoding
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.
Thank you for updating this issue. It is no longer marked as stale.
Description of Issue
i need to deal with line of file on windows,but failed. it seems the coding problem
Setup
i use the python api and the file.line module: local.cmd(tgt=s,fun='file.line',arg=[filepath],kwarg={'content':contents,'mode':'ensure','before':""})
get error report
The minion function caused an exception: Traceback (most recent call last):\n File "c:\salt\bin\lib\site-packages\salt\minion.py", line 1660, in _thread_return\n return_data = minion_instance.executors[fname](opts, data, func, args, kwargs)\n File "c:\salt\bin\lib\site-packages\salt\executors\direct_call.py", line 12, in execute\n return func(*args, **kwargs)\n File "c:\salt\bin\lib\site-packages\salt\modules\file.py", line 2050, in line\n path_content = salt.utils.data.decodelist(fp.read().splitlines(True))\nUnicodeDecodeError: \'gbk\' codec can\'t decode byte 0x84 in position 586: illegal multibyte sequence\n
Versions Report
Salt Version: Salt: 2019.2.0
Dependency Versions: cffi: 1.12.3 cherrypy: Not Installed dateutil: Not Installed docker-py: Not Installed gitdb: Not Installed gitpython: Not Installed ioflo: Not Installed Jinja2: 2.10.1 libgit2: 0.28.2 libnacl: Not Installed M2Crypto: Not Installed Mako: Not Installed msgpack-pure: Not Installed msgpack-python: 0.6.1 mysql-python: Not Installed pycparser: 2.19 pycrypto: 2.6.1 pycryptodome: Not Installed pygit2: 0.28.2 Python: 3.6.8 (default, Apr 25 2019, 21:02:35) python-gnupg: Not Installed PyYAML: 5.1.2 PyZMQ: 18.0.2 RAET: Not Installed smmap: Not Installed timelib: Not Installed Tornado: 4.5.3 ZMQ: 4.3.1
System Versions: dist: centos 7.6.1810 Core locale: UTF-8 machine: x86_64 release: 3.10.0-957.27.2.el7.x86_64 system: Linux version: CentOS Linux 7.6.1810 Core