Skip to content

Commit 85e6cd4

Browse files
authored
Add a None check for exc.stdout. (#21)
Fixes #15.
1 parent ea8bc06 commit 85e6cd4

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/stack_pr/cli.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,16 @@ def push_branches(st: List[StackEntry], remote):
579579

580580

581581
def print_cmd_failure_details(exc: SubprocessError):
582-
cmd_stdout = exc.stdout.decode("utf-8").replace("\\n", "\n").replace("\\t", "\t")
583-
cmd_stderr = exc.stderr.decode("utf-8").replace("\\n", "\n").replace("\\t", "\t")
582+
cmd_stdout = (
583+
exc.stdout.decode("utf-8").replace("\\n", "\n").replace("\\t", "\t")
584+
if exc.stdout
585+
else None
586+
)
587+
cmd_stderr = (
588+
exc.stderr.decode("utf-8").replace("\\n", "\n").replace("\\t", "\t")
589+
if exc.stderr
590+
else None
591+
)
584592
print(f"Exitcode: {exc.returncode}")
585593
print(f"Stdout: {cmd_stdout}")
586594
print(f"Stderr: {cmd_stderr}")
@@ -760,7 +768,9 @@ def deduce_base(args: CommonArgs) -> CommonArgs:
760768
deduced_base = get_command_output(
761769
["git", "merge-base", args.head, f"{args.remote}/{args.target}"]
762770
)
763-
return CommonArgs(deduced_base, args.head, args.remote, args.target, args.hyperlinks)
771+
return CommonArgs(
772+
deduced_base, args.head, args.remote, args.target, args.hyperlinks
773+
)
764774

765775

766776
def print_tips_after_export(st: List[StackEntry], args: CommonArgs):
@@ -1144,7 +1154,10 @@ def create_argparser() -> argparse.ArgumentParser:
11441154
"-T", "--target", default="main", help="Remote target branch"
11451155
)
11461156
common_parser.add_argument(
1147-
"--hyperlinks", action=argparse.BooleanOptionalAction, default=True, help="Enable or disable hyperlink support."
1157+
"--hyperlinks",
1158+
action=argparse.BooleanOptionalAction,
1159+
default=True,
1160+
help="Enable or disable hyperlink support.",
11481161
)
11491162

11501163
parser_submit = subparsers.add_parser(

0 commit comments

Comments
 (0)