Skip to content

Commit

Permalink
Fix get_geolocation's Unicode scrub wrapping
Browse files Browse the repository at this point in the history
`get_geolocation` is one of the few calls that also takes arguments, and
its return values may contain Unicode. The simple Unicode wrapper used
elsewhere can't take no-nonarg calls, so we wrap `get_geolocation` manually.
  • Loading branch information
aaaaalbert committed Mar 3, 2017
1 parent 88f7308 commit 7350a00
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions repysensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ def scrubbed_function():
# Create lock wrapper helper functions for the various locks, and
# wrap the sensor calls from the different CPython implementations.
sensorlock_wrap = wrap_with(sensorlock)
args_taking_sensorlock_wrap = args_taking_wrap_with(sensorlock)
medialock_wrap = args_taking_wrap_with(medialock)
outputlock_wrap = args_taking_wrap_with(outputlock)

Expand Down Expand Up @@ -367,10 +366,17 @@ def scrubbed_function():
tts_speak = medialock_wrap(media.tts_speak)

# Wrap the `location` module calls
# `get_geolocation` takes arguments, so it needs an arg-taking lock.
# `get_geolocation` takes arguments and might return Unicode, so it
# needs special attention.
get_location = unicode_scrub_wrap(sensorlock_wrap(location.get_location))
get_lastknown_location = unicode_scrub_wrap(sensorlock_wrap(location.get_lastknown_location))
get_geolocation = unicode_scrub_wrap(args_taking_sensorlock_wrap(location.get_geolocation))

def get_geolocation(latitude, longitude, number_of_results):
sensorlock.acquire()
raw_return_dict = location.get_geolocation(latitude, longitude, number_of_results)
sensorlock.release()
return scrub_unicode_from(raw_return_dict)



# Wrap the `androidlog` module calls
Expand Down

0 comments on commit 7350a00

Please sign in to comment.