Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thonny encounters "internal error" in programs calling exit() #966

Closed
Phoemuex opened this issue Oct 27, 2019 · 6 comments
Closed

Thonny encounters "internal error" in programs calling exit() #966

Phoemuex opened this issue Oct 27, 2019 · 6 comments
Milestone

Comments

@Phoemuex
Copy link

I am running Thonny 3.2.1 on Windows 8.1 (64 bit), using Python 3.7.4 (32 bit) and Tk 8.6.9 (downloaded and installed the bundle from the website).

I have a curious issue regarding programs that call exit(). These work fine usually, but in connection with importing tkinter, they seem to cause issues.

Consider the following two-line program

import tkinter
exit()

Saving this program as "test.py" and running it (via F5) causes Thonny to display the following "internal error":

Traceback (most recent call last):
  File "C:\Users\Felix\AppData\Local\Programs\Thonny\lib\tkinter\__init__.py", line 1705, in __call__
    return self.func(*args)
  File "C:\Users\Felix\AppData\Local\Programs\Thonny\lib\tkinter\__init__.py", line 749, in callit
    func(*args)
  File "C:\Users\Felix\AppData\Local\Programs\Thonny\lib\site-packages\thonny\running.py", line 432, in _poll_vm_messages
    if self._pull_vm_messages() is False:
  File "C:\Users\Felix\AppData\Local\Programs\Thonny\lib\site-packages\thonny\running.py", line 440, in _pull_vm_messages
    msg = self._proxy.fetch_next_message()
  File "C:\Users\Felix\AppData\Local\Programs\Thonny\lib\site-packages\thonny\running.py", line 1141, in fetch_next_message
    msg = super().fetch_next_message()
  File "C:\Users\Felix\AppData\Local\Programs\Thonny\lib\site-packages\thonny\running.py", line 942, in fetch_next_message
    self._store_state_info(msg)
  File "C:\Users\Felix\AppData\Local\Programs\Thonny\lib\site-packages\thonny\running.py", line 988, in _store_state_info
    self._update_gui_updating(msg)
  File "C:\Users\Felix\AppData\Local\Programs\Thonny\lib\site-packages\thonny\running.py", line 1015, in _update_gui_updating
    self._loop_gui_update(True)
  File "C:\Users\Felix\AppData\Local\Programs\Thonny\lib\site-packages\thonny\running.py", line 1021, in _loop_gui_update
    self.send_command(InlineCommand("process_gui_events"))
  File "C:\Users\Felix\AppData\Local\Programs\Thonny\lib\site-packages\thonny\running.py", line 791, in send_command
    self._send_msg(cmd)
  File "C:\Users\Felix\AppData\Local\Programs\Thonny\lib\site-packages\thonny\running.py", line 795, in _send_msg
    self._proc.stdin.flush()
OSError: [Errno 22] Invalid argument

NOTE: The same does not happen if one omits the import tkinter!

NOTE 2: This error is not completely reproducible, sometimes the program finishes without the internal error, but at least after running the program three times in a row, I have until now ALWAYS been able to reproduce the problem, in ~15 tries.

@aivarannamaa aivarannamaa added this to the 3.2.2 milestone Oct 30, 2019
@aivarannamaa
Copy link
Member

Thank you for the report!

I was able to reproduce it only once (in about 30 trials), but I think I found the solution. Please open the issue again if it persists in upcoming Thonny 3.2.2

@LordzShadow
Copy link

This issue seems to persist in Thonny 4.0.0

running exit() the program does not end and clicking on the shell window and pressing enter, Thonny crashes.

Traceback (most recent call last):
  File "C:\Program Files (x86)\Thonny\lib\tkinter\__init__.py", line 1921, in __call__
    return self.func(*args)
  File "C:\Program Files (x86)\Thonny\lib\site-packages\thonny\tktextext.py", line 243, in dispatch
    return fun(event)
  File "C:\Program Files (x86)\Thonny\lib\site-packages\thonny\shell.py", line 1012, in perform_return
    EnhancedTextWithLogging.perform_return(self, event)
  File "C:\Program Files (x86)\Thonny\lib\site-packages\thonny\tktextext.py", line 468, in perform_return
    self.insert("insert", "\n")
  File "C:\Program Files (x86)\Thonny\lib\site-packages\thonny\shell.py", line 974, in intercept_insert
    self._try_submit_input()
  File "C:\Program Files (x86)\Thonny\lib\site-packages\thonny\shell.py", line 1163, in _try_submit_input
    self._submit_input(submittable_text)
  File "C:\Program Files (x86)\Thonny\lib\site-packages\thonny\shell.py", line 1320, in _submit_input
    get_runner().send_program_input(text_to_be_submitted)
  File "C:\Program Files (x86)\Thonny\lib\site-packages\thonny\running.py", line 309, in send_program_input
    self._proxy.send_program_input(data)
  File "C:\Program Files (x86)\Thonny\lib\site-packages\thonny\running.py", line 1057, in send_program_input
    self._send_msg(InputSubmission(data))
  File "C:\Program Files (x86)\Thonny\lib\site-packages\thonny\running.py", line 1050, in _send_msg
    self._proc.stdin.write(serialize_message(msg) + "\n")
OSError: [Errno 22] Invalid argument

image

@aivarannamaa aivarannamaa reopened this Sep 1, 2022
@aivarannamaa
Copy link
Member

Thanks for reporting this! I'll try to fix it for Thonny 4.0.1

@aivarannamaa aivarannamaa modified the milestones: 3.2.2, 4.0.1 Sep 1, 2022
@aivarannamaa
Copy link
Member

Fixed under #2433.

@vandega
Copy link

vandega commented Nov 8, 2022

this error goes in 4.0.1. after easy code.

python 3.11.0 stabile
windows 11.
CPU: AMD x64

this error goes every time, even if I write print('hello world!).
error about def function. no matter if i use def name (*val) or def name (val) error same. answer goes correct in simple codes but error still popup.

Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Thonny\lib\tkinter\__init__.py", line 1921, in __call__
    return self.func(*args)
  File "C:\Users\User\AppData\Local\Programs\Thonny\lib\tkinter\__init__.py", line 839, in callit
    func(*args)
  File "C:\Users\User\AppData\Local\Programs\Thonny\lib\site-packages\thonny\ui_utils.py", line 2244, in poll
    on_completion(proc, out_lines, err_lines)
  File "C:\Users\User\AppData\Local\Programs\Thonny\lib\site-packages\thonny\plugins\mypy\__init__.py", line 110, in _parse_and_output_warnings
    logging.error("Can't parse MyPy line: " + line.strip())
NameError: name 'logging' is not defined
```

`

@aivarannamaa
Copy link
Member

@vandega, this was fixed in #2491 and the fix will be available in the next version. In the meantime you can get rid of this error by going to "Tools => Options => Assistant" and unchecking "Perform MyPy checks".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants