comparison mercurial/ui.py @ 27110:f04bd381e8c0

ui: avoid needless casting to a str In many cases, we don't need to cast to a str because the object will be cast when it is eventually written. As part of testing this, I added some code to raise exceptions when a non-str was passed in and wasn't able to trigger it. i.e. we're already passing str into this function everywhere, so the casting isn't necessary.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 22 Nov 2015 14:44:55 -0800
parents a93d53f79e6e
children 3553e40d0770
comparison
equal deleted inserted replaced
27109:a93d53f79e6e 27110:f04bd381e8c0
620 When labeling output for a specific command, a label of 620 When labeling output for a specific command, a label of
621 "cmdname.type" is recommended. For example, status issues 621 "cmdname.type" is recommended. For example, status issues
622 a label of "status.modified" for modified files. 622 a label of "status.modified" for modified files.
623 ''' 623 '''
624 if self._buffers: 624 if self._buffers:
625 self._buffers[-1].extend([str(a) for a in args]) 625 self._buffers[-1].extend(a for a in args)
626 else: 626 else:
627 self._progclear() 627 self._progclear()
628 for a in args: 628 for a in args:
629 self.fout.write(str(a)) 629 self.fout.write(a)
630 630
631 def write_err(self, *args, **opts): 631 def write_err(self, *args, **opts):
632 self._progclear() 632 self._progclear()
633 try: 633 try:
634 if self._bufferstates and self._bufferstates[-1][0]: 634 if self._bufferstates and self._bufferstates[-1][0]:
635 return self.write(*args, **opts) 635 return self.write(*args, **opts)
636 if not getattr(self.fout, 'closed', False): 636 if not getattr(self.fout, 'closed', False):
637 self.fout.flush() 637 self.fout.flush()
638 for a in args: 638 for a in args:
639 self.ferr.write(str(a)) 639 self.ferr.write(a)
640 # stderr may be buffered under win32 when redirected to files, 640 # stderr may be buffered under win32 when redirected to files,
641 # including stdout. 641 # including stdout.
642 if not getattr(self.ferr, 'closed', False): 642 if not getattr(self.ferr, 'closed', False):
643 self.ferr.flush() 643 self.ferr.flush()
644 except IOError as inst: 644 except IOError as inst: