Skip to content

Commit c5320ab

Browse files
committed
Fix deprecation warning when using python 2.7.13
Just invert the import order, try to get the real python 2 ConfigParser first.
1 parent 2b7aefa commit c5320ab

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ Version 1.8.4
1717

1818
2. Updated travis setup to python 3.6 for OS X.
1919

20+
* Fix deprecation warnings thrown by ```ConfigParser``` when using pygccxml
21+
with python 2.7.13.
22+
2023
Version 1.8.3
2124
-------------
2225

pygccxml/parser/config.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@
1313
import platform
1414
import subprocess
1515
import warnings
16+
# In py3, ConfigParser was renamed to the more-standard configparser.
17+
# But there's a py3 backport that installs "configparser" in py2, and I don't
18+
# want it because it has annoying deprecation warnings. So try the real py2
19+
# import first
20+
# Inspired by https://bitbucket.org/ned/coveragepy/commits/f8e9d62f1412
1621
try:
17-
from configparser import ConfigParser
18-
except ImportError:
1922
from ConfigParser import SafeConfigParser as ConfigParser
23+
except ImportError:
24+
from configparser import ConfigParser
2025
from .. import utils
2126

2227

0 commit comments

Comments
 (0)