Skip to content

Commit 6712bc8

Browse files
elbehery95bbc2
authored andcommitted
fix interpolation order
add interpolation order test
1 parent d83c1b6 commit 6712bc8

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
99

10-
*No unreleased change at this time.*
10+
### Fixed
11+
12+
- Privilege definition in file over the environment in variable expansion (#256 by
13+
[@elbehery95]).
1114

1215
## [0.13.0] - 2020-04-16
1316

@@ -197,6 +200,7 @@ project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
197200
[@ulyssessouza]: https://github.com/ulyssessouza
198201
[@venthur]: https://github.com/venthur
199202
[@yannham]: https://github.com/yannham
203+
[@elbehery95]: https://github.com/elbehery95
200204

201205
[Unreleased]: https://github.com/theskumar/python-dotenv/compare/v0.13.0...HEAD
202206
[0.13.0]: https://github.com/theskumar/python-dotenv/compare/v0.12.0...v0.13.0

src/dotenv/main.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,8 @@ def resolve_nested_variables(values):
214214
# type: (Dict[Text, Optional[Text]]) -> Dict[Text, Optional[Text]]
215215
def _replacement(name, default):
216216
# type: (Text, Optional[Text]) -> Text
217-
"""
218-
get appropriate value for a variable name.
219-
first search in environ, if not found,
220-
then look into the dotenv variables
221-
"""
222217
default = default if default is not None else ""
223-
ret = os.getenv(name, new_values.get(name, default))
218+
ret = new_values.get(name, os.getenv(name, default))
224219
return ret # type: ignore
225220

226221
def _re_sub_callback(match):

tests/test_main.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,9 @@ def test_dotenv_values_file(dotenv_file):
334334
335335
# Reused
336336
({"b": "c"}, "a=${b}${b}", True, {"a": "cc"}),
337+
338+
# Re-defined and used in file
339+
({"b": "c"}, "b=d\na=${b}", True, {"a": "d", "b": "d"}),
337340
],
338341
)
339342
def test_dotenv_values_stream(env, string, interpolate, expected):

0 commit comments

Comments
 (0)