Fixed "TypeError: unsupported operand type(s)" when system environment variable is used by project configuration parser // Resolve #3377

This commit is contained in:
Ivan Kravets
2020-02-13 13:34:34 +02:00
parent 206054b35f
commit 36a2228220
3 changed files with 24 additions and 12 deletions

View File

@ -1,10 +1,16 @@
Release Notes
=============
.. _release_notes_4_0:
.. _release_notes_4:
PlatformIO Core 4
-----------------
4.2.1 (2020-02-??)
~~~~~~~~~~~~~~~~~~
* Fixed "TypeError: unsupported operand type(s)" when system environment variable is used by project configuration parser (`issue #3377 <https://github.com/platformio/platformio-core/issues/3377>`_)
PlatformIO Core 4.0
-------------------
4.2.0 (2020-02-12)
~~~~~~~~~~~~~~~~~~
@ -182,8 +188,8 @@ PlatformIO Core 4.0
- Fixed "systemd-udevd" warnings in `99-platformio-udev.rules <http://docs.platformio.org/page/faq.html#platformio-udev-rules>`__ (`issue #2442 <https://github.com/platformio/platformio-core/issues/2442>`_)
- Fixed an issue when package cache (Library Manager) expires too fast (`issue #2559 <https://github.com/platformio/platformio-core/issues/2559>`_)
PlatformIO Core 3.0
-------------------
PlatformIO Core 3
-----------------
3.6.7 (2019-04-23)
~~~~~~~~~~~~~~~~~~
@ -783,8 +789,8 @@ PlatformIO Core 3.0
(`issue #742 <https://github.com/platformio/platformio-core/issues/742>`_)
* Stopped supporting Python 2.6
PlatformIO Core 2.0
--------------------
PlatformIO Core 2
-----------------
2.11.2 (2016-08-02)
~~~~~~~~~~~~~~~~~~~
@ -1569,8 +1575,8 @@ PlatformIO Core 2.0
* Fixed bug with creating copies of source files
(`issue #177 <https://github.com/platformio/platformio-core/issues/177>`_)
PlatformIO Core 1.0
-------------------
PlatformIO Core 1
-----------------
1.5.0 (2015-05-15)
~~~~~~~~~~~~~~~~~~
@ -1760,8 +1766,8 @@ PlatformIO Core 1.0
error (`issue #81 <https://github.com/platformio/platformio-core/issues/81>`_)
* Several bug fixes, increased stability and performance improvements
PlatformIO Core 0.0
-------------------
PlatformIO Core Preview
-----------------------
0.10.2 (2015-01-06)
~~~~~~~~~~~~~~~~~~~

View File

@ -273,7 +273,9 @@ class ProjectConfigBase(object):
if envvar_value:
break
if envvar_value and option_meta.multiple:
value += ("" if value == MISSING else "\n") + envvar_value
if value == MISSING:
value = ""
value += ("\n" if value else "") + envvar_value
elif envvar_value and value == MISSING:
value = envvar_value

View File

@ -185,6 +185,7 @@ def test_sysenv_options(config):
assert config.get("env:base", "upload_port") is None
assert config.get("env:extra_2", "upload_port") == "/dev/extra_2/port"
os.environ["PLATFORMIO_BUILD_FLAGS"] = "-DSYSENVDEPS1 -DSYSENVDEPS2"
os.environ["PLATFORMIO_BUILD_UNFLAGS"] = "-DREMOVE_MACRO"
os.environ["PLATFORMIO_UPLOAD_PORT"] = "/dev/sysenv/port"
os.environ["__PIO_TEST_CNF_EXTRA_FLAGS"] = "-L /usr/local/lib"
assert config.get("custom", "extra_flags") == "-L /usr/local/lib"
@ -194,6 +195,7 @@ def test_sysenv_options(config):
]
assert config.get("env:base", "upload_port") == "/dev/sysenv/port"
assert config.get("env:extra_2", "upload_port") == "/dev/extra_2/port"
assert config.get("env:base", "build_unflags") == ["-DREMOVE_MACRO"]
# env var as option
assert config.options(env="test_extends") == [
@ -206,6 +208,7 @@ def test_sysenv_options(config):
"lib_deps",
"lib_ignore",
"custom_builtin_option",
"build_unflags",
"upload_port",
]
@ -215,6 +218,7 @@ def test_sysenv_options(config):
# cleanup system environment variables
del os.environ["PLATFORMIO_BUILD_FLAGS"]
del os.environ["PLATFORMIO_BUILD_UNFLAGS"]
del os.environ["PLATFORMIO_UPLOAD_PORT"]
del os.environ["__PIO_TEST_CNF_EXTRA_FLAGS"]
del os.environ["PLATFORMIO_HOME_DIR"]