aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjuerg <juerg@google.com>2023-07-18 13:12:36 -0700
committerCopybara-Service <copybara-worker@google.com>2023-07-18 13:13:48 -0700
commit665da0e4f157e646ba072e4e2ca9b091268bc2b6 (patch)
tree05c54b8c5fddda481b65aecafc677a98b30da370
parent7b27a965546eb95d36dc1ff7d660a77c952f259d (diff)
downloadtink-665da0e4f157e646ba072e4e2ca9b091268bc2b6.tar.gz
Simplify remaining example in Python.
Register should always work, when it fails it's a bug, so it's better to not catch that exception. PiperOrigin-RevId: 549090205
-rw-r--r--python/examples/aead/aead.py6
-rw-r--r--python/examples/cleartext_keyset/cleartext_keyset.py6
-rw-r--r--python/examples/deterministic_aead/deterministic_aead.py6
-rw-r--r--python/examples/encrypted_keyset/encrypted_keyset.py6
-rw-r--r--python/examples/envelope_aead/envelope.py6
-rw-r--r--python/examples/gcs/gcs_envelope_aead.py6
-rw-r--r--python/examples/hybrid/hybrid.py6
-rw-r--r--python/examples/mac/mac.py6
-rw-r--r--python/examples/signature/signature.py6
9 files changed, 9 insertions, 45 deletions
diff --git a/python/examples/aead/aead.py b/python/examples/aead/aead.py
index 074806c99..ac7c18aec 100644
--- a/python/examples/aead/aead.py
+++ b/python/examples/aead/aead.py
@@ -45,11 +45,7 @@ def main(argv):
FLAGS.associated_data, 'utf-8')
# Initialise Tink
- try:
- aead.register()
- except tink.TinkError as e:
- logging.error('Error initialising Tink: %s', e)
- return 1
+ aead.register()
# Read the keyset into a keyset_handle
with open(FLAGS.keyset_path, 'rt') as keyset_file:
diff --git a/python/examples/cleartext_keyset/cleartext_keyset.py b/python/examples/cleartext_keyset/cleartext_keyset.py
index e80ad949c..e91d45ecc 100644
--- a/python/examples/cleartext_keyset/cleartext_keyset.py
+++ b/python/examples/cleartext_keyset/cleartext_keyset.py
@@ -40,11 +40,7 @@ def main(argv):
del argv # Unused.
# Initialise Tink
- try:
- aead.register()
- except tink.TinkError as e:
- logging.error('Error initialising Tink: %s', e)
- return 1
+ aead.register()
if FLAGS.mode == 'generate':
# [START generate-a-new-keyset]
diff --git a/python/examples/deterministic_aead/deterministic_aead.py b/python/examples/deterministic_aead/deterministic_aead.py
index c79b1143d..3b6612dba 100644
--- a/python/examples/deterministic_aead/deterministic_aead.py
+++ b/python/examples/deterministic_aead/deterministic_aead.py
@@ -45,11 +45,7 @@ def main(argv):
FLAGS.associated_data, 'utf-8')
# Initialise Tink
- try:
- daead.register()
- except tink.TinkError as e:
- logging.error('Error initialising Tink: %s', e)
- return 1
+ daead.register()
# Read the keyset into a keyset_handle
with open(FLAGS.keyset_path, 'rt') as keyset_file:
diff --git a/python/examples/encrypted_keyset/encrypted_keyset.py b/python/examples/encrypted_keyset/encrypted_keyset.py
index b64dc3b80..0871a8dea 100644
--- a/python/examples/encrypted_keyset/encrypted_keyset.py
+++ b/python/examples/encrypted_keyset/encrypted_keyset.py
@@ -47,11 +47,7 @@ def main(argv):
FLAGS.associated_data, 'utf-8')
# Initialise Tink
- try:
- aead.register()
- except tink.TinkError as e:
- logging.exception('Error initialising Tink: %s', e)
- return 1
+ aead.register()
try:
# Read the GCP credentials and setup client
diff --git a/python/examples/envelope_aead/envelope.py b/python/examples/envelope_aead/envelope.py
index fe00857b9..a5347b011 100644
--- a/python/examples/envelope_aead/envelope.py
+++ b/python/examples/envelope_aead/envelope.py
@@ -50,11 +50,7 @@ def main(argv):
)
# Initialise Tink
- try:
- aead.register()
- except tink.TinkError as e:
- logging.exception('Error initialising Tink: %s', e)
- return 1
+ aead.register()
try:
# Read the GCP credentials and setup client
diff --git a/python/examples/gcs/gcs_envelope_aead.py b/python/examples/gcs/gcs_envelope_aead.py
index 6e4ac3245..09245ef26 100644
--- a/python/examples/gcs/gcs_envelope_aead.py
+++ b/python/examples/gcs/gcs_envelope_aead.py
@@ -49,11 +49,7 @@ def main(argv):
del argv # Unused.
# Initialise Tink
- try:
- aead.register()
- except tink.TinkError as e:
- logging.exception('Error initialising Tink: %s', e)
- return 1
+ aead.register()
try:
# Read the GCP credentials and setup client
diff --git a/python/examples/hybrid/hybrid.py b/python/examples/hybrid/hybrid.py
index 24661e90d..f6c87331e 100644
--- a/python/examples/hybrid/hybrid.py
+++ b/python/examples/hybrid/hybrid.py
@@ -44,11 +44,7 @@ def main(argv):
FLAGS.context_info, 'utf-8')
# Initialise Tink
- try:
- hybrid.register()
- except tink.TinkError as e:
- logging.exception('Error initialising Tink: %s', e)
- return 1
+ hybrid.register()
# Read the keyset into a keyset_handle
with open(FLAGS.keyset_path, 'rt') as keyset_file:
diff --git a/python/examples/mac/mac.py b/python/examples/mac/mac.py
index 94de762fb..7fbf3a506 100644
--- a/python/examples/mac/mac.py
+++ b/python/examples/mac/mac.py
@@ -43,11 +43,7 @@ def main(argv):
del argv # Unused.
# Initialise Tink.
- try:
- mac.register()
- except tink.TinkError as e:
- logging.error('Error initialising Tink: %s', e)
- return 1
+ mac.register()
# Read the keyset into a keyset_handle.
with open(FLAGS.keyset_path, 'rt') as keyset_file:
diff --git a/python/examples/signature/signature.py b/python/examples/signature/signature.py
index bfa7d8256..75485d937 100644
--- a/python/examples/signature/signature.py
+++ b/python/examples/signature/signature.py
@@ -45,11 +45,7 @@ def main(argv):
del argv # Unused.
# Initialise Tink
- try:
- signature.register()
- except tink.TinkError as e:
- logging.exception('Error initialising Tink: %s', e)
- return 1
+ signature.register()
# Read the keyset into a keyset_handle
with open(FLAGS.keyset_path, 'rt') as keyset_file: