Commit a47d63eb authored by Stefan Behnel's avatar Stefan Behnel

Try to fix test compilation problem with MSVC, where 1/0 is a compile time error.

parent f7bcf72f
...@@ -127,12 +127,13 @@ class ExceptionTests(unittest.TestCase): ...@@ -127,12 +127,13 @@ class ExceptionTests(unittest.TestCase):
self.raise_catch(ValueError, "ValueError") self.raise_catch(ValueError, "ValueError")
self.assertRaises(ValueError, chr, 17<<16) self.assertRaises(ValueError, chr, 17<<16)
ZERO = 0
self.raise_catch(ZeroDivisionError, "ZeroDivisionError") self.raise_catch(ZeroDivisionError, "ZeroDivisionError")
try: x = 1/0 try: x = 1/ZERO
except ZeroDivisionError: pass except ZeroDivisionError: pass
self.raise_catch(Exception, "Exception") self.raise_catch(Exception, "Exception")
try: x = 1/0 try: x = 1/ZERO
except Exception as e: pass except Exception as e: pass
self.raise_catch(StopAsyncIteration, "StopAsyncIteration") self.raise_catch(StopAsyncIteration, "StopAsyncIteration")
...@@ -668,8 +669,9 @@ class ExceptionTests(unittest.TestCase): ...@@ -668,8 +669,9 @@ class ExceptionTests(unittest.TestCase):
# "can not delete variable 'e' referenced in nested scope" # "can not delete variable 'e' referenced in nested scope"
def print_error(): def print_error():
e e
ZERO = 0
try: try:
1/0 1/ZERO
except Exception as e: except Exception as e:
print_error() print_error()
# implicit "del e" here # implicit "del e" here
...@@ -730,8 +732,9 @@ class ExceptionTests(unittest.TestCase): ...@@ -730,8 +732,9 @@ class ExceptionTests(unittest.TestCase):
yield sys.exc_info()[1] yield sys.exc_info()[1]
it = g() it = g()
next(it) next(it)
ZERO = 0
try: try:
1/0 1/ZERO
except ZeroDivisionError as e: except ZeroDivisionError as e:
self.assertIs(sys.exc_info()[1], e) self.assertIs(sys.exc_info()[1], e)
gen_exc = it.throw(e) gen_exc = it.throw(e)
...@@ -743,8 +746,9 @@ class ExceptionTests(unittest.TestCase): ...@@ -743,8 +746,9 @@ class ExceptionTests(unittest.TestCase):
# See issue #23353. When an exception is raised by a generator, # See issue #23353. When an exception is raised by a generator,
# the caller's exception state should still be restored. # the caller's exception state should still be restored.
def g(): def g():
ZERO = 0
try: try:
1/0 1/ZERO
except ZeroDivisionError: except ZeroDivisionError:
yield sys.exc_info()[0] yield sys.exc_info()[0]
raise raise
...@@ -1275,8 +1279,9 @@ class ExceptionTests(unittest.TestCase): ...@@ -1275,8 +1279,9 @@ class ExceptionTests(unittest.TestCase):
with self.assertRaises(ZeroDivisionError): with self.assertRaises(ZeroDivisionError):
i = g() i = g()
ZERO = 0
try: try:
1/0 1/ZERO
except: except:
next(i) next(i)
next(i) next(i)
......
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