Bug 399785 - Scripter errors if script file lacks .py extension
Summary: Scripter errors if script file lacks .py extension
Status: RESOLVED WORKSFORME
Alias: None
Product: krita
Classification: Applications
Component: Scripting (show other bugs)
Version: 4.1.5
Platform: Appimage Linux
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-14 11:05 UTC by noemie scherer
Modified: 2018-10-16 07:55 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
screenshot of the error message (35.10 KB, image/png)
2018-10-16 07:22 UTC, noemie scherer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description noemie scherer 2018-10-14 11:05:44 UTC
SUMMARY

When I save a script written in the Scripter with a filename that doesn't explicitly end with .py (even though the "files of type" field is "python file (*.py)"), the script doesn't run anymore but gives an error message.

STEPS TO REPRODUCE
1. open Tools > Scripts > Scripter
2. write print("test")
3. Save As "foo" (no .py extension)
4. run by clicking the arrow icon

OBSERVED RESULT

======================================

**********************
AttributeError: 'NoneType' object has no attribute 'loader'

In file: <frozen importlib._bootstrap>
In function: module_from_spec at line: 574. Line with error:

**********************


EXPECTED RESULT

test


SOFTWARE VERSIONS

Qt Version: 5.10.0
Python2: 2.7.15
Python3: 3.6.6
Comment 1 Halla Rempt 2018-10-14 15:52:20 UTC
Hi Noémie,

I'm wondering, why would you do that? The bit of backtrace you give is all in python, not in Krita's code. Could you also pass the full backtrace, not just a snippet?
Comment 2 noemie scherer 2018-10-14 19:40:36 UTC
Hi,
I'm not sure I understand your question so do ask again if I didn't answer it. Why did I call it "foo" and not "foo.py"? When you save an image in krita, you don't need to add the extension, it does so automatically; I didn't think about it and assumed python scripts worked the same. And when I got the error message (the one I put in "Observed result"), it didn't help me find what was wrong. I'm worried it might happen to other people too.
My bug report wasn't very clear, sorry; what I put in Observed Result (and in Expected Result as well) is the full result I got in the 'Output' section of the Scripter, I didn't remove any of it. The debugger remained empty. I also just ran it from terminal and it didn't print anything new when I saved without the file extension, nor when I ran it (and got the error in the Scripter Output). Please tell me if there is another way to get information that would be useful to you.
Comment 3 Halla Rempt 2018-10-16 06:55:04 UTC
If I save a file from the scripter plugin, it does automatically add the .py suffix.

In any case, I would like to see the full error: the bit that comes after 

In function: module_from_spec at line: 574. Line with error:
Comment 4 noemie scherer 2018-10-16 07:22:49 UTC
Created attachment 115672 [details]
screenshot of the error message
Comment 5 noemie scherer 2018-10-16 07:25:52 UTC
I guess it's just my computer then, it's not important to fix.
Like I said, I gave you the full result I saw in Output. See the file attached.
Comment 6 Halla Rempt 2018-10-16 07:55:45 UTC
Okay... Well, it's a bit weird, there definitely should have been more text :-). But I'll close this issue then.