summaryrefslogtreecommitdiff
path: root/swiftclient
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-09-15 02:34:01 +0000
committerGerrit Code Review <review@openstack.org>2016-09-15 02:34:01 +0000
commit0ec6b7b162a7b98ca3fad515de17d8f8a88dda72 (patch)
tree4f0798b36f2064de1df5ff4c95af575172a8c249 /swiftclient
parent714bf0cd4b1fafc47d055ccc12edd4a51ed8cb91 (diff)
parente41158d79e4bcb280ec94365226f9423f72d7b66 (diff)
downloadpython-swiftclient-0ec6b7b162a7b98ca3fad515de17d8f8a88dda72.tar.gz
Merge "Make tempurl subcommand insist on whole number seconds"
Diffstat (limited to 'swiftclient')
-rw-r--r--swiftclient/utils.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/swiftclient/utils.py b/swiftclient/utils.py
index 2e727ad..0d1104e 100644
--- a/swiftclient/utils.py
+++ b/swiftclient/utils.py
@@ -80,17 +80,19 @@ def generate_temp_url(path, seconds, key, method, absolute=False):
:param absolute: if True then the seconds parameter is interpreted as an
absolute Unix time, otherwise seconds is interpreted as a relative time
offset from current time.
- :raises: ValueError if seconds is not a positive integer or path is not to
+ :raises: ValueError if seconds is not a whole number or path is not to
an object.
- :raises: TypeError if seconds is not an integer
:return: the path portion of a temporary URL
"""
try:
+ seconds = float(seconds)
+ if not seconds.is_integer():
+ raise ValueError()
seconds = int(seconds)
+ if seconds < 0:
+ raise ValueError()
except ValueError:
- raise TypeError('seconds must be an integer')
- if seconds < 0:
- raise ValueError('seconds must be a positive integer')
+ raise ValueError('seconds must be a whole number')
if isinstance(path, six.binary_type):
try: