This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author nedbat
Recipients nedbat, patriki, r.david.murray, serhiy.storchaka
Date 2016-12-24.12:51:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1482583868.33.0.980139195786.issue29048@psf.upfronthosting.co.za>
In-reply-to
Content
I doubt very very much that coverage.py is stealing stderr.  Many many test suites would have this problem if that were true.  More likely is that somehow __del__ is not being invoked when you need it to be.

I tried running the tests under coverage also, and did not see this behavior. I don't have a build tree of the latest code, but I ran it on 3.6.0.  The tests passed both with and without coverage measurement (output below).  I would like to understand why you are seeing the results you are.

$ mkvirtualenv -p python3.6 issue29048
Running virtualenv with interpreter /usr/local/bin/python3.6
Using base prefix '/usr/local/pythonz/pythons/CPython-3.6.0'
New python executable in issue29048/bin/python3.6
Also creating executable in issue29048/bin/python
Installing setuptools, pip, wheel...done.
Collecting pip
  Using cached pip-9.0.1-py2.py3-none-any.whl
Collecting setuptools
  Using cached setuptools-32.2.0-py2.py3-none-any.whl
Installing collected packages: pip, setuptools
  Found existing installation: pip 7.1.2
    Uninstalling pip-7.1.2:
      Successfully uninstalled pip-7.1.2
  Found existing installation: setuptools 18.2
    Uninstalling setuptools-18.2:
      Successfully uninstalled setuptools-18.2
Successfully installed pip-9.0.1 setuptools-32.2.0
(issue29048)$ pip install coverage
Collecting coverage
Installing collected packages: coverage
Successfully installed coverage-4.2
(issue29048)$ python3.6 -m test -v test_exceptions
== CPython 3.6.0 (default, Dec 23 2016, 07:11:25) [GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)]
==   Darwin-14.5.0-x86_64-i386-64bit little-endian
==   hash algorithm: siphash24 64bit
==  cwd: /private/var/folders/j2/gr3cj3jn63s5q8g3bjvw57hm0000gp/T/test_python_20266
==  encodings: locale=UTF-8, FS=utf-8
Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=0, verbose=0, bytes_warning=0, quiet=0, hash_randomization=1, isolated=0)
Run tests sequentially
0:00:00 [1/1] test_exceptions
testAttributes (test.test_exceptions.ExceptionTests) ... ok
testChainingAttrs (test.test_exceptions.ExceptionTests) ... ok
testChainingDescriptors (test.test_exceptions.ExceptionTests) ... ok
testExceptionCleanupNames (test.test_exceptions.ExceptionTests) ... ok
testExceptionCleanupState (test.test_exceptions.ExceptionTests) ... ok
testInfiniteRecursion (test.test_exceptions.ExceptionTests) ... ok
testInvalidAttrs (test.test_exceptions.ExceptionTests) ... ok
testInvalidTraceback (test.test_exceptions.ExceptionTests) ... ok
testKeywordArgs (test.test_exceptions.ExceptionTests) ... ok
testNoneClearsTracebackAttr (test.test_exceptions.ExceptionTests) ... ok
testRaising (test.test_exceptions.ExceptionTests) ... ok
testSettingException (test.test_exceptions.ExceptionTests) ... ok
testSyntaxErrorMessage (test.test_exceptions.ExceptionTests) ... ok
testSyntaxErrorOffset (test.test_exceptions.ExceptionTests) ... ok
testWithTraceback (test.test_exceptions.ExceptionTests) ... ok
test_3114 (test.test_exceptions.ExceptionTests) ... ok
test_MemoryError (test.test_exceptions.ExceptionTests) ... ok
test_WindowsError (test.test_exceptions.ExceptionTests) ... ok
test_badisinstance (test.test_exceptions.ExceptionTests) ... ok
test_errno_ENOTDIR (test.test_exceptions.ExceptionTests) ... ok
test_exception_target_in_nested_scope (test.test_exceptions.ExceptionTests) ... ok
test_exception_with_doc (test.test_exceptions.ExceptionTests) ... ok
test_generator_close_cleanup_exc_state (test.test_exceptions.ExceptionTests) ... ok
test_generator_del_cleanup_exc_state (test.test_exceptions.ExceptionTests) ... ok
test_generator_doesnt_retain_old_exc (test.test_exceptions.ExceptionTests) ... ok
test_generator_finalizing_and_exc_info (test.test_exceptions.ExceptionTests) ... ok
test_generator_leaking (test.test_exceptions.ExceptionTests) ... ok
test_generator_leaking2 (test.test_exceptions.ExceptionTests) ... ok
test_generator_leaking3 (test.test_exceptions.ExceptionTests) ... ok
test_generator_leaking4 (test.test_exceptions.ExceptionTests) ... ok
test_generator_next_cleanup_exc_state (test.test_exceptions.ExceptionTests) ... ok
test_generator_send_cleanup_exc_state (test.test_exceptions.ExceptionTests) ... ok
test_generator_throw_cleanup_exc_state (test.test_exceptions.ExceptionTests) ... ok
test_memory_error_cleanup (test.test_exceptions.ExceptionTests) ... ok
test_recursion_error_cleanup (test.test_exceptions.ExceptionTests) ... ok
test_str (test.test_exceptions.ExceptionTests) ... ok
test_unhandled (test.test_exceptions.ExceptionTests) ... ok
test_unicode_change_attributes (test.test_exceptions.ExceptionTests) ... ok
test_unicode_errors_no_object (test.test_exceptions.ExceptionTests) ... ok
test_unraisable (test.test_exceptions.ExceptionTests) ... ok
test_windows_message (test.test_exceptions.ExceptionTests)
Should fill in unknown error code in Windows error message ... skipped 'test specific to Windows'
test_attributes (test.test_exceptions.ImportErrorTests) ... ok
test_non_str_argument (test.test_exceptions.ImportErrorTests) ... ok

