Skip to content

Commit 02cd108

Browse files
author
Steven Silvester
authored
Merge pull request #79 from afshin/error-output
Fix handling of error output
2 parents 10362d7 + f281c7a commit 02cd108

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

jupyter_releaser/lib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ def publish_assets(dist_dir, npm_token, npm_cmd, twine_cmd, dry_run, use_checkou
384384
try:
385385
util.run(f"{npm_cmd} {name}", cwd=dist_dir, quiet=True)
386386
except CalledProcessError as e:
387-
stderr = e.stderr.decode("utf-8")
387+
stderr = e.stderr
388388
if (
389389
"EPUBLISHCONFLICT" in stderr
390390
or "previously published versions" in stderr

jupyter_releaser/tests/test_cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ def wrapped(cmd, **kwargs):
530530
called += 1
531531
if called == 0:
532532
err = CalledProcessError(1, "foo")
533-
err.stderr = "EPUBLISHCONFLICT".encode("UTF-8")
533+
err.stderr = "EPUBLISHCONFLICT"
534534
raise err
535535

536536
mock_run = mocker.patch("jupyter_releaser.util.run", wraps=wrapped)
@@ -559,7 +559,7 @@ def wrapped(cmd, **kwargs):
559559
if cmd.startswith("npm publish --dry-run"):
560560
called += 1
561561
err = CalledProcessError(1, "foo")
562-
err.stderr = "previously published versions".encode("UTF-8")
562+
err.stderr = "previously published versions"
563563
raise err
564564

565565
mocker.patch("jupyter_releaser.util.run", wraps=wrapped)

jupyter_releaser/util.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@ def _run_win(cmd, **kwargs):
8282
log(output)
8383
return output
8484
except CalledProcessError as e:
85+
e.output = e.output.decode("utf-8")
8586
if quiet:
86-
log("stderr:\n", e.stderr.decode("utf-8").strip(), "\n\n")
87-
log("stdout:\n", e.output.decode("utf-8").strip(), "\n\n")
87+
e.stderr = e.stderr.decode("utf-8")
88+
log("stderr:\n", e.stderr.strip(), "\n\n")
89+
log("stdout:\n", e.output.strip(), "\n\n")
8890
raise e
8991

9092

0 commit comments

Comments
 (0)