UnicodeEncodeError write error in session_log (when unicode data is read in and then written to the session_log)
See original GitHub issueHi @ktbyers
Not sure why but some or my older scripts are running into UnicodeEncodeError : “‘ascii’ codec can’t encode character ‘\xe3’ in position 45774: ordinal not in range(128)”. Snippet of code below
`deviceinfo = {‘device_type’: ‘cisco_wlc’, ‘ip’: wlcipadd, ‘username’: username, ‘password’: password, ‘banner_timeout’: 16, ‘global_delay_factor’: 4, ‘session_log’:filename}
device = netmiko.ConnectHandler(**deviceinfo)
op = device.send_command_timing(“show ap summary”, use_textfsm=False)`
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Python: Can't write to file - UnicodeEncodeError - Stack Overflow
To write Unicode text to a file, you could use io.open() function: #!/usr/bin/env python from io import open with open('utf8.txt', 'w', ...
Read more >Overcoming frustration: Correctly using unicode in python2
In python, the unicode type stores an abstract sequence of code points. ... but throw an error when you give it a string...
Read more >TT_11195 error in session log when running PowerCenter ...
This error occurs when the data contains extended ASCII or Unicode characters but one or more of the following are not configured:.
Read more >Python JSON Encode Unicode and non-Ascii characters as-is
In this example, we will try to encode the Unicode Data into JSON. This solution is useful when you want to dump Unicode...
Read more >Understanding Python unicode, str, UnicodeEncodeError and ...
Understanding the basics of Python 'unicode' and 'str' type; Deliberately causing UnicodeEncodeError and UnicodeDecodeError and fixing it.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @ktbyers
It seems our jump server was moved to a different data center pushing latency towards some WLC into 180 - 230ms zone. As netmiko has to fetch data over multiple iterations, some characters get malformed and fail to write into session logs on Windows (haven’t tested yet on Linux). This failure to write session log also causes entire driver to crash, terminating connection to WLC/switch. I have disabled session_log on driver level which has fixed the issue for us.
Naah, it clearly looks like a unicode write error:
i.e. there is unicode in the output of what is read back in and we are trying to write that out to the session_log. You probably could modify that behavior such that it writes out unicode (or strips unicode).