----------------------------------------------------------------------
Ran 43 tests in 0.027s

OK (skipped=1)
1 test OK.

Total duration: 64 ms
Tests result: SUCCESS
(issue29048)$ python -m coverage run --pylib -m test -v test_exceptions
== CPython 3.6.0 (default, Dec 23 2016, 07:11:25) [GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)]
==   Darwin-14.5.0-x86_64-i386-64bit little-endian
==   hash algorithm: siphash24 64bit
==  cwd: /private/var/folders/j2/gr3cj3jn63s5q8g3bjvw57hm0000gp/T/test_python_20270
==  encodings: locale=UTF-8, FS=utf-8
Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=0, verbose=0, bytes_warning=0, quiet=0, hash_randomization=1, isolated=0)
Run tests sequentially
0:00:00 [1/1] test_exceptions
testAttributes (test.test_exceptions.ExceptionTests) ... ok
testChainingAttrs (test.test_exceptions.ExceptionTests) ... ok
testChainingDescriptors (test.test_exceptions.ExceptionTests) ... ok
testExceptionCleanupNames (test.test_exceptions.ExceptionTests) ... ok
testExceptionCleanupState (test.test_exceptions.ExceptionTests) ... ok
testInfiniteRecursion (test.test_exceptions.ExceptionTests) ... ok
testInvalidAttrs (test.test_exceptions.ExceptionTests) ... ok
testInvalidTraceback (test.test_exceptions.ExceptionTests) ... ok
testKeywordArgs (test.test_exceptions.ExceptionTests) ... ok
testNoneClearsTracebackAttr (test.test_exceptions.ExceptionTests) ... ok
testRaising (test.test_exceptions.ExceptionTests) ... ok
testSettingException (test.test_exceptions.ExceptionTests) ... ok
testSyntaxErrorMessage (test.test_exceptions.ExceptionTests) ... ok
testSyntaxErrorOffset (test.test_exceptions.ExceptionTests) ... ok
testWithTraceback (test.test_exceptions.ExceptionTests) ... ok
test_3114 (test.test_exceptions.ExceptionTests) ... ok
test_MemoryError (test.test_exceptions.ExceptionTests) ... ok
test_WindowsError (test.test_exceptions.ExceptionTests) ... ok
test_badisinstance (test.test_exceptions.ExceptionTests) ... ok
test_errno_ENOTDIR (test.test_exceptions.ExceptionTests) ... ok
test_exception_target_in_nested_scope (test.test_exceptions.ExceptionTests) ... ok
test_exception_with_doc (test.test_exceptions.ExceptionTests) ... ok
test_generator_close_cleanup_exc_state (test.test_exceptions.ExceptionTests) ... ok
test_generator_del_cleanup_exc_state (test.test_exceptions.ExceptionTests) ... ok
test_generator_doesnt_retain_old_exc (test.test_exceptions.ExceptionTests) ... ok
test_generator_finalizing_and_exc_info (test.test_exceptions.ExceptionTests) ... ok
test_generator_leaking (test.test_exceptions.ExceptionTests) ... ok
test_generator_leaking2 (test.test_exceptions.ExceptionTests) ... ok
test_generator_leaking3 (test.test_exceptions.ExceptionTests) ... ok
test_generator_leaking4 (test.test_exceptions.ExceptionTests) ... ok
test_generator_next_cleanup_exc_state (test.test_exceptions.ExceptionTests) ... ok
test_generator_send_cleanup_exc_state (test.test_exceptions.ExceptionTests) ... ok
test_generator_throw_cleanup_exc_state (test.test_exceptions.ExceptionTests) ... ok
test_memory_error_cleanup (test.test_exceptions.ExceptionTests) ... ok
test_recursion_error_cleanup (test.test_exceptions.ExceptionTests) ... ok
test_str (test.test_exceptions.ExceptionTests) ... ok
test_unhandled (test.test_exceptions.ExceptionTests) ... ok
test_unicode_change_attributes (test.test_exceptions.ExceptionTests) ... ok
test_unicode_errors_no_object (test.test_exceptions.ExceptionTests) ... ok
test_unraisable (test.test_exceptions.ExceptionTests) ... ok
test_windows_message (test.test_exceptions.ExceptionTests)
Should fill in unknown error code in Windows error message ... skipped 'test specific to Windows'
test_attributes (test.test_exceptions.ImportErrorTests) ... ok
test_non_str_argument (test.test_exceptions.ImportErrorTests) ... ok

