Author: Amaury Forgeot d'Arc <amaur...@gmail.com> Branch: Changeset: r44088:1c635389d676 Date: 2011-05-03 17:12 +0200 http://bitbucket.org/pypy/pypy/changeset/1c635389d676/
Log: Implement pending() method for ssl objects 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 @@ -199,6 +199,16 @@ else: raise _ssl_seterror(self.space, self, num_bytes) + def pending(self): + """pending() -> count + + Returns the number of already decrypted bytes available for read, + pending on the connection.""" + count = libssl_SSL_pending(self.ssl) + if count < 0: + raise _ssl_seterror(self.space, self, count) + return self.space.wrap(count) + @unwrap_spec(num_bytes=int) def read(self, num_bytes=1024): """read([len]) -> string @@ -374,6 +384,7 @@ server = interp2app(SSLObject.server), issuer = interp2app(SSLObject.issuer), write = interp2app(SSLObject.write), + pending = interp2app(SSLObject.pending), read = interp2app(SSLObject.read), do_handshake=interp2app(SSLObject.do_handshake), shutdown=interp2app(SSLObject.shutdown), 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 @@ -146,6 +146,7 @@ data = ss.read(10) assert isinstance(data, str) assert len(data) == 10 + assert ss.pending() > 50 # many more bytes to read self.s.close() def test_shutdown(self): _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit