File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -150,7 +150,10 @@ def validate_options(opts):
150
150
normalized = {}
151
151
for option , value in opts .iteritems ():
152
152
option , value = validate (option , value )
153
- normalized [option ] = value
153
+ # str(option) to ensure that a unicode URI results in plain 'str'
154
+ # option names. 'normalized' is then suitable to be passed as kwargs
155
+ # in all Python versions.
156
+ normalized [str (option )] = value
154
157
return normalized
155
158
156
159
Original file line number Diff line number Diff line change @@ -335,6 +335,14 @@ def test_parse_uri(self):
335
335
parse_uri ("mongodb://user%40domain.com"
336
336
"@localhost/foo?authMechanism=GSSAPI" ))
337
337
338
+ def test_parse_uri_unicode (self ):
339
+ # Ensure parsing a unicode returns option names that can be passed
340
+ # as kwargs. In Python 2.4, keyword argument names must be ASCII.
341
+ # In all Pythons, str is the type of valid keyword arg names.
342
+ res = parse_uri (unicode ("mongodb://localhost/?fsync=true" ))
343
+ for key in res ['options' ]:
344
+ self .assertTrue (isinstance (key , str ))
345
+
338
346
339
347
if __name__ == "__main__" :
340
348
unittest .main ()
You can’t perform that action at this time.
0 commit comments