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()