Author: Armin Rigo <ar...@tunes.org> Branch: py3.5 Changeset: r88302:c6e6087f1717 Date: 2016-11-10 19:10 +0100 http://bitbucket.org/pypy/pypy/changeset/c6e6087f1717/
Log: merge heads diff --git a/lib-python/3/ssl.py b/lib-python/3/ssl.py --- a/lib-python/3/ssl.py +++ b/lib-python/3/ssl.py @@ -745,8 +745,7 @@ # non-blocking raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets") self.do_handshake() - - except (OSError, ValueError): + except: self.close() raise diff --git a/lib-python/3/test/test_ssl.py b/lib-python/3/test/test_ssl.py --- a/lib-python/3/test/test_ssl.py +++ b/lib-python/3/test/test_ssl.py @@ -1838,7 +1838,14 @@ else: self.sock.close() + # PyPy change def run(self): + try: + self._run() + finally: + self.close() + + def _run(self): self.running = True if not self.server.starttls_server: if not self.wrap_conn(): diff --git a/lib-python/3/test/test_urllib2_localnet.py b/lib-python/3/test/test_urllib2_localnet.py --- a/lib-python/3/test/test_urllib2_localnet.py +++ b/lib-python/3/test/test_urllib2_localnet.py @@ -544,6 +544,7 @@ self.assertEqual(handler.requests, ["/bizarre", b"get=with_feeling"]) def test_https(self): + self.skipTest('Segfaults on PyPy') handler = self.start_https_server() context = ssl.create_default_context(cafile=CERT_localhost) data = self.urlopen("https://localhost:%s/bizarre" % handler.port, context=context) @@ -573,6 +574,7 @@ cadefault=True) def test_https_sni(self): + self.skipTest('Segfaults on PyPy') if ssl is None: self.skipTest("ssl module required") if not ssl.HAS_SNI: diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py --- a/pypy/interpreter/gateway.py +++ b/pypy/interpreter/gateway.py @@ -159,6 +159,9 @@ def visit_str0(self, el, app_sig): self.checked_space_method(el, app_sig) + def visit_bytes(self, el, app_sig): + self.checked_space_method(el, app_sig) + def visit_fsencode(self, el, app_sig): self.checked_space_method(el, app_sig) @@ -296,6 +299,9 @@ def visit_str0(self, typ): self.run_args.append("space.str0_w(%s)" % (self.scopenext(),)) + def visit_bytes(self, typ): + self.run_args.append("space.bytes_w(%s)" % (self.scopenext(),)) + def visit_fsencode(self, typ): self.run_args.append("space.fsencode_w(%s)" % (self.scopenext(),)) @@ -452,6 +458,9 @@ def visit_str0(self, typ): self.unwrap.append("space.str0_w(%s)" % (self.nextarg(),)) + def visit_bytes(self, typ): + self.unwrap.append("space.bytes_w(%s)" % (self.nextarg(),)) + def visit_fsencode(self, typ): self.unwrap.append("space.fsencode_w(%s)" % (self.nextarg(),)) diff --git a/pypy/interpreter/test/test_gateway.py b/pypy/interpreter/test/test_gateway.py --- a/pypy/interpreter/test/test_gateway.py +++ b/pypy/interpreter/test/test_gateway.py @@ -256,6 +256,20 @@ assert self.space.eq_w(space.call_function(w_app_g, space.wrap(True)), space.wrap(True)) + def test_interp2app_unwrap_spec_bytes(self): + # we can't use the "bytes" object for the unwrap_spec, because that's + # an alias for "str" on the underlying Python2 + space = self.space + w = space.wrap + def g(space, b): + return space.newbytes(b) + app_g = gateway.interp2app(g, unwrap_spec=[gateway.ObjSpace, 'bytes']) + app_g2 = gateway.interp2app(g, unwrap_spec=[gateway.ObjSpace, 'bytes']) + assert app_g is app_g2 + w_app_g = space.wrap(app_g) + assert self.space.eq_w(space.call_function(w_app_g, space.newbytes("abc")), + space.newbytes("abc")) + def test_caching_methods(self): class Base(gateway.W_Root): def f(self): diff --git a/pypy/module/_hashlib/interp_hashlib.py b/pypy/module/_hashlib/interp_hashlib.py --- a/pypy/module/_hashlib/interp_hashlib.py +++ b/pypy/module/_hashlib/interp_hashlib.py @@ -187,7 +187,7 @@ HAS_FAST_PKCS5_PBKDF2_HMAC = ropenssl.PKCS5_PBKDF2_HMAC is not None if HAS_FAST_PKCS5_PBKDF2_HMAC: - @unwrap_spec(name=str, password=str, salt=str, rounds=int, + @unwrap_spec(name=str, password='bytes', salt='bytes', rounds=int, w_dklen=WrappedDefault(None)) def pbkdf2_hmac(space, name, password, salt, rounds, w_dklen): digest = ropenssl.EVP_get_digestbyname(name) @@ -206,4 +206,4 @@ dklen, buf.raw) if not r: raise ValueError - return space.wrap(buf.str(dklen)) + return space.newbytes(buf.str(dklen)) diff --git a/pypy/module/_hashlib/test/test_hashlib.py b/pypy/module/_hashlib/test/test_hashlib.py --- a/pypy/module/_hashlib/test/test_hashlib.py +++ b/pypy/module/_hashlib/test/test_hashlib.py @@ -91,7 +91,10 @@ from _hashlib import pbkdf2_hmac except ImportError: skip("Requires OpenSSL >= 1.1") - out = pbkdf2_hmac('sha1', 'password', 'salt', 1) + out = pbkdf2_hmac('sha1', b'password', b'salt', 1) + assert type(out) is bytes assert out == '0c60c80f961f0e71f3a9b524af6012062fe037a6'.decode('hex') - out = pbkdf2_hmac('sha1', 'password', 'salt', 2, None) + out = pbkdf2_hmac('sha1', b'password', b'salt', 2, None) assert out == 'ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957'.decode('hex') + raises(TypeError, pbkdf2_hmac, 'sha1', 'password', b'salt', 1) + raises(TypeError, pbkdf2_hmac, 'sha1', b'password', 'salt', 1) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit