1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Fix python3 raise exception error.

This commit is contained in:
eternnoir 2015-10-02 17:08:05 +08:00
parent 29a42a398b
commit 855ff40070

View File

@ -2,9 +2,11 @@
import threading
import sys
import six
from six import string_types
# Python3 queue support.
try:
import Queue
except ImportError:
@ -66,7 +68,7 @@ class WorkerThread(threading.Thread):
def raise_exceptions(self):
if self.exception_event.is_set():
raise self.exc_info[0], self.exc_info[1], self.exc_info[2]
six.reraise(self.exc_info[0], self.exc_info[1], self.exc_info[2])
def clear_exceptions(self):
self.exception_event.clear()
@ -96,7 +98,7 @@ class ThreadPool:
def raise_exceptions(self):
if self.exception_event.is_set():
raise self.exc_info[0], self.exc_info[1], self.exc_info[2]
six.reraise(self.exc_info[0], self.exc_info[1], self.exc_info[2])
def clear_exceptions(self):
self.exception_event.clear()
@ -129,7 +131,7 @@ class AsyncTask:
if not self.done:
self.thread.join()
if isinstance(self.result, BaseException):
raise self.result[0], self.result[1], self.result[2]
six.reraise(self.result[0], self.result[1], self.result[2])
else:
return self.result