You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix flaws pointed out by ieure, plus test failures
I'm not entirely sure it is appropriate to allow .url and .normalized_url to be non-existent in addition to allowing them to be None, but I don't really understand the intent of the url setter.
""" Returns None if s is a unicode or an ascii string, else
93
-
returns the UnicodeDecodeError that results from attempting to
94
-
decode it as ascii. """
95
-
try:
96
-
s.decode('ascii')
97
-
exceptUnicodeDecodeError, le:
98
-
returnle
92
+
""" Raise exception with instructive error message if s is not unicode or ascii. """
93
+
ifnotisinstance(s, unicode):
94
+
try:
95
+
s.decode('ascii')
96
+
exceptUnicodeDecodeError, le:
97
+
raiseTypeError('You are required to pass either a unicode object or an ascii string here. You passed a Python string object which contained non-ascii: %r. The UnicodeDecodeError that resulted from attempting to interpret it as ascii was: %s'% (s, le,))
99
98
100
99
defescape(s):
101
100
"""Escape a URL including any /."""
102
-
encerr=check_for_bad_encoding(s)
103
-
ifencerr:
104
-
raiseError('You are required to pass either a unicode object or an ascii string here. You passed a Python string object which contained non-ascii: %r. The UnicodeDecodeError that resulted from attempting to interpret it as ascii was: %s'% (encerr,))
raiseValueError("You are required to pass either a unicode object or an ascii string for `url'. You passed a Python string object which contained non-ascii: %r. The UnicodeDecodeError that resulted from attempting to interpret it as ascii was: %s"%(url, encerr,))
287
+
ifurlisnotNone:
288
+
check_for_bad_encoding(url)
289
+
self.url=unicode(url)
294
290
self.method=method
295
-
self.url=unicode(url)
296
291
ifparametersisnotNone:
297
292
self.update(parameters)
298
293
@@ -732,7 +727,7 @@ class SignatureMethod_HMAC_SHA1(SignatureMethod):
0 commit comments