Skip to content

Commit f6b69cf

Browse files
committed
Allow settings.toml to end without a newline
1 parent 4dbbfa0 commit f6b69cf

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

shared-module/os/getenv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ STATIC os_getenv_err_t read_string_value(file_arg *active_file, vstr_t *buf) {
201201
case '#':
202202
next_line(active_file);
203203
MP_FALLTHROUGH;
204+
case 0:
204205
case '\n':
205206
return GETENV_OK;
206207
default:
@@ -257,7 +258,6 @@ STATIC os_getenv_err_t read_bare_value(file_arg *active_file, vstr_t *buf, int f
257258
while (true) {
258259
switch (character) {
259260
case 0:
260-
return GETENV_ERR_UNEXPECTED | character;
261261
case '\n':
262262
return GETENV_OK;
263263
case '#':

tests/circuitpython/getenv.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,8 @@ def run_test(key, content):
7575
for i in range(13):
7676
run_test(f"key{i}", content_good)
7777

78+
# Test value without trailing newline
79+
run_test(f"noeol", "noeol=3")
80+
7881
for content in content_bad:
7982
run_test("key", content)

tests/circuitpython/getenv.py.exp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ key9 'hello comment'
1111
key10 127
1212
key11 0
1313
key12 None
14+
noeol 3
1415
key Invalid byte '\n'
1516
key Invalid byte '"'
1617
key invalid syntax for integer with base 10: ''

0 commit comments

Comments
 (0)