Skip to content

Commit f0c5867

Browse files
authored
sphinx.util.logging: Make write() methods return int
1 parent 5461707 commit f0c5867

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

sphinx/util/logging.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -583,13 +583,13 @@ def __init__(self, stream: IO[str]) -> None:
583583
self.stream = stream
584584
self.encoding = getattr(stream, 'encoding', 'ascii') or 'ascii'
585585

586-
def write(self, data: str) -> None:
586+
def write(self, data: str) -> int:
587587
try:
588-
self.stream.write(data)
588+
return self.stream.write(data)
589589
except UnicodeEncodeError:
590590
# stream accept only str, not bytes. So, we encode and replace
591591
# non-encodable characters, then decode them.
592-
self.stream.write(
592+
return self.stream.write(
593593
data.encode(self.encoding, 'replace').decode(self.encoding)
594594
)
595595

@@ -604,8 +604,9 @@ class LastMessagesWriter:
604604
def __init__(self, app: Sphinx, stream: IO[str]) -> None:
605605
self.app = app
606606

607-
def write(self, data: str) -> None:
607+
def write(self, data: str) -> int:
608608
self.app.messagelog.append(data)
609+
return len(data)
609610

610611

611612
def setup(app: Sphinx, status: IO[str], warning: IO[str]) -> None:

0 commit comments

Comments
 (0)