@@ -530,12 +530,15 @@ def ppaged(self, msg: Any, *, end: str = '\n', chop: bool = False) -> None:
530530
531531 WARNING: On Windows, the text always wraps regardless of what the chop argument is set to
532532 """
533- import subprocess
534- if not msg :
533+ # msg can be any type, so convert to string before checking if it's blank
534+ msg_str = str (msg )
535+
536+ # Consider None to be no data to print
537+ if msg is None or msg_str == '' :
535538 return
536539
537540 try :
538- msg_str = '{}{}' . format ( msg , end )
541+ import subprocess
539542
540543 # Attempt to detect if we are not running within a fully functional terminal.
541544 # Don't try to use the pager when being run by a continuous integration system like Jenkins + pexpect.
@@ -550,6 +553,7 @@ def ppaged(self, msg: Any, *, end: str = '\n', chop: bool = False) -> None:
550553 if functional_terminal and not self ._redirecting and not self .in_pyscript () and not self .in_script ():
551554 if ansi .allow_ansi .lower () == ansi .ANSI_NEVER .lower ():
552555 msg_str = ansi .strip_ansi (msg_str )
556+ msg_str += end
553557
554558 pager = self .pager
555559 if chop :
@@ -561,7 +565,7 @@ def ppaged(self, msg: Any, *, end: str = '\n', chop: bool = False) -> None:
561565 pipe_proc = subprocess .Popen (pager , shell = True , stdin = subprocess .PIPE )
562566 pipe_proc .communicate (msg_str .encode ('utf-8' , 'replace' ))
563567 else :
564- self .poutput (msg_str , end = '' )
568+ self .poutput (msg_str , end = end )
565569 except BrokenPipeError :
566570 # This occurs if a command's output is being piped to another process and that process closes before the
567571 # command is finished. If you would like your application to print a warning message, then set the
0 commit comments