Skip to content

dotenv: minor difference from standard package #6661

@jepler

Description

@jepler

CircuitPython version

Adafruit CircuitPython 8.0.0-alpha.1-75-gfed3f9c97-dirty on 2022-07-27; Raspberry Pi Pico with rp2040

Code/REPL

import dotenv

for i in range(0, 11):
    key = f"env_test_{i}"
    value = dotenv.get_key("env_test", key)
    print(i, key, repr(value))

Behavior

compared to running on cpython with python-dotenv installed, the variables env_test_8 and env_test_9 get incorrect values due to a bug in parsing

Description

You also have to put the following file as env_test next to the test program. Note that some lines end with whitespace: env_test.txt

In the below code block (DO NOT COPY AND PASTE IT,, use the downloadable env_test.txt file above) a "$" is displayed at the actual end of each line to make the whitespace clearer:

env_test_1=hi mom $
env_test_2=hi mom #$
env_test_3='hi mom' $
env_test_4='hi mom' #$
env_test_5$
env_test_6=$
env_test_7=#$
env_test_8= $
env_test_9= #$
env_test_10=first$
env_test_10=last$

It appears that the line env_test_8= (no content, ends with space) is parsed incorrectly, consuming the next line. This causes env_test_9 not to be found as a key.

Additional information

No response

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions