Commit 9c8ec172 authored by Denis Bilenko's avatar Denis Bilenko

Merge pull request #358 from fantix/exc_clear

Ignore sys.exc_clear() for PY3.
parents 2960692c 7483cef1
...@@ -30,6 +30,7 @@ from code import InteractiveConsole ...@@ -30,6 +30,7 @@ from code import InteractiveConsole
from gevent import socket from gevent import socket
from gevent.greenlet import Greenlet from gevent.greenlet import Greenlet
from gevent.hub import PY3
from gevent.server import StreamServer from gevent.server import StreamServer
__all__ = ['BackdoorServer'] __all__ = ['BackdoorServer']
...@@ -79,6 +80,7 @@ class SocketConsole(Greenlet): ...@@ -79,6 +80,7 @@ class SocketConsole(Greenlet):
console.locals["builtins"] = builtins console.locals["builtins"] = builtins
console.interact(banner=self.banner) console.interact(banner=self.banner)
except SystemExit: # raised by quit() except SystemExit: # raised by quit()
if not PY3:
sys.exc_clear() sys.exc_clear()
finally: finally:
self.switch_out() self.switch_out()
......
...@@ -8,7 +8,7 @@ from __future__ import absolute_import ...@@ -8,7 +8,7 @@ from __future__ import absolute_import
import os import os
import sys import sys
from gevent.hub import get_hub, reinit from gevent.hub import get_hub, reinit, PY3
import errno import errno
EAGAIN = getattr(errno, 'EAGAIN', 11) EAGAIN = getattr(errno, 'EAGAIN', 11)
...@@ -52,6 +52,7 @@ if fcntl: ...@@ -52,6 +52,7 @@ if fcntl:
except OSError as e: except OSError as e:
if e.errno not in ignored_errors: if e.errno not in ignored_errors:
raise raise
if not PY3:
sys.exc_clear() sys.exc_clear()
if hub is None: if hub is None:
hub = get_hub() hub = get_hub()
...@@ -71,6 +72,7 @@ if fcntl: ...@@ -71,6 +72,7 @@ if fcntl:
except OSError as e: except OSError as e:
if e.errno not in ignored_errors: if e.errno not in ignored_errors:
raise raise
if not PY3:
sys.exc_clear() sys.exc_clear()
if hub is None: if hub is None:
hub = get_hub() hub = get_hub()
......
...@@ -13,6 +13,7 @@ from gevent import socket ...@@ -13,6 +13,7 @@ from gevent import socket
import gevent import gevent
from gevent.server import StreamServer from gevent.server import StreamServer
from gevent.hub import GreenletExit from gevent.hub import GreenletExit
from gevent.hub import PY3
__all__ = ['WSGIHandler', 'WSGIServer'] __all__ = ['WSGIHandler', 'WSGIServer']
...@@ -321,6 +322,7 @@ class WSGIHandler(object): ...@@ -321,6 +322,7 @@ class WSGIHandler(object):
except socket.error as ex: except socket.error as ex:
# Broken pipe, connection reset by peer # Broken pipe, connection reset by peer
if ex.args[0] in (errno.EPIPE, errno.ECONNRESET): if ex.args[0] in (errno.EPIPE, errno.ECONNRESET):
if not PY3:
sys.exc_clear() sys.exc_clear()
return return
else: else:
......
import gevent import gevent
import sys import sys
import greentest import greentest
import six
sys.exc_clear() if not six.PY3:
sys.exc_clear()
class ExpectedError(Exception): class ExpectedError(Exception):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment