Exception while printing an exception trough logging.exception() - python

I have a try block which raises an exception every time, in except block I used logging.exception('some message') to log error. But while handling the above exception another exception occurred.
try:
raise Exception('')
#some key error exception raised.
except Exception as e:
abortMsg = "some error"
logging.exception(abortMsg)
return
I'am pretty sure that the error is caused by the stack trace of the exception,Any operation related to it like printing it , or using traceback.print_exc() raises exceptions recursively
The error log when i used traceback.print_exc()
Error log:
--- Logging error ---
Unhandled exception in thread started by <bound method Thread._bootstrap of <Thread(Thread-5,
started 139762597885696)>>
Traceback (most recent call last):
File "somefile.py", line 570, in postProcess
reporter.write_report()
File "someotherfile.py", line 115, in write_report
File "someotherfile.py", line 295, in _addSectionResult
File "someotherfile.py", line 315, in _addCheckSummary
KeyError: 'message_zero'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/somefile.py", line 310, in execute
self.postProcess()
File "/somefile.py", line 580, in postProcess
s = str(traceback.print_exc())
File "/usr/lib/python3.5/traceback.py", line 159, in print_exc
print_exception(*sys.exc_info(), limit=limit, file=file, chain=chain)
File "/usr/lib/python3.5/traceback.py", line 100, in print_exception
type(value), value, tb, limit=limit).format(chain=chain):
File "/usr/lib/python3.5/traceback.py", line 474, in __init__
capture_locals=capture_locals)
File "/usr/lib/python3.5/traceback.py", line 358, in extract
f.line
File "/usr/lib/python3.5/traceback.py", line 282, in line
self._line = linecache.getline(self.filename, self.lineno).strip()
File "/usr/lib/python3.5/linecache.py", line 16, in getline
lines = getlines(filename, module_globals)
File "/usr/lib/python3.5/linecache.py", line 47, in getlines
return updatecache(filename, module_globals)
File "/usr/lib/python3.5/linecache.py", line 137, in updatecache
lines = fp.readlines()
File "/usr/lib/python3.5/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa3 in position 4: invalid start byte'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.5/logging/__init__.py", line 980, in emit
msg = self.format(record)
File "/usr/lib/python3.5/logging/__init__.py", line 830, in format
return fmt.format(record)
File "/usr/lib/python3.5/logging/__init__.py", line 575, in format
record.exc_text = self.formatException(record.exc_info)
File "/usr/lib/python3.5/logging/__init__.py", line 525, in formatException
traceback.print_exception(ei[0], ei[1], tb, None, sio)
File "/usr/lib/python3.5/traceback.py", line 100, in print_exception
type(value), value, tb, limit=limit).format(chain=chain):
File "/usr/lib/python3.5/traceback.py", line 487, in __init__
self._load_lines()
File "/usr/lib/python3.5/traceback.py", line 500, in _load_lines
self.__context__._load_lines()
File "/usr/lib/python3.5/traceback.py", line 498, in _load_lines
frame.line
File "/usr/lib/python3.5/traceback.py", line 282, in line
self._line = linecache.getline(self.filename, self.lineno).strip()
File "/usr/lib/python3.5/linecache.py", line 16, in getline
lines = getlines(filename, module_globals)
File "/usr/lib/python3.5/linecache.py", line 47, in getlines
return updatecache(filename, module_globals)
File "/usr/lib/python3.5/linecache.py", line 137, in updatecache
lines = fp.readlines()
File "/usr/lib/python3.5/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa3 in position 4: invalid start byte
Is there any way to see and analyse stack trace which is causing error?
PS : I'm using this inside a docker. While i run this file locally no recursive exception is raised.
EDIT : Any exception raised from anywhere from the code is causing recursive exception(unicode decode error)

Related

How to trap this nested httpx exception?

