mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #18013 -- Use the new 'as' syntax for exceptions.
Thanks Clueless for the initial patch. Note that unittest has been purposely left out (external package only used by Python 2.6).
This commit is contained in:
@@ -1626,7 +1626,7 @@ class DebugRunner(DocTestRunner):
|
||||
... {}, 'foo', 'foo.py', 0)
|
||||
>>> try:
|
||||
... runner.run(test)
|
||||
... except UnexpectedException, failure:
|
||||
... except UnexpectedException as failure:
|
||||
... pass
|
||||
|
||||
>>> failure.test is test
|
||||
@@ -1654,7 +1654,7 @@ class DebugRunner(DocTestRunner):
|
||||
|
||||
>>> try:
|
||||
... runner.run(test)
|
||||
... except DocTestFailure, failure:
|
||||
... except DocTestFailure as failure:
|
||||
... pass
|
||||
|
||||
DocTestFailure objects provide access to the test:
|
||||
@@ -2164,7 +2164,7 @@ class DocTestCase(unittest.TestCase):
|
||||
>>> case = DocTestCase(test)
|
||||
>>> try:
|
||||
... case.debug()
|
||||
... except UnexpectedException, failure:
|
||||
... except UnexpectedException as failure:
|
||||
... pass
|
||||
|
||||
The UnexpectedException contains the test, the example, and
|
||||
@@ -2193,7 +2193,7 @@ class DocTestCase(unittest.TestCase):
|
||||
|
||||
>>> try:
|
||||
... case.debug()
|
||||
... except DocTestFailure, failure:
|
||||
... except DocTestFailure as failure:
|
||||
... pass
|
||||
|
||||
DocTestFailure objects provide access to the test:
|
||||
|
||||
@@ -378,7 +378,7 @@ class Client(RequestFactory):
|
||||
|
||||
try:
|
||||
response = self.handler(environ)
|
||||
except TemplateDoesNotExist, e:
|
||||
except TemplateDoesNotExist as e:
|
||||
# If the view raises an exception, Django will attempt to show
|
||||
# the 500.html template. If that template is not available,
|
||||
# we should ignore the error in favor of re-raising the
|
||||
|
||||
@@ -84,7 +84,7 @@ def restore_transaction_methods():
|
||||
def assert_and_parse_html(self, html, user_msg, msg):
|
||||
try:
|
||||
dom = parse_html(html)
|
||||
except HTMLParseError, e:
|
||||
except HTMLParseError as e:
|
||||
standardMsg = u'%s\n%s' % (msg, e.msg)
|
||||
self.fail(self._formatMessage(user_msg, standardMsg))
|
||||
return dom
|
||||
@@ -1035,7 +1035,7 @@ class LiveServerThread(threading.Thread):
|
||||
try:
|
||||
self.httpd = StoppableWSGIServer(
|
||||
(self.host, port), QuietWSGIRequestHandler)
|
||||
except WSGIServerException, e:
|
||||
except WSGIServerException as e:
|
||||
if (index + 1 < len(self.possible_ports) and
|
||||
e.args[0].errno == errno.EADDRINUSE):
|
||||
# This port is already in use, so we go on and try with
|
||||
@@ -1054,7 +1054,7 @@ class LiveServerThread(threading.Thread):
|
||||
self.httpd.set_app(handler)
|
||||
self.is_ready.set()
|
||||
self.httpd.serve_forever()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.error = e
|
||||
self.is_ready.set()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user