mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 19:34:08 +00:00 
			
		
		
		
	Fix bug
[ 676342 ] after using pdb readline does not work correctly using Michael Stone's patch so the completer functionality of cmd is only setup between preloop and postloop.
This commit is contained in:
		
							parent
							
								
									c064a1d7e3
								
							
						
					
					
						commit
						35a92ce9da
					
				
					 1 changed files with 15 additions and 9 deletions
				
			
		
							
								
								
									
										24
									
								
								Lib/cmd.py
									
										
									
									
									
								
							
							
						
						
									
										24
									
								
								Lib/cmd.py
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -86,13 +86,7 @@ class Cmd:
 | 
			
		|||
 | 
			
		||||
        """
 | 
			
		||||
        self.cmdqueue = []
 | 
			
		||||
        if completekey:
 | 
			
		||||
            try:
 | 
			
		||||
                import readline
 | 
			
		||||
                readline.set_completer(self.complete)
 | 
			
		||||
                readline.parse_and_bind(completekey+": complete")
 | 
			
		||||
            except ImportError:
 | 
			
		||||
                pass
 | 
			
		||||
        self.completekey = completekey
 | 
			
		||||
 | 
			
		||||
    def cmdloop(self, intro=None):
 | 
			
		||||
        """Repeatedly issue a prompt, accept input, parse an initial prefix
 | 
			
		||||
| 
						 | 
				
			
			@ -142,14 +136,26 @@ class Cmd:
 | 
			
		|||
 | 
			
		||||
    def preloop(self):
 | 
			
		||||
        """Hook method executed once when the cmdloop() method is called."""
 | 
			
		||||
        pass
 | 
			
		||||
        if self.completekey:
 | 
			
		||||
            try:
 | 
			
		||||
                import readline
 | 
			
		||||
                self.old_completer = readline.get_completer()
 | 
			
		||||
                readline.set_completer(self.complete)
 | 
			
		||||
                readline.parse_and_bind(self.completekey+": complete")
 | 
			
		||||
            except ImportError:
 | 
			
		||||
                pass
 | 
			
		||||
 | 
			
		||||
    def postloop(self):
 | 
			
		||||
        """Hook method executed once when the cmdloop() method is about to
 | 
			
		||||
        return.
 | 
			
		||||
 | 
			
		||||
        """
 | 
			
		||||
        pass
 | 
			
		||||
        if self.completekey:
 | 
			
		||||
            try:
 | 
			
		||||
                import readline
 | 
			
		||||
                readline.set_completer(self.old_completer)
 | 
			
		||||
            except ImportError:
 | 
			
		||||
                pass
 | 
			
		||||
 | 
			
		||||
    def parseline(self, line):
 | 
			
		||||
        line = line.strip()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue