asyncssh: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc2 in position 0:
`future: <Task finished coro=<OutputFetcher.task() done, defined at /home/waqas/PycharmProjects/automation_manager/automation_manager/general_automation/commander/output_fetcher.py:49> exception=DisconnectError(‘Disconnect Error: Unicode decode error’,)> Traceback (most recent call last): File “/home/waqas/.virtualenv/automation_manager/lib/python3.6/site-packages/asyncssh/channel.py”, line 296, in _deliver_data data = encdata.decode(self._encoding) UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xc2 in position 0: invalid continuation byte
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File “/home/waqas/PycharmProjects/automation_manager/automation_manager/general_automation/commander/output_fetcher.py”, line 65, in task await out_file.write(await router.send_command(command)) File “/home/waqas/PycharmProjects/automation_manager/automation_manager/general_automation/netdev/vendors/base.py”, line 208, in send_command output = await self._read_until_prompt_or_pattern(pattern, re_flags) File “/home/waqas/PycharmProjects/automation_manager/automation_manager/general_automation/netdev/vendors/base.py”, line 264, in _read_until_prompt_or_pattern output += await asyncio.wait_for(fut, self._timeout) File “/usr/lib/python3.6/asyncio/tasks.py”, line 339, in wait_for return (yield from fut) File “/usr/lib/python3.6/asyncio/coroutines.py”, line 215, in coro res = yield from res File “/home/waqas/.virtualenv/automation_manager/lib/python3.6/site-packages/asyncssh/stream.py”, line 444, in read raise recv_buf.pop(0) File “/home/waqas/.virtualenv/automation_manager/lib/python3.6/site-packages/asyncssh/connection.py”, line 504, in data_received while self._inpbuf and self._recv_handler(): File “/home/waqas/.virtualenv/automation_manager/lib/python3.6/site-packages/asyncssh/connection.py”, line 724, in _recv_packet processed = handler.process_packet(pkttype, seq, packet) File “/home/waqas/.virtualenv/automation_manager/lib/python3.6/site-packages/asyncssh/packet.py”, line 207, in process_packet self._packet_handlers[pkttype](self, pkttype, pktid, packet) File “/home/waqas/.virtualenv/automation_manager/lib/python3.6/site-packages/asyncssh/channel.py”, line 521, in _process_data self._accept_data(data) File “/home/waqas/.virtualenv/automation_manager/lib/python3.6/site-packages/asyncssh/channel.py”, line 351, in _accept_data self._deliver_data(data, datatype) File “/home/waqas/.virtualenv/automation_manager/lib/python3.6/site-packages/asyncssh/channel.py”, line 308, in _deliver_data ‘Unicode decode error’) asyncssh.misc.DisconnectError: Disconnect Error: Unicode decode error `
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 23 (11 by maintainers)
Ok - support for an “errors” argument is now ready to test in the “develop” branch (see commit 39ab119). Methods such as SSHClientConnection’s create_session(), create_connection(), create_unix_connection(), create_server(), and create_unix_server() now support this, along with SSHServerConnection’s create_connection() and create_unix_connection(). The equivalent functions which return stream or process objects also now support this.
Callers to create_server_channel(), create_tcp_channel(), and create_unix_channel() can also pass in an “errors” argument when customizing other channel parameters.
Support for controlling Unicode error handling is also available via the “session_errors” argument in the top-level AsyncSSH create_server() call (to be used along with “session_encoding”), and whatever is set there will apply to newly created server sessions on that server.
When working with SSH process objects, whatever Unicode error handler is set is also automatically used as the error handler for any I/O redirection which is performed on that process.
Finally, the get_comment() and set_comment() functions that operate on private/public keys and certificates have been updated to accept an “errors” argument as well.