← index #3223Issue #915
Off-topic · high · value 2.008
QUERY · ISSUE

Unix: initialisation of multi-line dict can report wrong line number for syntax error.

openby peterhinchopened 2017-07-19updated 2024-08-28

The following:

a = {
    'one' : 1,
    'two' : 2,
    'three' : 3,
    'four', 4  # error
    }

produces the following outcome:

MicroPython v1.8.7-893-g46b849a on 2017-06-22; linux version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> import rats35
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "rats35.py", line 2, in <module>
SyntaxError: expecting key:value for dict
>>> 
CANDIDATE · ISSUE

unix: Command line executed python ("./micropython -c") cannot contain newlines

closedby tomvonclefopened 2014-10-17updated 2014-10-17

There's an issue in unix/main.c (see line 362). Newlines in the string after the '-c' flag seem to cause syntax errors (At least in Debian 7.1 and bash 4.2.37).

image

$ ./micropython -c 'print("Hello World")
print("Hey")'
  File "<stdin>", line 2, column 1
SyntaxError: invalid syntax
$ 

I might find time to fix it this weekend.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied