|
74 | 74 |
|
75 | 75 | from tuf.api import exceptions
|
76 | 76 | from tuf.api.metadata import Metadata, Root, Snapshot, Targets, Timestamp
|
77 |
| -from tuf.api.serialization import DeserializationError |
78 | 77 |
|
79 | 78 | logger = logging.getLogger(__name__)
|
80 | 79 |
|
@@ -161,10 +160,7 @@ def update_root(self, data: bytes) -> Metadata[Root]:
|
161 | 160 | raise RuntimeError("Cannot update root after timestamp")
|
162 | 161 | logger.debug("Updating root")
|
163 | 162 |
|
164 |
| - try: |
165 |
| - new_root = Metadata[Root].from_bytes(data) |
166 |
| - except DeserializationError as e: |
167 |
| - raise exceptions.RepositoryError("Failed to load root") from e |
| 163 | + new_root = Metadata[Root].from_bytes(data) |
168 | 164 |
|
169 | 165 | if new_root.signed.type != Root.type:
|
170 | 166 | raise exceptions.RepositoryError(
|
@@ -218,10 +214,7 @@ def update_timestamp(self, data: bytes) -> Metadata[Timestamp]:
|
218 | 214 | # No need to check for 5.3.11 (fast forward attack recovery):
|
219 | 215 | # timestamp/snapshot can not yet be loaded at this point
|
220 | 216 |
|
221 |
| - try: |
222 |
| - new_timestamp = Metadata[Timestamp].from_bytes(data) |
223 |
| - except DeserializationError as e: |
224 |
| - raise exceptions.RepositoryError("Failed to load timestamp") from e |
| 217 | + new_timestamp = Metadata[Timestamp].from_bytes(data) |
225 | 218 |
|
226 | 219 | if new_timestamp.signed.type != Timestamp.type:
|
227 | 220 | raise exceptions.RepositoryError(
|
@@ -311,10 +304,7 @@ def update_snapshot(
|
311 | 304 | if not trusted:
|
312 | 305 | snapshot_meta.verify_length_and_hashes(data)
|
313 | 306 |
|
314 |
| - try: |
315 |
| - new_snapshot = Metadata[Snapshot].from_bytes(data) |
316 |
| - except DeserializationError as e: |
317 |
| - raise exceptions.RepositoryError("Failed to load snapshot") from e |
| 307 | + new_snapshot = Metadata[Snapshot].from_bytes(data) |
318 | 308 |
|
319 | 309 | if new_snapshot.signed.type != Snapshot.type:
|
320 | 310 | raise exceptions.RepositoryError(
|
@@ -423,10 +413,7 @@ def update_delegated_targets(
|
423 | 413 |
|
424 | 414 | meta.verify_length_and_hashes(data)
|
425 | 415 |
|
426 |
| - try: |
427 |
| - new_delegate = Metadata[Targets].from_bytes(data) |
428 |
| - except DeserializationError as e: |
429 |
| - raise exceptions.RepositoryError("Failed to load snapshot") from e |
| 416 | + new_delegate = Metadata[Targets].from_bytes(data) |
430 | 417 |
|
431 | 418 | if new_delegate.signed.type != Targets.type:
|
432 | 419 | raise exceptions.RepositoryError(
|
@@ -455,10 +442,7 @@ def _load_trusted_root(self, data: bytes) -> None:
|
455 | 442 | Note that an expired initial root is considered valid: expiry is
|
456 | 443 | only checked for the final root in update_timestamp().
|
457 | 444 | """
|
458 |
| - try: |
459 |
| - new_root = Metadata[Root].from_bytes(data) |
460 |
| - except DeserializationError as e: |
461 |
| - raise exceptions.RepositoryError("Failed to load root") from e |
| 445 | + new_root = Metadata[Root].from_bytes(data) |
462 | 446 |
|
463 | 447 | if new_root.signed.type != Root.type:
|
464 | 448 | raise exceptions.RepositoryError(
|
|
0 commit comments