Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
c093b89e
Commit
c093b89e
authored
Dec 01, 2013
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use as-syntax in except clauses #38
parent
abe61a16
Changes
20
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
29 additions
and
29 deletions
+29
-29
examples/portforwarder.py
examples/portforwarder.py
+1
-1
gevent/core.ppyx
gevent/core.ppyx
+1
-1
gevent/hub.py
gevent/hub.py
+1
-1
gevent/os.py
gevent/os.py
+2
-2
gevent/pywsgi.py
gevent/pywsgi.py
+1
-1
gevent/server.py
gevent/server.py
+2
-2
gevent/ssl.py
gevent/ssl.py
+1
-1
gevent/subprocess.py
gevent/subprocess.py
+2
-2
gevent/timeout.py
gevent/timeout.py
+1
-1
gevent/util.py
gevent/util.py
+1
-1
greentest/bench_sleep0.py
greentest/bench_sleep0.py
+1
-1
greentest/test__pywsgi.py
greentest/test__pywsgi.py
+3
-3
greentest/test__socket_dns.py
greentest/test__socket_dns.py
+1
-1
greentest/test__socket_ex.py
greentest/test__socket_ex.py
+1
-1
greentest/test__subprocess.py
greentest/test__subprocess.py
+2
-2
greentest/test_ares_timeout.py
greentest/test_ares_timeout.py
+2
-2
greentest/test_close_backend_fd.py
greentest/test_close_backend_fd.py
+1
-1
greentest/util.py
greentest/util.py
+3
-3
greentest/xtest__benchmarks.py
greentest/xtest__benchmarks.py
+1
-1
util/set_version.py
util/set_version.py
+1
-1
No files found.
examples/portforwarder.py
View file @
c093b89e
...
...
@@ -28,7 +28,7 @@ class PortForwarder(StreamServer):
log
(
'%s:%s accepted'
,
*
address
[:
2
])
try
:
dest
=
create_connection
(
self
.
dest
)
except
IOError
,
ex
:
except
IOError
as
ex
:
log
(
'%s:%s failed to connect to %s:%s: %s'
,
address
[
0
],
address
[
1
],
self
.
dest
[
0
],
self
.
dest
[
1
],
ex
)
return
gevent
.
spawn
(
forward
,
source
,
dest
)
...
...
gevent/core.ppyx
View file @
c093b89e
...
...
@@ -161,7 +161,7 @@ cpdef unsigned int _flags_to_int(object flags) except? -1:
value = value.strip().lower()
if value:
result |= _flags_str2int[value]
except KeyError
,
ex:
except KeyError
as
ex:
raise ValueError('Invalid backend or flag: %s\nPossible values: %s' % (ex, ', '.join(sorted(_flags_str2int.keys()))))
return result
...
...
gevent/hub.py
View file @
c093b89e
...
...
@@ -279,7 +279,7 @@ class Hub(greenlet):
else
:
try
:
info
=
self
.
loop
.
_format
()
except
Exception
,
ex
:
except
Exception
as
ex
:
info
=
str
(
ex
)
or
repr
(
ex
)
or
'error'
result
=
'<%s at 0x%x %s'
%
(
self
.
__class__
.
__name__
,
id
(
self
),
info
)
if
self
.
_resolver
is
not
None
:
...
...
gevent/os.py
View file @
c093b89e
...
...
@@ -48,7 +48,7 @@ if fcntl:
while
True
:
try
:
return
_read
(
fd
,
n
)
except
OSError
,
e
:
except
OSError
as
e
:
if
e
.
errno
not
in
ignored_errors
:
raise
sys
.
exc_clear
()
...
...
@@ -67,7 +67,7 @@ if fcntl:
while
True
:
try
:
return
_write
(
fd
,
buf
)
except
OSError
,
e
:
except
OSError
as
e
:
if
e
.
errno
not
in
ignored_errors
:
raise
sys
.
exc_clear
()
...
...
gevent/pywsgi.py
View file @
c093b89e
...
...
@@ -353,7 +353,7 @@ class WSGIHandler(object):
def
_sendall
(
self
,
data
):
try
:
self
.
socket
.
sendall
(
data
)
except
socket
.
error
,
ex
:
except
socket
.
error
as
ex
:
self
.
status
=
'socket error: %s'
%
ex
if
self
.
code
>
0
:
self
.
code
=
-
self
.
code
...
...
gevent/server.py
View file @
c093b89e
...
...
@@ -91,7 +91,7 @@ class StreamServer(BaseServer):
def
do_read
(
self
):
try
:
client_socket
,
address
=
self
.
socket
.
accept
()
except
_socket
.
error
,
err
:
except
_socket
.
error
as
err
:
if
err
[
0
]
==
EWOULDBLOCK
:
return
raise
...
...
@@ -130,7 +130,7 @@ class DatagramServer(BaseServer):
def
do_read
(
self
):
try
:
data
,
address
=
self
.
_socket
.
recvfrom
(
8192
)
except
_socket
.
error
,
err
:
except
_socket
.
error
as
err
:
if
err
[
0
]
==
EWOULDBLOCK
:
return
raise
...
...
gevent/ssl.py
View file @
c093b89e
...
...
@@ -70,7 +70,7 @@ class SSLSocket(socket):
# see if it's connected
try
:
socket
.
getpeername
(
self
)
except
socket_error
,
e
:
except
socket_error
as
e
:
if
e
[
0
]
!=
errno
.
ENOTCONN
:
raise
# no, no connection yet
...
...
gevent/subprocess.py
View file @
c093b89e
...
...
@@ -443,7 +443,7 @@ class Popen(object):
env
,
cwd
,
startupinfo
)
except
pywintypes
.
error
,
e
:
except
pywintypes
.
error
as
e
:
# Translate pywintypes.error to WindowsError, which is
# a subclass of OSError. FIXME: We should really
# translate errno using _sys_errlist (or similar), but
...
...
@@ -799,7 +799,7 @@ def write_and_close(fobj, data):
try
:
if
data
:
fobj
.
write
(
data
)
except
(
OSError
,
IOError
)
,
ex
:
except
(
OSError
,
IOError
)
as
ex
:
if
ex
.
errno
!=
errno
.
EPIPE
and
ex
.
errno
!=
errno
.
EINVAL
:
raise
finally
:
...
...
gevent/timeout.py
View file @
c093b89e
...
...
@@ -68,7 +68,7 @@ class Timeout(BaseException):
timeout.start()
try:
...
except Timeout
,
t:
except Timeout
as
t:
if t is not timeout:
raise # not my timeout
"""
...
...
gevent/util.py
View file @
c093b89e
...
...
@@ -14,7 +14,7 @@ class wrap_errors(object):
def wrapped_func(*args, **kwargs):
try:
return func(*args, **kwargs)
except (A, B, C)
,
ex:
except (A, B, C)
as
ex:
return ex
:class:`wrap_errors` provides a shortcut to write that in one line::
...
...
greentest/bench_sleep0.py
View file @
c093b89e
...
...
@@ -31,7 +31,7 @@ def bench_gevent(arg=0):
def
bench_eventlet
(
arg
):
try
:
import
eventlet
except
ImportError
,
ex
:
except
ImportError
as
ex
:
sys
.
stderr
.
write
(
'Failed to import eventlet: %s
\
n
'
%
ex
)
return
from
eventlet.api
import
sleep
...
...
greentest/test__pywsgi.py
View file @
c093b89e
...
...
@@ -777,7 +777,7 @@ class TestContentLength304(TestCase):
def
application
(
self
,
env
,
start_response
):
try
:
start_response
(
'304 Not modified'
,
[(
'Content-Length'
,
'100'
)])
except
AssertionError
,
ex
:
except
AssertionError
as
ex
:
start_response
(
'200 Raised'
,
[])
return
[
str
(
ex
)]
else
:
...
...
@@ -804,7 +804,7 @@ class TestBody304(TestCase):
fd
.
write
(
'GET / HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
Connection: close
\
r
\
n
\
r
\
n
'
)
try
:
read_http
(
fd
)
except
AssertionError
,
ex
:
except
AssertionError
as
ex
:
self
.
assertEqual
(
str
(
ex
),
'The 304 response must have no body'
)
else
:
raise
AssertionError
(
'AssertionError must be raised'
)
...
...
@@ -827,7 +827,7 @@ class TestWrite304(TestCase):
fd
.
write
(
'GET / HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
Connection: close
\
r
\
n
\
r
\
n
'
)
try
:
read_http
(
fd
)
except
AssertionError
,
ex
:
except
AssertionError
as
ex
:
self
.
assertEqual
(
str
(
ex
),
'The 304 response must have no body'
)
else
:
raise
AssertionError
(
'write() must raise'
)
...
...
greentest/test__socket_dns.py
View file @
c093b89e
...
...
@@ -298,7 +298,7 @@ class TestFamily(TestCase):
try:
result = function(*args)
raise AssertionError('
%
s
:
Expected
to
raise
%
s
,
instead
returned
%
r' % (function, error, result))
except Exception
,
ex:
except Exception
as
ex:
if isinstance(error, basestring):
repr_error = error
else:
...
...
greentest/test__socket_ex.py
View file @
c093b89e
...
...
@@ -11,7 +11,7 @@ class TestClosedSocket(greentest.TestCase):
sock
.
close
()
try
:
sock
.
send
(
'a'
,
timeout
=
1
)
except
socket
.
error
,
ex
:
except
socket
.
error
as
ex
:
if
ex
[
0
]
!=
9
:
raise
...
...
greentest/test__subprocess.py
View file @
c093b89e
...
...
@@ -28,7 +28,7 @@ class Test(greentest.TestCase):
def
test_child_exception
(
self
):
try
:
subprocess
.
Popen
([
'*'
]).
wait
()
except
OSError
,
ex
:
except
OSError
as
ex
:
assert
ex
.
errno
==
2
,
ex
else
:
raise
AssertionError
(
'Expected OSError: [Errno 2] No such file or directory'
)
...
...
@@ -141,7 +141,7 @@ class Test(greentest.TestCase):
def
test_check_output_keyword_error
(
self
):
try
:
subprocess
.
check_output
([
sys
.
executable
,
'-c'
,
'import sys; sys.exit(44)'
])
except
subprocess
.
CalledProcessError
,
e
:
except
subprocess
.
CalledProcessError
as
e
:
self
.
assertEqual
(
e
.
returncode
,
44
)
else
:
raise
AssertionError
(
'must fail with CalledProcessError'
)
...
...
greentest/test_ares_timeout.py
View file @
c093b89e
...
...
@@ -8,7 +8,7 @@ address = ('127.0.0.10', 53)
listener
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
try
:
listener
.
bind
(
address
)
except
socket
.
error
,
ex
:
except
socket
.
error
as
ex
:
if
'permission denied'
in
str
(
ex
).
lower
():
sys
.
stderr
.
write
(
'This test binds on port 53 and thus must be run as root.
\
n
'
)
sys
.
exit
(
0
)
...
...
@@ -24,7 +24,7 @@ gevent.spawn(reader)
r
=
gevent
.
get_hub
().
resolver
=
Resolver
(
servers
=
[
'127.0.0.10'
],
timeout
=
0.001
,
tries
=
1
)
try
:
result
=
r
.
gethostbyname
(
'www.google.com'
)
except
socket
.
gaierror
,
ex
:
except
socket
.
gaierror
as
ex
:
if
'ARES_ETIMEOUT'
not
in
str
(
ex
):
raise
else
:
...
...
greentest/test_close_backend_fd.py
View file @
c093b89e
...
...
@@ -14,7 +14,7 @@ for count in xrange(2):
os
.
close
(
fileno
)
try
:
gevent
.
sleep
(
0.001
)
except
SystemError
,
ex
:
except
SystemError
as
ex
:
if
'(libev)'
in
str
(
ex
):
print
'The error is expected: %s'
%
ex
else
:
...
...
greentest/util.py
View file @
c093b89e
...
...
@@ -50,10 +50,10 @@ def killpg(pid):
return
try
:
return
os
.
killpg
(
pid
,
9
)
except
OSError
,
ex
:
except
OSError
as
ex
:
if
ex
.
errno
!=
3
:
log
(
'killpg(%r, 9) failed: %s: %s'
,
pid
,
type
(
ex
).
__name__
,
ex
)
except
Exception
,
ex
:
except
Exception
as
ex
:
log
(
'killpg(%r, 9) failed: %s: %s'
,
pid
,
type
(
ex
).
__name__
,
ex
)
...
...
@@ -68,7 +68,7 @@ def _kill(popen):
if
hasattr
(
popen
,
'kill'
):
try
:
popen
.
kill
()
except
OSError
,
ex
:
except
OSError
as
ex
:
if
ex
.
errno
==
3
:
# No such process
return
if
ex
.
errno
==
13
:
# Permission denied (translated from windows error 5: "Access is denied")
...
...
greentest/xtest__benchmarks.py
View file @
c093b89e
...
...
@@ -13,7 +13,7 @@ def kill(popen):
return
try
:
popen
.
kill
()
except
OSError
,
ex
:
except
OSError
as
ex
:
if
ex
.
errno
==
3
:
# No such process
return
if
ex
.
errno
==
13
:
# Permission denied (translated from windows error 5: "Access is denied")
...
...
util/set_version.py
View file @
c093b89e
...
...
@@ -108,7 +108,7 @@ def modify_version(filename, new_version):
def unlink(path):
try:
os.unlink(path)
except OSError
,
ex:
except OSError
as
ex:
if ex.errno == 2: # No such file or directory
return
raise
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment