diff options
author | Jake Farrell <jfarrell@apache.org> | 2012-05-18 01:00:39 +0000 |
---|---|---|
committer | Jake Farrell <jfarrell@apache.org> | 2012-05-18 01:00:39 +0000 |
commit | 6c5ee6ad2067e245ab5364f9a6019d8b63d7ed52 (patch) | |
tree | c699696515dd54bf246bcb7b400b8a0b567ac7c0 /lib/py | |
parent | 5e022aa6865918d56616b9ef026337bd766ce04a (diff) | |
download | thrift-6c5ee6ad2067e245ab5364f9a6019d8b63d7ed52.tar.gz |
Thrift-1604:Python exxception handeling for changes from PEP3110
Client: py
Patch: Jake Farrell
Python PEP 3110 changed exception handling by replacing the ',' with 'as'. This was initially introduced in python 2.6 and in 3.0 the ',' usage is no longer suppported. Since exception handling through out the py lib uses the ',' it will need to be converted over to using the 'as' syntax for exceptions
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1339941 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'lib/py')
-rw-r--r-- | lib/py/src/server/THttpServer.py | 2 | ||||
-rw-r--r-- | lib/py/src/server/TProcessPoolServer.py | 6 | ||||
-rw-r--r-- | lib/py/src/server/TServer.py | 18 | ||||
-rw-r--r-- | lib/py/src/transport/TSSLSocket.py | 6 |
4 files changed, 16 insertions, 16 deletions
diff --git a/lib/py/src/server/THttpServer.py b/lib/py/src/server/THttpServer.py index be54bab94..6f9217393 100644 --- a/lib/py/src/server/THttpServer.py +++ b/lib/py/src/server/THttpServer.py @@ -73,7 +73,7 @@ class THttpServer(TServer.TServer): oprot = thttpserver.outputProtocolFactory.getProtocol(otrans) try: thttpserver.processor.process(iprot, oprot) - except ResponseException, exn: + except ResponseException as exn: exn.handler(self) else: self.send_response(200) diff --git a/lib/py/src/server/TProcessPoolServer.py b/lib/py/src/server/TProcessPoolServer.py index 7a695a883..86c431212 100644 --- a/lib/py/src/server/TProcessPoolServer.py +++ b/lib/py/src/server/TProcessPoolServer.py @@ -59,7 +59,7 @@ class TProcessPoolServer(TServer): self.serveClient(client) except (KeyboardInterrupt, SystemExit): return 0 - except Exception, x: + except Exception as x: logging.exception(x) def serveClient(self, client): @@ -74,7 +74,7 @@ class TProcessPoolServer(TServer): self.processor.process(iprot, oprot) except TTransportException, tx: pass - except Exception, x: + except Exception as x: logging.exception(x) itrans.close() @@ -106,7 +106,7 @@ class TProcessPoolServer(TServer): break except (SystemExit, KeyboardInterrupt): break - except Exception, x: + except Exception as x: logging.exception(x) self.isRunning.value = False diff --git a/lib/py/src/server/TServer.py b/lib/py/src/server/TServer.py index 2f24842c4..97097cc4a 100644 --- a/lib/py/src/server/TServer.py +++ b/lib/py/src/server/TServer.py @@ -84,7 +84,7 @@ class TSimpleServer(TServer): self.processor.process(iprot, oprot) except TTransport.TTransportException, tx: pass - except Exception, x: + except Exception as x: logging.exception(x) itrans.close() @@ -108,7 +108,7 @@ class TThreadedServer(TServer): t.start() except KeyboardInterrupt: raise - except Exception, x: + except Exception as x: logging.exception(x) def handle(self, client): @@ -121,7 +121,7 @@ class TThreadedServer(TServer): self.processor.process(iprot, oprot) except TTransport.TTransportException, tx: pass - except Exception, x: + except Exception as x: logging.exception(x) itrans.close() @@ -161,7 +161,7 @@ class TThreadPoolServer(TServer): self.processor.process(iprot, oprot) except TTransport.TTransportException, tx: pass - except Exception, x: + except Exception as x: logging.exception(x) itrans.close() @@ -174,7 +174,7 @@ class TThreadPoolServer(TServer): t = threading.Thread(target=self.serveThread) t.setDaemon(self.daemon) t.start() - except Exception, x: + except Exception as x: logging.exception(x) # Pump the socket for clients @@ -183,7 +183,7 @@ class TThreadPoolServer(TServer): try: client = self.serverTransport.accept() self.clients.put(client) - except Exception, x: + except Exception as x: logging.exception(x) @@ -208,7 +208,7 @@ class TForkingServer(TServer): def try_close(file): try: file.close() - except IOError, e: + except IOError as e: logging.warning(e, exc_info=True) self.serverTransport.listen() @@ -242,7 +242,7 @@ class TForkingServer(TServer): self.processor.process(iprot, oprot) except TTransport.TTransportException, tx: pass - except Exception, e: + except Exception as e: logging.exception(e) ecode = 1 finally: @@ -253,7 +253,7 @@ class TForkingServer(TServer): except TTransport.TTransportException, tx: pass - except Exception, x: + except Exception as x: logging.exception(x) def collect_children(self): diff --git a/lib/py/src/transport/TSSLSocket.py b/lib/py/src/transport/TSSLSocket.py index 6d79ac6a6..e0ff4f940 100644 --- a/lib/py/src/transport/TSSLSocket.py +++ b/lib/py/src/transport/TSSLSocket.py @@ -86,13 +86,13 @@ class TSSLSocket(TSocket.TSocket): self.handle.settimeout(self._timeout) try: self.handle.connect(ip_port) - except socket.error, e: + except socket.error as e: if res is not res0[-1]: continue else: raise e break - except socket.error, e: + except socket.error as e: if self._unix_socket: message = 'Could not connect to secure socket %s' % self._unix_socket else: @@ -188,7 +188,7 @@ class TSSLServerSocket(TSocket.TServerSocket): try: client = ssl.wrap_socket(plain_client, certfile=self.certfile, server_side=True, ssl_version=self.SSL_VERSION) - except ssl.SSLError, ssl_exc: + except ssl.SSLError as ssl_exc: # failed handshake/ssl wrap, close socket to client plain_client.close() # raise ssl_exc |