mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Remove "disgusting hack" in favour of closure (patch #1462235)
This commit is contained in:
		
							parent
							
								
									c5ffd91911
								
							
						
					
					
						commit
						4696ffbf09
					
				
					 1 changed files with 2 additions and 5 deletions
				
			
		|  | @ -449,18 +449,15 @@ def after(self, ms, func=None, *args): | ||||||
|             # I'd rather use time.sleep(ms*0.001) |             # I'd rather use time.sleep(ms*0.001) | ||||||
|             self.tk.call('after', ms) |             self.tk.call('after', ms) | ||||||
|         else: |         else: | ||||||
|             # XXX Disgusting hack to clean up after calling func |             def callit(): | ||||||
|             tmp = [] |  | ||||||
|             def callit(func=func, args=args, self=self, tmp=tmp): |  | ||||||
|                 try: |                 try: | ||||||
|                     func(*args) |                     func(*args) | ||||||
|                 finally: |                 finally: | ||||||
|                     try: |                     try: | ||||||
|                         self.deletecommand(tmp[0]) |                         self.deletecommand(name) | ||||||
|                     except TclError: |                     except TclError: | ||||||
|                         pass |                         pass | ||||||
|             name = self._register(callit) |             name = self._register(callit) | ||||||
|             tmp.append(name) |  | ||||||
|             return self.tk.call('after', ms, name) |             return self.tk.call('after', ms, name) | ||||||
|     def after_idle(self, func, *args): |     def after_idle(self, func, *args): | ||||||
|         """Call FUNC once if the Tcl main loop has no event to |         """Call FUNC once if the Tcl main loop has no event to | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Georg Brandl
						Georg Brandl