I'm trapping thus:
with httpx.Client(**sessions[scraperIndex]) as client:
try:
response = client.get(...)
except TimeoutError as e:
print('does not hit')
except Exception as e:
print(f'⛔️ Unexpected exception: {e}')
print_exc() # hits!
However I'm getting the below crashdump.
Pulling out key lines:
TimeoutError: The read operation timed out
During handling of the above exception, another exception occurred:
httpcore.ReadTimeout: The read operation timed out
The above exception was the direct cause of the following exception:
httpx.ReadTimeout: The read operation timed out
Why isn't my TimeoutError catching this?
And what's the correct catch? Can someone give a logic for deducing it?
CrashDump:
⛔️ Unexpected exception: The read operation timed out
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/httpcore/_exceptions.py", line 8, in map_exceptions
yield
File "/usr/local/lib/python3.10/dist-packages/httpcore/backends/sync.py", line 26, in read
return self._sock.recv(max_bytes)
File "/usr/lib/python3.10/ssl.py", line 1258, in recv
return self.read(buflen)
File "/usr/lib/python3.10/ssl.py", line 1131, in read
return self._sslobj.read(len)
TimeoutError: The read operation timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions
yield
File "/usr/local/lib/python3.10/dist-packages/httpx/_transports/default.py", line 218, in handle_request
resp = self._pool.handle_request(req)
File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/connection_pool.py", line 253, in handle_request
raise exc
File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/connection_pool.py", line 237, in handle_request
response = connection.handle_request(request)
File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/connection.py", line 90, in handle_request
return self._connection.handle_request(request)
File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/http11.py", line 105, in handle_request
raise exc
File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/http11.py", line 84, in handle_request
) = self._receive_response_headers(**kwargs)
File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/http11.py", line 148, in _receive_response_headers
event = self._receive_event(timeout=timeout)
File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/http11.py", line 177, in _receive_event
data = self._network_stream.read(
File "/usr/local/lib/python3.10/dist-packages/httpcore/backends/sync.py", line 24, in read
with map_exceptions(exc_map):
File "/usr/lib/python3.10/contextlib.py", line 153, in __exit__
self.gen.throw(typ, value, traceback)
File "/usr/local/lib/python3.10/dist-packages/httpcore/_exceptions.py", line 12, in map_exceptions
raise to_exc(exc)
httpcore.ReadTimeout: The read operation timed out
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/root/scraper-pi/Scrape.py", line 148, in main
cursor, _nScraped = scrape(client, cursor)
File "/root/scraper-pi/Scrape.py", line 79, in scrape
response = client.get(
File "/usr/local/lib/python3.10/dist-packages/httpx/_client.py", line 1039, in get
return self.request(
File "/usr/local/lib/python3.10/dist-packages/httpx/_client.py", line 815, in request
return self.send(request, auth=auth, follow_redirects=follow_redirects)
File "/usr/local/lib/python3.10/dist-packages/httpx/_client.py", line 902, in send
response = self._send_handling_auth(
File "/usr/local/lib/python3.10/dist-packages/httpx/_client.py", line 930, in _send_handling_auth
response = self._send_handling_redirects(
File "/usr/local/lib/python3.10/dist-packages/httpx/_client.py", line 967, in _send_handling_redirects
response = self._send_single_request(request)
File "/usr/local/lib/python3.10/dist-packages/httpx/_client.py", line 1003, in _send_single_request
response = transport.handle_request(request)
File "/usr/local/lib/python3.10/dist-packages/httpx/_transports/default.py", line 217, in handle_request
with map_httpcore_exceptions():
File "/usr/lib/python3.10/contextlib.py", line 153, in __exit__
self.gen.throw(typ, value, traceback)
File "/usr/local/lib/python3.10/dist-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ReadTimeout: The read operation timed out
The base class for all httpx timeout errors is not the built-in TimeoutError (presumably because that would also make timeouts OSErrors, which doesn't sound correct), but httpx.TimeoutException.
import httpx
with httpx.Client() as client:
try:
response = client.get("http://httpbin.org/get", timeout=0.001)
except httpx.TimeoutException as e:
print('gottem')
prints gottem just fine.

Keep Running a tweepy stream for a long time

I'm running a python script that is supposed to listen tweets with a specific '#' (and then execute some code).
My code is almost running 100% correctly but I still have an issue: my program stops running at random time for "no reason".
Here is the error:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/http/client.py", line 551, in _get_chunk_left
chunk_left = self._read_next_chunk_size()
File "/usr/local/lib/python3.8/http/client.py", line 518, in _read_next_chunk_size
return int(line, 16)
ValueError: invalid literal for int() with base 16: b''
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/http/client.py", line 583, in _readinto_chunked
chunk_left = self._get_chunk_left()
File "/usr/local/lib/python3.8/http/client.py", line 553, in _get_chunk_left
raise IncompleteRead(b'')
http.client.IncompleteRead: IncompleteRead(0 bytes read)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/urllib3/response.py", line 436, in _error_catcher
yield
File "/usr/local/lib/python3.8/site-packages/urllib3/response.py", line 518, in read
data = self._fp.read(amt) if not fp_closed else b""
File "/usr/local/lib/python3.8/http/client.py", line 454, in read
n = self.readinto(b)
File "/usr/local/lib/python3.8/http/client.py", line 488, in readinto
return self._readinto_chunked(b)
File "/usr/local/lib/python3.8/http/client.py", line 599, in _readinto_chunked
raise IncompleteRead(bytes(b[0:total_bytes]))
http.client.IncompleteRead: IncompleteRead(292 bytes read)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 133, in <module>
myStream.filter(track=['#DownDropship'])
File "/usr/local/lib/python3.8/site-packages/tweepy/streaming.py", line 474, in filter
self._start(is_async)
File "/usr/local/lib/python3.8/site-packages/tweepy/streaming.py", line 389, in _start
self._run()
File "/usr/local/lib/python3.8/site-packages/tweepy/streaming.py", line 320, in _run
six.reraise(*exc_info)
File "/usr/local/lib/python3.8/site-packages/six.py", line 703, in reraise
raise value
File "/usr/local/lib/python3.8/site-packages/tweepy/streaming.py", line 289, in _run
self._read_loop(resp)
File "/usr/local/lib/python3.8/site-packages/tweepy/streaming.py", line 339, in _read_loop
line = buf.read_line()
File "/usr/local/lib/python3.8/site-packages/tweepy/streaming.py", line 200, in read_line
self._buffer += self._stream.read(self._chunk_size)
File "/usr/local/lib/python3.8/site-packages/urllib3/response.py", line 540, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "/usr/local/lib/python3.8/contextlib.py", line 131, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/local/lib/python3.8/site-packages/urllib3/response.py", line 454, in _error_catcher
raise ProtocolError("Connection broken: %r" % e, e)
urllib3.exceptions.ProtocolError: ('Connection broken: IncompleteRead(292 bytes read)', IncompleteRead(292 bytes read))
Here is a piece of my code:
from tweepy import StreamListener
from retrying import retry
import tweepy
#retry
class MyStreamListener(StreamListener):
#retry
def on_status(self, status):
do something ...
except Exception as e:
pass
myStreamListener = MyStreamListener()
myStream = tweepy.Stream(auth=twitter_handler.api.auth, listener=myStreamListener)
myStream.filter(track=['#Something'])
I found these "#retry" here but apparently, it doesn't work properly.
Thanks for your help

sending mail with attachment but the attachment is not send only the body is sent

I'm sending a mail with pdf attached in my application but at the receiver end can receive only the body not the attachment
This is the error I received while running the script but the mail is sent
Traceback (most recent call last):
File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 332, in send_headers
self.send_preamble()
File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 255, in send_preamble
('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\socketserver.py", line 799, in write
self._sock.sendall(b)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 141, in run
self.handle_error()
File "C:\Result Creater\virtual\lib\site-packages\django\core\servers\basehttp.py", line 116, in handle_error
super().handle_error()
File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 368, in handle_error
self.finish_response()
File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 344, in client_is_modern
return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
TypeError: 'NoneType' object is not subscriptable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\socketserver.py", line 720, in __init__
self.handle()
File "C:\Result Creater\virtual\lib\site-packages\django\core\servers\basehttp.py", line 171, in handle
self.handle_one_request()
File "C:\Result Creater\virtual\lib\site-packages\django\core\servers\basehttp.py", line 194, in handle_one_request
handler.run(self.server.get_app())
File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 144, in run
self.close()
File "C:\Result Creater\virtual\lib\site-packages\django\core\servers\basehttp.py", line 111, in close
super().close()
File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\wsgiref\simple_server.py", line 35, in close
self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
My send email function-
def send_email(request):
subject='Mark Sheet'
message='You requested for your Marksheet'
email_from=settings.EMAIL_HOST_USER
recipient_list=[request.user.email]
email=EmailMessage(subject,message,email_from,recipient_list,
headers={'Reply- To':settings.EMAIL_HOST_USER})
file=str(request.user)+'.pdf'
email.attach_file=(f"/store/{file}")
email.send()
return redirect('home')
My Pdf class for creating pdf
class Pdf(View):
def get(self,request):
marks=Marks.objects.filter(user_name=request.user).first()
today=timezone.now()
params={
'today':today,
'marks':marks,
'request':request
}
file=Render.render_to_file('user/pdf.html',params)
return redirect('send_email')
You have bad syntax here:
email.attach_file=(f"/store/{file}")
attach_file() is a method, and you're assigning to it with = which means the method gets replaced on the object instead of being called. Change it to:
email.attach_file(f"/store/{file}")

VIM8 & flake8 doesn't work when there are chinese words in it

Everything went well when all words in my file are in English, but when I use codes like "print("你好")", or even use a comment like "# 你好", then flake8 stopped working, and only display "an exception was thrown. See ALEDetail" in the first line.[I use w0rp/ale as plugin in vim80]
If I enter :ALEDetail in the vim, the information looks like below:
Traceback (most recent call last):
File "d:\programmingtool\python\python35\lib\site-packages\flake8\utils.py", line 82, in _stdin_get_value_py3
return io.StringIO(stdin_value.decode(coding))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 92: invalid start byte
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "d:\programmingtool\python\python35\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "d:\programmingtool\python\python35\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\ProgrammingTool\python\python35\Scripts\flake8.exe\__main__.py", line 9, in <module>
File "d:\programmingtool\python\python35\lib\site-packages\flake8\main\cli.py", line 16, in main
app.run(argv)
File "d:\programmingtool\python\python35\lib\site-packages\flake8\main\application.py", line 396, in run
self._run(argv)
File "d:\programmingtool\python\python35\lib\site-packages\flake8\main\application.py", line 384, in _run
self.run_checks()
File "d:\programmingtool\python\python35\lib\site-packages\flake8\main\application.py", line 309, in run_checks
self.file_checker_manager.start(files)
File "d:\programmingtool\python\python35\lib\site-packages\flake8\checker.py", line 342, in start
self.make_checkers(paths)
File "d:\programmingtool\python\python35\lib\site-packages\flake8\checker.py", line 246, in make_checkers
checker for checker in checkers if checker.should_process
File "d:\programmingtool\python\python35\lib\site-packages\flake8\checker.py", line 246, in <listcomp>
checker for checker in checkers if checker.should_process
File "d:\programmingtool\python\python35\lib\site-packages\flake8\checker.py", line 243, in <genexpr>
if should_create_file_checker(filename, argument)
File "d:\programmingtool\python\python35\lib\site-packages\flake8\checker.py", line 378, in __init__
self.processor = self._make_processor()
File "d:\programmingtool\python\python35\lib\site-packages\flake8\checker.py", line 392, in _make_processor
return processor.FileProcessor(self.filename, self.options)
File "d:\programmingtool\python\python35\lib\site-packages\flake8\processor.py", line 61, in __init__
self.lines = self.read_lines()
File "d:\programmingtool\python\python35\lib\site-packages\flake8\processor.py", line 297, in read_lines
lines = self.read_lines_from_stdin()
File "d:\programmingtool\python\python35\lib\site-packages\flake8\processor.py", line 333, in read_lines_from_stdin
return utils.stdin_get_value().splitlines(True)
File "d:\programmingtool\python\python35\lib\site-packages\flake8\utils.py", line 95, in stdin_get_value
stdin_value = _stdin_get_value_py3()
File "d:\programmingtool\python\python35\lib\site-packages\flake8\utils.py", line 84, in _stdin_get_value_py3
return io.StringIO(stdin_value.decode('utf-8'))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 92: invalid start byte

€ sign - xlsxwriter error

I'm trying to get some data from one web page and write these data into xlsx file. Everything seems good but the Encoding error probably raises if it tries to write it into xlsx file during CLOSING the file.
ERROR:
Traceback (most recent call last):
File "C:/Users/Milano/PycharmProjects/distrelec/crawler.py", line 429, in <module>
temp_file_to_xlsx()
File "C:/Users/Milano/PycharmProjects/distrelec/crawler.py", line 119, in temp_file_to_xlsx
wb.close()
File "C:\Python27\lib\site-packages\xlsxwriter\workbook.py", line 295, in close
self._store_workbook()
File "C:\Python27\lib\site-packages\xlsxwriter\workbook.py", line 518, in _store_workbook
xml_files = packager._create_package()
File "C:\Python27\lib\site-packages\xlsxwriter\packager.py", line 134, in _create_package
self._write_workbook_file()
File "C:\Python27\lib\site-packages\xlsxwriter\packager.py", line 174, in _write_workbook_file
workbook._assemble_xml_file()
File "C:\Python27\lib\site-packages\xlsxwriter\workbook.py", line 464, in _assemble_xml_file
self._write_sheets()
File "C:\Python27\lib\site-packages\xlsxwriter\workbook.py", line 1455, in _write_sheets
self._write_sheet(worksheet.name, id_num, worksheet.hidden)
File "C:\Python27\lib\site-packages\xlsxwriter\workbook.py", line 1472, in _write_sheet
self._xml_empty_tag('sheet', attributes)
File "C:\Python27\lib\site-packages\xlsxwriter\xmlwriter.py", line 80, in _xml_empty_tag
self.fh.write("<%s/>" % tag)
File "C:\Python27\lib\codecs.py", line 694, in write
return self.writer.write(data)
File "C:\Python27\lib\codecs.py", line 357, in write
data, consumed = self.encode(object, self.errors)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 23: ordinal not in range(128)
To find out where is the problem I've edited codecs module:
def write(self, object):
""" Writes the object's contents encoded to self.stream.
"""
try:
data, consumed = self.encode(object, self.errors)
self.stream.write(data)
except:
print object
print repr(object)
raise Exception
The output is:
<sheet name="Android PC–APC" sheetId="42" r:id="rId42"/>
'<sheet name="Android PC\xe2\x80\x93APC" sheetId="42" r:id="rId42"/>'
temp_file_to_xlsx()
File "C:/Users/Milano/PycharmProjects/distrelec/crawler.py", line 119, in temp_file_to_xlsx
wb.close()
File "C:\Python27\lib\site-packages\xlsxwriter\workbook.py", line 295, in close
self._store_workbook()
File "C:\Python27\lib\site-packages\xlsxwriter\workbook.py", line 518, in _store_workbook
xml_files = packager._create_package()
File "C:\Python27\lib\site-packages\xlsxwriter\packager.py", line 134, in _create_package
self._write_workbook_file()
File "C:\Python27\lib\site-packages\xlsxwriter\packager.py", line 174, in _write_workbook_file
workbook._assemble_xml_file()
File "C:\Python27\lib\site-packages\xlsxwriter\workbook.py", line 464, in _assemble_xml_file
self._write_sheets()
File "C:\Python27\lib\site-packages\xlsxwriter\workbook.py", line 1455, in _write_sheets
self._write_sheet(worksheet.name, id_num, worksheet.hidden)
File "C:\Python27\lib\site-packages\xlsxwriter\workbook.py", line 1472, in _write_sheet
self._xml_empty_tag('sheet', attributes)
File "C:\Python27\lib\site-packages\xlsxwriter\xmlwriter.py", line 80, in _xml_empty_tag
self.fh.write("<%s/>" % tag)
File "C:\Python27\lib\codecs.py", line 699, in write
return self.writer.write(data)
File "C:\Python27\lib\codecs.py", line 363, in write
raise Exception
Exception
What should I do with that please?
You have to decode your input data with the correct encoding, which seems to be 'utf-8'.
You may want to look at this:
Example: Simple Unicode with Python 2

Categories

Resources