Skip to content

Commit 3eab9b9

Browse files
LEEMINJOOhanouticelina
authored andcommitted
Fix: Restore sys.stdout in notebook_login after error (#2896)
1 parent 203eec8 commit 3eab9b9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/huggingface_hub/utils/_subprocess.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ def capture_output() -> Generator[StringIO, None, None]:
4444
output = StringIO()
4545
previous_output = sys.stdout
4646
sys.stdout = output
47-
yield output
48-
sys.stdout = previous_output
47+
try:
48+
yield output
49+
finally:
50+
sys.stdout = previous_output
4951

5052

5153
def run_subprocess(

0 commit comments

Comments
 (0)