----------------------------------------------------------------------
Ran 43 tests in 0.036s

OK (skipped=1)
1 test OK.

Total duration: 95 ms
Tests result: SUCCESS
(issue29048)$ python -m coverage report
Name                                                                                       Stmts   Miss  Cover
--------------------------------------------------------------------------------------------------------------
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/_bootlocale.py                         17     13    24%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/_collections_abc.py                   562    546     3%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/_osx_support.py                       210    161    23%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/_sysconfigdata_m_darwin_darwin.py       1      0   100%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/_weakrefset.py                        146    109    25%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/abc.py                                 92     65    29%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/argparse.py                          1187    757    36%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/base64.py                             315    268    15%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/codecs.py                             398    377     5%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/collections/__init__.py               677    650     4%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/contextlib.py                         163    140    14%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/difflib.py                            669    606     9%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/email/__init__.py                      14      8    43%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/email/base64mime.py                    40     26    35%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/email/charset.py                      122     78    36%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/email/encoders.py                      28     19    32%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/email/errors.py                        37      7    81%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/email/header.py                       310    258    17%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/email/quoprimime.py                   115     83    28%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/encodings/__init__.py                  76     43    43%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/encodings/latin_1.py                   19     18     5%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/enum.py                               438    248    43%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/functools.py                          443    421     5%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/genericpath.py                         72     50    31%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/gettext.py                            389    323    17%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/gzip.py                               349    298    15%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/importlib/__init__.py                  99     96     3%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/importlib/_bootstrap.py               631    445    29%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/importlib/_bootstrap_external.py      711    528    26%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/importlib/util.py                     147    140     5%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/ipaddress.py                          904    597    34%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/linecache.py                          102     55    46%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/locale.py                             399    357    11%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/logging/__init__.py                   769    521    32%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/logging/handlers.py                   663    534    19%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/lzma.py                               135    130     4%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/multiprocessing/process.py            163    162     1%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/nntplib.py                            559    457    18%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/os.py                                 536    489     9%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/platform.py                           580    466    20%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/posixpath.py                          320    222    31%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/pprint.py                             419    351    16%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/queue.py                              111     76    32%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/quopri.py                             168    150    11%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/random.py                             346    329     5%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/re.py                                 153    125    18%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/shutil.py                             619    600     3%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/socket.py                             403    396     2%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/sre_compile.py                        401    151    62%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/sre_parse.py                          758    460    39%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/ssl.py                                571    426    25%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/string.py                             153    114    25%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/subprocess.py                         794    671    15%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/sysconfig.py                          376    246    35%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/tempfile.py                           395    258    35%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/test/__init__.py                        0      0   100%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/test/__main__.py                        2      0   100%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/test/libregrtest/__init__.py            3      0   100%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/test/libregrtest/cmdline.py           127     52    59%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/test/libregrtest/main.py              335    163    51%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/test/libregrtest/refleak.py           186    122    34%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/test/libregrtest/runtest.py           146     62    58%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/test/libregrtest/save_env.py          189     68    64%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/test/libregrtest/setup.py              68     21    69%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/test/support/__init__.py             1289    902    30%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/test/test_exceptions.py               765     93    88%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/threading.py                          575    572     1%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/tokenize.py                           473    438     7%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/traceback.py                          247    185    25%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/types.py                              155    152     2%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/unittest/__init__.py                   15      3    80%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/unittest/case.py                      753    413    45%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/unittest/loader.py                    295    226    23%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/unittest/main.py                      149    122    18%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/unittest/result.py                    128     66    48%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/unittest/runner.py                    159     51    68%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/unittest/signals.py                    47     33    30%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/unittest/suite.py                     220     81    63%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/unittest/util.py                      130    107    18%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/urllib/__init__.py                      0      0   100%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/urllib/error.py                        34     19    44%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/urllib/response.py                     43     26    40%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/warnings.py                           331    300     9%
/usr/local/pythonz/pythons/CPython-3.6.0/lib/python3.6/weakref.py                            379    342    10%
--------------------------------------------------------------------------------------------------------------
TOTAL                                                                                      26517  19743    26%
(issue29048)$
History
Date User Action Args
2016-12-24 12:51:08nedbatsetrecipients: + nedbat, r.david.murray, serhiy.storchaka, patriki
2016-12-24 12:51:08nedbatsetmessageid: <1482583868.33.0.980139195786.issue29048@psf.upfronthosting.co.za>
2016-12-24 12:51:08nedbatlinkissue29048 messages
2016-12-24 12:51:06nedbatcreate