diff --git a/HISTORY.rst b/HISTORY.rst index 14258008..0b7f21ca 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -38,6 +38,7 @@ PlatformIO Core 4.0 * Fixed an issue with project generator when ``src_build_flags`` were not respected (`issue #3137 `_) * Fixed an issue when booleans in "platformio.ini" are not parsed properly (`issue #3022 `_) * Fixed an issue with invalid encoding when generating project for Visual Studio (`issue #3183 `_) +* Fixed an issue when Project Config Parser does not remove in-line comments when Python 3 is used (`issue #3213 `_) 4.0.3 (2019-08-30) ~~~~~~~~~~~~~~~~~~ diff --git a/platformio/project/config.py b/platformio/project/config.py index 73d5e087..763ff66f 100644 --- a/platformio/project/config.py +++ b/platformio/project/config.py @@ -21,7 +21,7 @@ from hashlib import sha1 import click from platformio import exception, fs -from platformio.compat import WINDOWS, hashlib_encode_data +from platformio.compat import PY2, WINDOWS, hashlib_encode_data from platformio.project.options import ProjectOptions try: @@ -84,7 +84,11 @@ class ProjectConfigBase(object): self.expand_interpolations = expand_interpolations self.warnings = [] self._parsed = [] - self._parser = ConfigParser.ConfigParser() + self._parser = ( + ConfigParser.ConfigParser() + if PY2 + else ConfigParser.ConfigParser(inline_comment_prefixes=("#", ";")) + ) if path and os.path.isfile(path): self.read(path, parse_extra) diff --git a/tests/test_projectconf.py b/tests/test_projectconf.py index c95584e9..b118a2ef 100644 --- a/tests/test_projectconf.py +++ b/tests/test_projectconf.py @@ -28,9 +28,9 @@ extra_configs = # global options per [env:*] [env] -monitor_speed = 115200 +monitor_speed = 115200 ; inline comment lib_deps = - Lib1 + Lib1 ; inline comment in multi-line value Lib2 lib_ignore = ${custom.lib_ignore}