mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	bpo-42508: Keep IDLE running on macOS (GH-23577) (GH-23669)
Remove obsolete workaround that prevented running files with
shortcuts when using new universal2 installers built on macOS 11.
Ignore buggy 2nd run_module_event call.
(cherry picked from commit 57e5113610)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
			
			
This commit is contained in:
		
							parent
							
								
									8502d46e36
								
							
						
					
					
						commit
						2a9a883d36
					
				
					 3 changed files with 14 additions and 19 deletions
				
			
		|  | @ -3,6 +3,10 @@ Released on 2020-12-07? | ||||||
| ====================================== | ====================================== | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | bpo-42508: Keep IDLE running on macOS.  Remove obsolete workaround | ||||||
|  | that prevented running files with shortcuts when using new universal2 | ||||||
|  | installers built on macOS 11. | ||||||
|  | 
 | ||||||
| bpo-42426: Fix reporting offset of the RE error in searchengine. | bpo-42426: Fix reporting offset of the RE error in searchengine. | ||||||
| 
 | 
 | ||||||
| bpo-42416: Get docstrings for IDLE calltips more often | bpo-42416: Get docstrings for IDLE calltips more often | ||||||
|  |  | ||||||
|  | @ -11,6 +11,7 @@ | ||||||
| """ | """ | ||||||
| import os | import os | ||||||
| import tabnanny | import tabnanny | ||||||
|  | import time | ||||||
| import tokenize | import tokenize | ||||||
| 
 | 
 | ||||||
| import tkinter.messagebox as tkMessageBox | import tkinter.messagebox as tkMessageBox | ||||||
|  | @ -42,9 +43,7 @@ def __init__(self, editwin): | ||||||
|         self.root = self.editwin.root |         self.root = self.editwin.root | ||||||
|         # cli_args is list of strings that extends sys.argv |         # cli_args is list of strings that extends sys.argv | ||||||
|         self.cli_args = [] |         self.cli_args = [] | ||||||
| 
 |         self.perf = 0.0    # Workaround for macOS 11 Uni2; see bpo-42508. | ||||||
|         if macosx.isCocoaTk(): |  | ||||||
|             self.editwin.text_frame.bind('<<run-module-event-2>>', self._run_module_event) |  | ||||||
| 
 | 
 | ||||||
|     def check_module_event(self, event): |     def check_module_event(self, event): | ||||||
|         if isinstance(self.editwin, outwin.OutputWindow): |         if isinstance(self.editwin, outwin.OutputWindow): | ||||||
|  | @ -107,24 +106,10 @@ def checksyntax(self, filename): | ||||||
|         finally: |         finally: | ||||||
|             shell.set_warning_stream(saved_stream) |             shell.set_warning_stream(saved_stream) | ||||||
| 
 | 
 | ||||||
|     def run_module_event(self, event): |  | ||||||
|         if macosx.isCocoaTk(): |  | ||||||
|             # Tk-Cocoa in MacOSX is broken until at least |  | ||||||
|             # Tk 8.5.9, and without this rather |  | ||||||
|             # crude workaround IDLE would hang when a user |  | ||||||
|             # tries to run a module using the keyboard shortcut |  | ||||||
|             # (the menu item works fine). |  | ||||||
|             self.editwin.text_frame.after(200, |  | ||||||
|                 lambda: self.editwin.text_frame.event_generate( |  | ||||||
|                         '<<run-module-event-2>>')) |  | ||||||
|             return 'break' |  | ||||||
|         else: |  | ||||||
|             return self._run_module_event(event) |  | ||||||
| 
 |  | ||||||
|     def run_custom_event(self, event): |     def run_custom_event(self, event): | ||||||
|         return self._run_module_event(event, customize=True) |         return self.run_module_event(event, customize=True) | ||||||
| 
 | 
 | ||||||
|     def _run_module_event(self, event, *, customize=False): |     def run_module_event(self, event, *, customize=False): | ||||||
|         """Run the module after setting up the environment. |         """Run the module after setting up the environment. | ||||||
| 
 | 
 | ||||||
|         First check the syntax.  Next get customization.  If OK, make |         First check the syntax.  Next get customization.  If OK, make | ||||||
|  | @ -133,6 +118,8 @@ def _run_module_event(self, event, *, customize=False): | ||||||
|         module being executed and also add that directory to its |         module being executed and also add that directory to its | ||||||
|         sys.path if not already included. |         sys.path if not already included. | ||||||
|         """ |         """ | ||||||
|  |         if macosx.isCocoaTk() and (time.perf_counter() - self.perf < .05): | ||||||
|  |             return 'break' | ||||||
|         if isinstance(self.editwin, outwin.OutputWindow): |         if isinstance(self.editwin, outwin.OutputWindow): | ||||||
|             self.editwin.text.bell() |             self.editwin.text.bell() | ||||||
|             return 'break' |             return 'break' | ||||||
|  | @ -218,6 +205,7 @@ def errorbox(self, title, message): | ||||||
|         # XXX This should really be a function of EditorWindow... |         # XXX This should really be a function of EditorWindow... | ||||||
|         tkMessageBox.showerror(title, message, parent=self.editwin.text) |         tkMessageBox.showerror(title, message, parent=self.editwin.text) | ||||||
|         self.editwin.text.focus_set() |         self.editwin.text.focus_set() | ||||||
|  |         self.perf = time.perf_counter() | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||||
|  |  | ||||||
|  | @ -0,0 +1,3 @@ | ||||||
|  | Keep IDLE running on macOS.  Remove obsolete workaround that prevented | ||||||
|  | running files with shortcuts when using new universal2 installers built | ||||||
|  | on macOS 11. | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Miss Islington (bot)
						Miss Islington (bot)