From 3c8c4f4a890a7d3b209bdb709fd92f3f7d1adf61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zaj=C4=85c?= Date: Tue, 17 Sep 2019 20:20:41 +0200 Subject: [PATCH] Do not error out on lines containg spaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a breaking change - https://github.com/docker/compose/issues/6511 Signed-off-by: Michał Zając --- compose/config/environment.py | 10 ++-------- tests/unit/config/environment_test.py | 9 --------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/compose/config/environment.py b/compose/config/environment.py index 696356f3246..0d9c28ba392 100644 --- a/compose/config/environment.py +++ b/compose/config/environment.py @@ -19,17 +19,11 @@ def split_env(env): if isinstance(env, six.binary_type): env = env.decode('utf-8', 'replace') - key = value = None + if '=' in env: key, value = env.split('=', 1) else: - key = env - if re.search(r'\s', key): - raise ConfigurationError( - "environment variable name '{}' may not contain whitespace.".format(key) - ) - return key, value - + return env, None def env_vars_from_file(filename): """ diff --git a/tests/unit/config/environment_test.py b/tests/unit/config/environment_test.py index 88eb0d6e11a..66e1eb123bc 100644 --- a/tests/unit/config/environment_test.py +++ b/tests/unit/config/environment_test.py @@ -53,12 +53,3 @@ def test_env_vars_from_file_bom(self): assert env_vars_from_file(str(tmpdir.join('bom.env'))) == { 'PARK_BOM': '박봄' } - - def test_env_vars_from_file_whitespace(self): - tmpdir = pytest.ensuretemp('env_file') - self.addCleanup(tmpdir.remove) - with codecs.open('{}/whitespace.env'.format(str(tmpdir)), 'w', encoding='utf-8') as f: - f.write('WHITESPACE =yes\n') - with pytest.raises(ConfigurationError) as exc: - env_vars_from_file(str(tmpdir.join('whitespace.env'))) - assert 'environment variable' in exc.exconly()