From eb522119345282edea88ebbf92ff781927d4c8d0 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 8 Nov 2016 19:16:07 -0500 Subject: Use py2 ConfigParser if we can, prevents deprecation warnings. #530 --- CHANGES.rst | 4 ++++ coverage/backward.py | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index e7c5760..4a6d0ed 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -43,6 +43,9 @@ Unreleased - Fixed an unusual bug involving multiple coding declarations affecting code containing code in multi-line strings: `issue 529`_. +- Prevented deprecation warnings from configparser that happened in some + circumstatnces, closing `issue 530`_. + - Corrected the name of the jquery.ba-throttle-debounce.js library. Thanks, Ben Finney. Closes `issue 505`_. @@ -55,6 +58,7 @@ Unreleased .. _issue 516: https://bitbucket.org/ned/coveragepy/issues/516/running-coverage-combine-twice-deletes-all .. _issue 525: https://bitbucket.org/ned/coveragepy/issues/525/coverage-combine-when-not-in-parallel-mode .. _issue 529: https://bitbucket.org/ned/coveragepy/issues/529/encoding-marker-may-only-appear-on-the +.. _issue 530: https://bitbucket.org/ned/coveragepy/issues/530/deprecationwarning-you-passed-a-bytestring Version 4.2 --- 2016-07-26 diff --git a/coverage/backward.py b/coverage/backward.py index 00fffa5..c7b607a 100644 --- a/coverage/backward.py +++ b/coverage/backward.py @@ -17,11 +17,14 @@ try: except ImportError: from io import StringIO -# In py3, ConfigParser was renamed to the more-standard configparser +# In py3, ConfigParser was renamed to the more-standard configparser. +# But there's a py3 backport that installs "configparser" in py2, and I don't +# want it because it has annoying deprecation warnings. So try the real py2 +# import first. try: - import configparser -except ImportError: import ConfigParser as configparser +except ImportError: + import configparser # What's a string called? try: -- cgit v1.2.1