[pypy-commit] pypy stdlib-2.7.13: fix for socket.ssl().read(0)
arigo
pypy.commits at gmail.com
Sun Dec 18 13:58:42 EST 2016
Author: Armin Rigo <arigo at tunes.org>
Branch: stdlib-2.7.13
Changeset: r89161:2106f69132d9
Date: 2016-12-18 19:58 +0100
http://bitbucket.org/pypy/pypy/changeset/2106f69132d9/
Log: fix for socket.ssl().read(0)
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
@@ -420,6 +420,12 @@
raise oefmt(space.w_ValueError, "size should not be negative")
rwbuffer = None
+ if num_bytes <= 0:
+ if rwbuffer:
+ return space.wrap(0)
+ else:
+ return space.wrap("")
+
with rffi.scoped_alloc_buffer(num_bytes) as buf:
while True:
err = 0
diff --git a/pypy/module/_ssl/test/test_ssl.py b/pypy/module/_ssl/test/test_ssl.py
--- a/pypy/module/_ssl/test/test_ssl.py
+++ b/pypy/module/_ssl/test/test_ssl.py
@@ -218,6 +218,7 @@
ss.write("hello\n")
data = ss.read(10)
assert isinstance(data, str)
+ assert ss.read(0) == ''
self.s.close()
del ss; gc.collect()
More information about the pypy-commit
mailing list