Replace StopIteration with return (#26861)

pull/26867/head
Richard Belleville 3 years ago committed by GitHub
parent 6b71ec3704
commit a48067c4c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      examples/python/cancellation/search.py

@ -127,7 +127,7 @@ def search(target,
hashes_computed = 0
for secret in _all_bytestrings():
if stop_event.is_set():
raise StopIteration() # pylint: disable=stop-iteration-return
return
candidate_hash = _get_hash(secret)
distance = _get_substring_hamming_distance(candidate_hash, target)
if interesting_hamming_distance is not None and distance <= interesting_hamming_distance:
@ -142,7 +142,7 @@ def search(target,
secret=base64.b64encode(secret),
hashed_name=candidate_hash,
hamming_distance=distance)
raise StopIteration() # pylint: disable=stop-iteration-return
return
hashes_computed += 1
if hashes_computed == maximum_hashes:
raise ResourceLimitExceededError()

Loading…
Cancel
Save