Issue with sys.Argv (BETA 160033)
wradcliffe last edited by wradcliffe
When running a script - clipboard.get() appears to be returning the full path to the current file opened in the editor instead of the contents of the clipboard. It also seems to cause a "cut" operation to be performed in the editor.
Note - clipboard.get() issued from the interactive prompt work fine. Running a script and using the function from a script shows the problem.
Note - I know the FileDownloader script was running fine in the release before BETA 160033
REPRO - switch out of Pythonista and copy a URL into the clipboard. Switch back and load the FileDownloader script and run it. You should see the path to the source code in the editor instead of the URL. Cancel the dialog box and see that the editor window is now empty. Switch over to the console again and execute "print clipboard.get() and the source code for the script should be displayed. For reference - here is the code for FileDownloader I am using (some slight mods from the original).
omz last edited by omz
Thanks! The problem doesn't seem to be with
sys.argv. For some reason, it contains the script path twice instead of just once, and the File Downloader blindly treats the second argument as a URL to download (without checking that it actually is a URL). Since it uses the last part of the URL's path as the destination filename, the current script gets overwritten by empty data (because downloading the "URL" fails of course)...
I don't know exactly why the argument is doubled right now, but it seems like this should be easy to fix. It's probably a bug that slipped through when I changed the way globals are cleared.
wradcliffe last edited by
Now it makes sense. I was also seeing issues with other scripts but without the apparent data loss issue and jumped to the wrong conclusion. Glad you were able to repro it easily and figure it out.