Skip to content

Commit 021b919

Browse files
committed
cli: Always write utf-8
Apparently Python really likes to use cp1252 on some platforms but our bundles must not be platform specific. Signed-off-by: Jussi Kukkonen <[email protected]>
1 parent e7290c1 commit 021b919

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

sigstore/_cli.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -686,16 +686,16 @@ def _sign_file_threaded(
686686

687687
if outputs.signature is not None:
688688
signature = base64.b64encode(result.signature).decode()
689-
with outputs.signature.open(mode="w") as io:
689+
with outputs.signature.open(mode="w", encoding="utf-8") as io:
690690
print(signature, file=io)
691691

692692
if outputs.certificate is not None:
693693
cert_pem = signer._signing_cert().public_bytes(Encoding.PEM).decode()
694-
with outputs.certificate.open(mode="w") as io:
694+
with outputs.certificate.open(mode="w", encoding="utf-8") as io:
695695
print(cert_pem, file=io)
696696

697697
if outputs.bundle is not None:
698-
with outputs.bundle.open(mode="w") as io:
698+
with outputs.bundle.open(mode="w", encoding="utf-8") as io:
699699
print(result.to_json(), file=io)
700700

701701

@@ -769,7 +769,7 @@ def _attest(args: argparse.Namespace) -> None:
769769
_invalid_arguments(args, f"Predicate must be a file: {predicate_path}")
770770

771771
try:
772-
with open(predicate_path, "r") as f:
772+
with open(predicate_path, "r", encoding="utf-8") as f:
773773
predicate = json.load(f)
774774
# We do a basic sanity check using our Pydantic models to see if the
775775
# contents of the predicate file match the specified predicate type.

test/integration/cli/test_attest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def test_attest_success_default_output_bundle(
7373

7474
assert expected_output_bundle.exists()
7575
verifier = Verifier.staging()
76-
with open(expected_output_bundle, "r") as bundle_file:
76+
with open(expected_output_bundle, "r", encoding="utf-8") as bundle_file:
7777
bundle = Bundle.from_json(bundle_file.read())
7878
verifier.verify_dsse(bundle=bundle, policy=UnsafeNoOp())
7979

test/integration/cli/test_sign.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def test_sign_success_default_output_bundle(
7272
assert expected_output_bundle.exists()
7373
verifier = Verifier.staging()
7474
with (
75-
open(expected_output_bundle, "r") as bundle_file,
75+
open(expected_output_bundle, "r", encoding="utf-8") as bundle_file,
7676
open(artifact, "rb") as input_file,
7777
):
7878
bundle = Bundle.from_json(bundle_file.read())
@@ -112,7 +112,7 @@ def test_sign_success_multiple_artifacts(capsys, sigstore, asset_integration, tm
112112
assert expected_output_bundle.exists()
113113
verifier = Verifier.staging()
114114
with (
115-
open(expected_output_bundle, "r") as bundle_file,
115+
open(expected_output_bundle, "r", encoding="utf-8") as bundle_file,
116116
open(artifact, "rb") as input_file,
117117
):
118118
bundle = Bundle.from_json(bundle_file.read())
@@ -154,7 +154,7 @@ def test_sign_success_multiple_artifacts_rekor_v2(
154154
assert expected_output_bundle.exists()
155155
verifier = Verifier.staging()
156156
with (
157-
open(expected_output_bundle, "r") as bundle_file,
157+
open(expected_output_bundle, "r", encoding="utf-8") as bundle_file,
158158
open(artifact, "rb") as input_file,
159159
):
160160
bundle = Bundle.from_json(bundle_file.read())

0 commit comments

Comments
 (0)