I could probably do it myself, though all I need is the column (as I already have the line), then I'd hook into the mp_obj_print_exception() and pull the faulty line directly from the file.
Anyway, I currently am trying to import cleanly my file. Right now I'm just putting the characters in the shell, but as you can see in the screenshot it makes the line number wrong. It also requires to put another newline if the script doesn't end with 0 indentation. I'd like that, when I type "import test", it imports all the text from test.py.
I defined mp_import_stat_t() in main.c to be the following:
Code: Select all
mp_import_stat_t mp_import_stat(const char *path) {
return MP_IMPORT_STAT_FILE;
}
Now, typing "import test" gives me an OSError 2 (which is normal, as it can't find the file). My question is: what is the function that actually reads from the file? I tried to follow the rabbit hole of pyexec_file() in lib/utils/pyexec.c but I got nowhere. Thanks in advance.