Author: Amaury Forgeot d'Arc <[email protected]>
Branch: py3k
Changeset: r75913:2cf9d354d605
Date: 2015-02-16 09:52 +0100
http://bitbucket.org/pypy/pypy/changeset/2cf9d354d605/
Log: SSL passwords can be unicode.
diff --git a/pypy/module/_ssl/interp_ssl.py b/pypy/module/_ssl/interp_ssl.py
--- a/pypy/module/_ssl/interp_ssl.py
+++ b/pypy/module/_ssl/interp_ssl.py
@@ -1094,13 +1094,16 @@
if pw_info.w_callable:
try:
w_result = space.call_function(pw_info.w_callable)
- try:
- password = pw_info.space.bufferstr_w(w_result)
- except OperationError as e:
- if not e.match(space, space.w_TypeError):
- raise
- raise oefmt(space.w_TypeError,
- "password callback must return a string")
+ if space.isinstance_w(w_result, space.w_unicode):
+ password = space.str_w(w_result)
+ else:
+ try:
+ password = pw_info.space.bufferstr_w(w_result)
+ except OperationError as e:
+ if not e.match(space, space.w_TypeError):
+ raise
+ raise oefmt(space.w_TypeError,
+ "password callback must return a string")
except OperationError as e:
pw_info.operationerror = e
return rffi.cast(rffi.INT, -1)
@@ -1362,13 +1365,16 @@
if space.is_true(space.callable(w_password)):
pw_info.w_callable = w_password
else:
- try:
- pw_info.password = space.bufferstr_w(w_password)
- except OperationError as e:
- if not e.match(space, space.w_TypeError):
- raise
- raise oefmt(space.w_TypeError,
- "password should be a string or callable")
+ if space.isinstance_w(w_password, space.w_unicode):
+ pw_info.password = space.str_w(w_password)
+ else:
+ try:
+ pw_info.password = space.bufferstr_w(w_password)
+ except OperationError as e:
+ if not e.match(space, space.w_TypeError):
+ raise
+ raise oefmt(space.w_TypeError,
+ "password should be a string or callable")
libssl_SSL_CTX_set_default_passwd_cb(
self.ctx, _password_callback)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit