Skip to content

Commit

Permalink
Fixed "TypeError: unsupported operand type(s)" when system environmen…
Browse files Browse the repository at this point in the history
…t variable is used by project configuration parser // Resolve #3377
  • Loading branch information
ivankravets committed Feb 13, 2020
1 parent 206054b commit 36a2228
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
28 changes: 17 additions & 11 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -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)
~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -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)
~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -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)
~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -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)
~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -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)
~~~~~~~~~~~~~~~~~~~
Expand Down
4 changes: 3 additions & 1 deletion platformio/project/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,9 @@ def getraw( # pylint: disable=too-many-branches
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

Expand Down
4 changes: 4 additions & 0 deletions tests/test_projectconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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") == [
Expand All @@ -206,6 +208,7 @@ def test_sysenv_options(config):
"lib_deps",
"lib_ignore",
"custom_builtin_option",
"build_unflags",
"upload_port",
]

Expand All @@ -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"]
Expand Down

0 comments on commit 36a2228

Please sign in to comment.