py5coding / py5generator

Meta-programming project that creates the py5 library code.
https://py5coding.org/
GNU General Public License v3.0
52 stars 13 forks source link

OSError exception triggered in split_setup.py while entering valid code to Python terminal on OSX #123

Closed hx2A closed 2 years ago

hx2A commented 2 years ago

Entering py5 code to the generic Python terminal is convenient on OSX. It says it can't find the source code for setup() but everything works just fine. and will throw an exception if setup() contains size(). The IPython REPL must take of this source code issue for users. This might not be fixable.

Found while testing the example code for #116

hx2A commented 2 years ago

So the code in split_setup.py is dependent on the Python standard library inspect and its ability to get a function's source code. This only works if it can find the code in a file. When I use the IPython REPL, it must save the user's input to temporary files somewhere so that inspect is able to access the source. When I enter the same code into the generic Python interpreter, inspect cannot get the code. This is just how inspect works and has nothing to do with py5. Therefore, users must define settings() when manually entering py5 code into the generic Python interpreter. There's nothing I can do to change this.

hx2A commented 2 years ago

It ls already mentioned in the documentation that the generic Python REPL doesn't save code to a file and therefore inspect won't be able to get the source code for setup():

If you happen to be manually typing code into the generic Python REPL, it won’t work.