mirror of
				https://github.com/esphome/esphome.git
				synced 2025-11-04 09:01:49 +00:00 
			
		
		
		
	fix: only decode when not str already (#923)
Signed-off-by: wilmardo <info@wilmardenouden.nl>
This commit is contained in:
		
				
					committed by
					
						
						Guillermo Ruffino
					
				
			
			
				
	
			
			
			
						parent
						
							eea78531a1
						
					
				
				
					commit
					828e291538
				
			@@ -118,10 +118,11 @@ class RedirectText:
 | 
			
		||||
        # str
 | 
			
		||||
        # If the conversion fails, we will create an exception, which is okay because we won't
 | 
			
		||||
        # be able to print it anyway.
 | 
			
		||||
        text = s.decode()
 | 
			
		||||
        if not isinstance(s, str):
 | 
			
		||||
            s = s.decode()
 | 
			
		||||
 | 
			
		||||
        if self._filter_pattern is not None:
 | 
			
		||||
            self._line_buffer += text
 | 
			
		||||
            self._line_buffer += s
 | 
			
		||||
            lines = self._line_buffer.splitlines(True)
 | 
			
		||||
            for line in lines:
 | 
			
		||||
                if '\n' not in line and '\r' not in line:
 | 
			
		||||
@@ -138,7 +139,7 @@ class RedirectText:
 | 
			
		||||
 | 
			
		||||
                self._write_color_replace(line)
 | 
			
		||||
        else:
 | 
			
		||||
            self._write_color_replace(text)
 | 
			
		||||
            self._write_color_replace(s)
 | 
			
		||||
 | 
			
		||||
        # write() returns the number of characters written
 | 
			
		||||
        # Let's print the number of characters of the original string in order to not confuse
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user