diff --git a/itty.py b/itty.py index d4d179b..0afbc70 100644 --- a/itty.py +++ b/itty.py @@ -261,7 +261,7 @@ def convert_to_ascii(self, data): if isinstance(data, unicode): try: return data.encode('us-ascii') - except UnicodeError, e: + except UnicodeError as e: raise else: return str(data) @@ -271,13 +271,13 @@ def handle_request(environ, start_response): """The main handler. Dispatches to the user's code.""" try: request = Request(environ, start_response) - except Exception, e: + except Exception as e: return handle_error(e) try: (re_url, url, callback), kwargs = find_matching_url(request) response = callback(request, **kwargs) - except Exception, e: + except Exception as e: return handle_error(e, request) if not isinstance(response, Response): @@ -616,12 +616,12 @@ def run_itty(server='wsgiref', host='localhost', port=8080, config=None): # AppEngine seems to echo everything, even though it shouldn't. Accomodate. if server != 'appengine': - print 'itty starting up (using %s)...' % server - print 'Listening on http://%s:%s...' % (host, port) - print 'Use Ctrl-C to quit.' - print + print('itty starting up (using %s)...' % server) + print('Listening on http://%s:%s...' % (host, port)) + print('Use Ctrl-C to quit.') + print() try: WSGI_ADAPTERS[server](host, port) except KeyboardInterrupt: - print 'Shutting down. Have a nice day!' + print('Shutting down. Have a nice day!')