Skip to content

Commit

Permalink
output.py: consistently use sys.__stderr__
Browse files Browse the repository at this point in the history
sys.stderr is sometimes temporarily replaced by other objects, thus rely
on sys.__stdserr__ consistently. Also provide a default for `fd` in
`init_curses()`.
  • Loading branch information
gerstner-hub committed Jun 18, 2024
1 parent 931c4d0 commit 8d698e0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/portage/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def init_xterm_titles():
try:
# by default check if we can dynamically query the proper title
# setting sequence via terminfo
curses = init_curses(sys.stderr)
curses = init_curses()

if curses is not None:
tsl = curses.tigetstr("tsl").decode()
Expand Down Expand Up @@ -334,7 +334,7 @@ def xtermTitle(mystr, raw=False):
mystr = _unicode_encode(
mystr, encoding=_encodings["stdio"], errors="backslashreplace"
)
f = sys.stderr.buffer
f = sys.__stderr__.buffer
f.write(mystr)
f.flush()

Expand Down Expand Up @@ -547,7 +547,7 @@ def new_styles(self, styles):
self.style_listener(styles)


def init_curses(fd):
def init_curses(fd=sys.__stderr__):
try:
import curses

Expand Down

0 comments on commit 8d698e0

Please sign in to comment.