[pypy-issue] Issue #1903: Chained exception in pypy3 working differently than CPython 3.x (pypy/pypy)

Ned Batchelder issues-reply at bitbucket.org
Sun Oct 26 22:04:13 CET 2014


New issue 1903: Chained exception in pypy3 working differently than CPython 3.x
https://bitbucket.org/pypy/pypy/issue/1903/chained-exception-in-pypy3-working

Ned Batchelder:

The coverage.py test suite fails in one test for pypy3.

PyPy3 testing was added in e303eb19c993 (https://bitbucket.org/ned/coveragepy/commits/e303eb19c993376b91ffb68da368a3482b4a608a)

To run the test suite:

```
pip install -r requirements.txt
tox
```

The failure:

```
======================================================================
FAIL: test_code_throws (tests.test_process.ProcessTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/ned/coverage/trunk/tests/test_process.py", line 274, in test_code_throws
    self.assertMultiLineEqual(out, out2)
nose.proxy.AssertionError: 'Traceback (most recent call last):\n  File "/Users/ned/coverage/trunk/coverage/ [truncated]... != 'Traceback (most recent call last):\n  File "throw.py", line 7, in <module>\n    [truncated]...
- Traceback (most recent call last):
-   File "/Users/ned/coverage/trunk/coverage/cmdline.py", line 671, in main
-     status = CoverageScript().command_line(argv)
-   File "/Users/ned/coverage/trunk/coverage/cmdline.py", line 416, in command_line
-     self.do_execute(options, args)
-   File "/Users/ned/coverage/trunk/coverage/cmdline.py", line 560, in do_execute
-     self.run_python_file(filename, args)
-   File "/Users/ned/coverage/trunk/coverage/execfile.py", line 141, in run_python_file
-     raise ExceptionDuringRun(typ, err, tb.tb_next)
- coverage.misc.ExceptionDuringRun: (<class 'Exception'>, Exception('hey!',), <traceback object at 0x0000000103ffa740>)
-
- During handling of the above exception, another exception occurred:
-
  Traceback (most recent call last):
    File "throw.py", line 7, in <module>
      f2()
    File "throw.py", line 5, in f2
      f1()
    File "throw.py", line 2, in f1
      raise Exception("hey!")
  Exception: hey!

-------------------- >> begin captured stdout << ---------------------
Traceback (most recent call last):
  File "/Users/ned/coverage/trunk/coverage/cmdline.py", line 671, in main
    status = CoverageScript().command_line(argv)
  File "/Users/ned/coverage/trunk/coverage/cmdline.py", line 416, in command_line
    self.do_execute(options, args)
  File "/Users/ned/coverage/trunk/coverage/cmdline.py", line 560, in do_execute
    self.run_python_file(filename, args)
  File "/Users/ned/coverage/trunk/coverage/execfile.py", line 141, in run_python_file
    raise ExceptionDuringRun(typ, err, tb.tb_next)
coverage.misc.ExceptionDuringRun: (<class 'Exception'>, Exception('hey!',), <traceback object at 0x0000000103ffa740>)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "throw.py", line 7, in <module>
    f2()
  File "throw.py", line 5, in f2
    f1()
  File "throw.py", line 2, in f1
    raise Exception("hey!")
Exception: hey!

Traceback (most recent call last):
  File "throw.py", line 7, in <module>
    f2()
  File "throw.py", line 5, in f2
    f1()
  File "throw.py", line 2, in f1
    raise Exception("hey!")
Exception: hey!


--------------------- >> end captured stdout << ----------------------
```

This test checks that running a program under coverage produces the same output as running it not under coverage. The program raises an exception.  Under pypy3, it gets this output:
```
Traceback (most recent call last):
  File "throw.py", line 7, in <module>
    f2()
  File "throw.py", line 5, in f2
    f1()
  File "throw.py", line 2, in f1
    raise Exception("hey!")
Exception: hey!
```

Under coverage, it gets this:
```
Traceback (most recent call last):
  File "/Users/ned/coverage/trunk/coverage/cmdline.py", line 671, in main
    status = CoverageScript().command_line(argv)
  File "/Users/ned/coverage/trunk/coverage/cmdline.py", line 416, in command_line
    self.do_execute(options, args)
  File "/Users/ned/coverage/trunk/coverage/cmdline.py", line 560, in do_execute
    self.run_python_file(filename, args)
  File "/Users/ned/coverage/trunk/coverage/execfile.py", line 141, in run_python_file
    raise ExceptionDuringRun(typ, err, tb.tb_next)
coverage.misc.ExceptionDuringRun: (<class 'Exception'>, Exception('hey!',), <traceback object at 0x0000000103ffa740>)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "throw.py", line 7, in <module>
    f2()
  File "throw.py", line 5, in f2
    f1()
  File "throw.py", line 2, in f1
    raise Exception("hey!")
Exception: hey!
```

This test passes on CPython 2.6, 2.7, 3.2, 3.3, 3.4, and on PyPy2




More information about the pypy-issue mailing list