[pypy-commit] pypy py3.5-refactor-sys_exc_info: (arigo) when running 'py.test -A', detect complete crashes of CPython too

2016-11-17 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: py3.5-refactor-sys_exc_info
Changeset: r88424:106e9a48e6a9
Date: 2016-11-17 08:53 +
http://bitbucket.org/pypy/pypy/changeset/106e9a48e6a9/

Log:(arigo) when running 'py.test -A', detect complete crashes of
CPython too

diff --git a/pypy/tool/pytest/apptest.py b/pypy/tool/pytest/apptest.py
--- a/pypy/tool/pytest/apptest.py
+++ b/pypy/tool/pytest/apptest.py
@@ -172,7 +172,8 @@
 f.write('\n'.join(defs))
 f.write('def %s():\n' % target_name)
 f.write('\n'.join(source))
-f.write("\n%s()\n" % target_name)
+f.write("\ntry:\n%s()\n" % target_name)
+f.write('finally:\nprint("===aefwuiheawiu===")')
 helper_dir = os.path.join(pypydir, 'tool', 'cpyext')
 env = os.environ.copy()
 env['PYTHONPATH'] = helper_dir
@@ -186,6 +187,8 @@
  (python_, usemodules))
 elif res > 0:
 raise AssertionError("Subprocess failed:\n" + stderr)
+elif "===aefwuiheawiu===" not in stdout:
+raise AssertionError("%r crashed:\n%s" % (python_, stderr))
 
 
 def extract_docstring_if_empty_function(fn):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5-refactor-sys_exc_info: (arigo) typos. write a minimal test now for the expected errors

2016-11-17 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: py3.5-refactor-sys_exc_info
Changeset: r88425:3f27a0c78aa5
Date: 2016-11-17 08:56 +
http://bitbucket.org/pypy/pypy/changeset/3f27a0c78aa5/

Log:(arigo) typos. write a minimal test now for the expected errors

diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py
--- a/pypy/interpreter/pyframe.py
+++ b/pypy/interpreter/pyframe.py
@@ -655,7 +655,9 @@
 blockstack.append(addr)
 blockstack.append(-1)
 elif op == POP_BLOCK:
-assert len(blockstack) >= 3
+if len(blockstack) < 3:
+raise oefmt(space.w_SystemError,
+"blocks not properly nested in this bytecode")
 blockstack.pop()
 setup_op = ord(code[blockstack.pop()])
 if setup_op != SETUP_LOOP:
@@ -670,22 +672,24 @@
 assert ii >= 0
 handler_addr = blockstack[ii]
 if addr == new_lasti:
-new_lasti_setup_addr = handler_addr
+new_lasti_handler_addr = handler_addr
 if addr == self.last_instr:
-f_lasti_setup_addr = handler_addr
+f_lasti_handler_addr = handler_addr
 
 if op >= HAVE_ARGUMENT:
 addr += 3
 else:
 addr += 1
 
-assert len(blockstack) == 0
+if len(blockstack) != 1:
+raise oefmt(space.w_SystemError,
+"blocks not properly nested in this bytecode")
 
 if new_lasti_handler_addr != f_lasti_handler_addr:
 raise oefmt(space.w_ValueError,
 "can't jump into or out of an 'expect' or "
 "'finally' block (%d -> %d)",
-f_lasti_handler_addr, new_lasti_setup_addr)
+f_lasti_handler_addr, new_lasti_handler_addr)
 
 # now we know we're not jumping into or out of a place which
 # needs a SysExcInfoRestorer.  Check that we're not jumping
diff --git a/pypy/interpreter/test/test_pyframe.py 
b/pypy/interpreter/test/test_pyframe.py
--- a/pypy/interpreter/test/test_pyframe.py
+++ b/pypy/interpreter/test/test_pyframe.py
@@ -87,6 +87,40 @@
 sys.settrace(None)
 # assert did not crash
 
+def test_f_lineno_set_2(self):
+counter = [0]
+errors = []
+
+def tracer(f, event, *args):
+if event == 'line':
+counter[0] += 1
+if counter[0] == 2:
+try:
+f.f_lineno += 2
+except ValueError as e:
+errors.append(e)
+return tracer
+
+# obscure: call open beforehand, py3k's open invokes some app
+# level code that confuses our tracing (likely due to the
+# testing env, otherwise it's not a problem)
+f = open(self.tempfile1, 'w')
+def function():
+try:
+raise ValueError
+except ValueError:
+x = 42
+return x
+
+import sys
+sys.settrace(tracer)
+x = function()
+sys.settrace(None)
+assert x == 42
+assert len(errors) == 1
+assert str(errors[0]).startswith(
+"can't jump into or out of an 'expect' or 'finally' block")
+
 def test_f_lineno_set_firstline(self):
 r"""
 seen = []
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Document next cpython crasher

2016-11-17 Thread arigo
Author: Armin Rigo 
Branch: extradoc
Changeset: r5748:572cc735325d
Date: 2016-11-17 09:49 +0100
http://bitbucket.org/pypy/extradoc/changeset/572cc735325d/

Log:Document next cpython crasher

diff --git a/planning/py3.5/cpython-crashers.rst 
b/planning/py3.5/cpython-crashers.rst
--- a/planning/py3.5/cpython-crashers.rst
+++ b/planning/py3.5/cpython-crashers.rst
@@ -41,6 +41,29 @@
   if chain=False.  This can rarely cause random nonsense in the main
   program.
 
+* setting f_lineno didn't evolve when the rest of the bytecodes evolved,
+  which means it is not safe any more::
+
+import sys
+
+def f():
+try:
+raise ValueError# line 5
+except ValueError:
+print(42)   # line 7
+
+def my_trace(*args):
+print(args)
+if args[1] == 'line':
+f = args[0]
+if f.f_lineno == 5:
+f.f_lineno = 7
+return my_trace
+
+sys.settrace(my_trace)
+f()
+sys.settrace(None)
+
 
 Other bugs
 --
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix (probably a merge error?)

2016-11-17 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r88426:31fb79a2893f
Date: 2016-11-17 10:16 +0100
http://bitbucket.org/pypy/pypy/changeset/31fb79a2893f/

Log:Fix (probably a merge error?)

diff --git a/pytest.py b/pytest.py
--- a/pytest.py
+++ b/pytest.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python
 # PYTHON_ARGCOMPLETE_OK
 """
 pytest: unit and functional testing with Python.
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5-ssl: passing all tests in test_ssl.py

2016-11-17 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5-ssl
Changeset: r88428:d9f42756c388
Date: 2016-11-17 13:34 +0100
http://bitbucket.org/pypy/pypy/changeset/d9f42756c388/

Log:passing all tests in test_ssl.py

diff --git a/lib_pypy/openssl/_cffi_src/openssl/bio.py 
b/lib_pypy/openssl/_cffi_src/openssl/bio.py
--- a/lib_pypy/openssl/_cffi_src/openssl/bio.py
+++ b/lib_pypy/openssl/_cffi_src/openssl/bio.py
@@ -82,6 +82,8 @@
 int BIO_write(BIO *, const void *, int);
 int BIO_puts(BIO *, const char *);
 int BIO_method_type(const BIO *);
+
+int * Cryptography_bio_references(const BIO *);
 """
 
 MACROS = """
@@ -132,7 +134,12 @@
 long BIO_set_nbio(BIO *, long);
 void BIO_set_retry_read(BIO *);
 void BIO_clear_retry_flags(BIO *);
+
+#define CRYPTO_LOCK_BIO ...
 """
 
 CUSTOMIZATIONS = """
+int * Cryptography_bio_references(const BIO * b) {
+return &b->references;
+}
 """
diff --git a/lib_pypy/openssl/_cffi_src/openssl/crypto.py 
b/lib_pypy/openssl/_cffi_src/openssl/crypto.py
--- a/lib_pypy/openssl/_cffi_src/openssl/crypto.py
+++ b/lib_pypy/openssl/_cffi_src/openssl/crypto.py
@@ -57,6 +57,8 @@
 
 /* This was removed in 1.1.0 */
 void CRYPTO_lock(int, int, const char *, int);
+
+void CRYPTO_add(void*,int,int);
 """
 
 CUSTOMIZATIONS = """
diff --git a/lib_pypy/openssl/_stdssl/__init__.py 
b/lib_pypy/openssl/_stdssl/__init__.py
--- a/lib_pypy/openssl/_stdssl/__init__.py
+++ b/lib_pypy/openssl/_stdssl/__init__.py
@@ -98,6 +98,10 @@
 # TODO threads?
 lib.OpenSSL_add_all_algorithms()
 
+def check_signals():
+# TODO PyErr_CheckSignal equivalent for pypy?
+pass
+
 def _socket_timeout(s):
 if s is None:
 return 0.0
@@ -218,13 +222,14 @@
 if sock:
 lib.SSL_set_fd(ssl, sock.fileno())
 else:
-raise NotImplementedError("implement _SSLSocket inbio, outbio 
params")
-# /* BIOs are reference counted and SSL_set_bio borrows our 
reference.
-#  * To prevent a double free in memory_bio_dealloc() we need to 
take an
-#  * extra reference here. */
-# CRYPTO_add(&inbio->bio->references, 1, CRYPTO_LOCK_BIO);
-# CRYPTO_add(&outbio->bio->references, 1, CRYPTO_LOCK_BIO);
-# SSL_set_bio(self->ssl, inbio->bio, outbio->bio);
+# BIOs are reference counted and SSL_set_bio borrows our reference.
+# To prevent a double free in memory_bio_dealloc() we need to take 
an
+# extra reference here.
+irefaddr = lib.Cryptography_bio_references(inbio.bio);
+orefaddr = lib.Cryptography_bio_references(outbio.bio);
+lib.CRYPTO_add(irefaddr, 1, lib.CRYPTO_LOCK_BIO)
+lib.CRYPTO_add(orefaddr, 1, lib.CRYPTO_LOCK_BIO)
+lib.SSL_set_bio(self.ssl, inbio.bio, outbio.bio)
 
 mode = lib.SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER
 if lib.SSL_MODE_AUTO_RETRY:
@@ -287,12 +292,17 @@
 
 @context.setter
 def context(self, value):
-self.ctx = value
+if isinstance(value, _SSLContext):
+if not HAS_SNI:
+raise NotImplementedError("setting a socket's "
+"context is not supported by your OpenSSL library")
+self.ctx = value
+lib.SSL_set_SSL_CTX(self.ssl, self.ctx.ctx);
+else:
+raise TypeError("The value must be a SSLContext")
 
 def do_handshake(self):
-sock = self.get_socket_or_None()
-if sock is None:
-raise ssl_error("Underlying socket connection gone", 
SSL_ERROR_NO_SOCKET)
+sock = self.get_socket_or_connection_gone()
 ssl = self.ssl
 timeout = _socket_timeout(sock)
 if sock:
@@ -313,8 +323,7 @@
 err = lib.SSL_get_error(ssl, ret)
 # end allow threads
 
-#if (PyErr_CheckSignals())
-#goto error;
+check_signals()
 
 if has_timeout:
 # REIVIEW monotonic clock?
@@ -399,8 +408,7 @@
 err = lib.SSL_get_error(self.ssl, length)
 #PySSL_END_ALLOW_THREADS
 
-# TODO if (PyErr_CheckSignals())
-# TODO goto error;
+check_signals()
 
 if has_timeout:
 # TODO monotonic clock
@@ -428,14 +436,12 @@
 raise pyssl_error(self, length)
 
 def read(self, length, buffer_into=None):
-sock = self.get_socket_or_None()
 ssl = self.ssl
 
 if length < 0 and buffer_into is None:
 raise ValueError("size should not be negative")
 
-if sock is None:
-raise ssl_error("Underlying socket connection gone", 
SSL_ERROR_NO_SOCKET)
+sock = self.get_socket_or_connection_gone()
 
 if not buffer_into:
 dest = _buffer_new(length)
@@ -467,9 +473,7 @@
 err = lib.SSL_get_error(self.ssl, count);
 #PySSL_END_ALLOW_THREADS
 
-# TODO
-#if (PyErr_CheckSignals())
-#goto error;
+   

[pypy-commit] pypy py3.5-ssl: copy over certificates of cpython stdlib (ssl + ssl_tests) target 3.5.2

2016-11-17 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5-ssl
Changeset: r88427:742c85b008ab
Date: 2016-11-17 10:05 +0100
http://bitbucket.org/pypy/pypy/changeset/742c85b008ab/

Log:copy over certificates of cpython stdlib (ssl + ssl_tests) target
3.5.2

diff --git a/lib-python/3/test/capath/0e4015b9.0 
b/lib-python/3/test/capath/0e4015b9.0
new file mode 100644
--- /dev/null
+++ b/lib-python/3/test/capath/0e4015b9.0
@@ -0,0 +1,16 @@
+-BEGIN CERTIFICATE-
+MIIClTCCAf6gAwIBAgIJAKGU95wKR8pTMA0GCSqGSIb3DQEBBQUAMHAxCzAJBgNV
+BAYTAlhZMRcwFQYDVQQHDA5DYXN0bGUgQW50aHJheDEjMCEGA1UECgwaUHl0aG9u
+IFNvZnR3YXJlIEZvdW5kYXRpb24xIzAhBgNVBAMMGnNlbGYtc2lnbmVkLnB5dGhv
+bnRlc3QubmV0MB4XDTE0MTEwMjE4MDkyOVoXDTI0MTAzMDE4MDkyOVowcDELMAkG
+A1UEBhMCWFkxFzAVBgNVBAcMDkNhc3RsZSBBbnRocmF4MSMwIQYDVQQKDBpQeXRo
+b24gU29mdHdhcmUgRm91bmRhdGlvbjEjMCEGA1UEAwwac2VsZi1zaWduZWQucHl0
+aG9udGVzdC5uZXQwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANDXQXW9tjyZ
+Xt0Iv2tLL1+jinr4wGg36ioLDLFkMf+2Y1GL0v0BnKYG4N1OKlAU15LXGeGer8vm
+Sv/yIvmdrELvhAbbo3w4a9TMYQA4XkIVLdvu3mvNOAet+8PMJxn26dbDhG809ALv
+EHY57lQsBS3G59RZyBPVqAqmImWNJnVzAgMBAAGjNzA1MCUGA1UdEQQeMByCGnNl
+bGYtc2lnbmVkLnB5dGhvbnRlc3QubmV0MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcN
+AQEFBQADgYEAIuzAhgMouJpNdf3URCHIineyoSt6WK/9+eyUcjlKOrDoXNZaD72h
+TXMeKYoWvJyVcSLKL8ckPtDobgP2OTt0UkyAaj0n+ZHaqq1lH2yVfGUA1ILJv515
+C8BqbvVZuqm3i7ygmw3bqE/lYMgOrYtXXnqOrz6nvsE6Yc9V9rFflOM=
+-END CERTIFICATE-
diff --git a/lib-python/3/test/capath/ce7b8643.0 
b/lib-python/3/test/capath/ce7b8643.0
new file mode 100644
--- /dev/null
+++ b/lib-python/3/test/capath/ce7b8643.0
@@ -0,0 +1,16 @@
+-BEGIN CERTIFICATE-
+MIIClTCCAf6gAwIBAgIJAKGU95wKR8pTMA0GCSqGSIb3DQEBBQUAMHAxCzAJBgNV
+BAYTAlhZMRcwFQYDVQQHDA5DYXN0bGUgQW50aHJheDEjMCEGA1UECgwaUHl0aG9u
+IFNvZnR3YXJlIEZvdW5kYXRpb24xIzAhBgNVBAMMGnNlbGYtc2lnbmVkLnB5dGhv
+bnRlc3QubmV0MB4XDTE0MTEwMjE4MDkyOVoXDTI0MTAzMDE4MDkyOVowcDELMAkG
+A1UEBhMCWFkxFzAVBgNVBAcMDkNhc3RsZSBBbnRocmF4MSMwIQYDVQQKDBpQeXRo
+b24gU29mdHdhcmUgRm91bmRhdGlvbjEjMCEGA1UEAwwac2VsZi1zaWduZWQucHl0
+aG9udGVzdC5uZXQwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANDXQXW9tjyZ
+Xt0Iv2tLL1+jinr4wGg36ioLDLFkMf+2Y1GL0v0BnKYG4N1OKlAU15LXGeGer8vm
+Sv/yIvmdrELvhAbbo3w4a9TMYQA4XkIVLdvu3mvNOAet+8PMJxn26dbDhG809ALv
+EHY57lQsBS3G59RZyBPVqAqmImWNJnVzAgMBAAGjNzA1MCUGA1UdEQQeMByCGnNl
+bGYtc2lnbmVkLnB5dGhvbnRlc3QubmV0MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcN
+AQEFBQADgYEAIuzAhgMouJpNdf3URCHIineyoSt6WK/9+eyUcjlKOrDoXNZaD72h
+TXMeKYoWvJyVcSLKL8ckPtDobgP2OTt0UkyAaj0n+ZHaqq1lH2yVfGUA1ILJv515
+C8BqbvVZuqm3i7ygmw3bqE/lYMgOrYtXXnqOrz6nvsE6Yc9V9rFflOM=
+-END CERTIFICATE-
diff --git a/lib-python/3/test/selfsigned_pythontestdotnet.pem 
b/lib-python/3/test/selfsigned_pythontestdotnet.pem
--- a/lib-python/3/test/selfsigned_pythontestdotnet.pem
+++ b/lib-python/3/test/selfsigned_pythontestdotnet.pem
@@ -1,5 +1,5 @@
 -BEGIN CERTIFICATE-
-MIIChzCCAfCgAwIBAgIJAKGU95wKR8pSMA0GCSqGSIb3DQEBBQUAMHAxCzAJBgNV
+MIIClTCCAf6gAwIBAgIJAKGU95wKR8pTMA0GCSqGSIb3DQEBBQUAMHAxCzAJBgNV
 BAYTAlhZMRcwFQYDVQQHDA5DYXN0bGUgQW50aHJheDEjMCEGA1UECgwaUHl0aG9u
 IFNvZnR3YXJlIEZvdW5kYXRpb24xIzAhBgNVBAMMGnNlbGYtc2lnbmVkLnB5dGhv
 bnRlc3QubmV0MB4XDTE0MTEwMjE4MDkyOVoXDTI0MTAzMDE4MDkyOVowcDELMAkG
@@ -8,9 +8,9 @@
 aG9udGVzdC5uZXQwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANDXQXW9tjyZ
 Xt0Iv2tLL1+jinr4wGg36ioLDLFkMf+2Y1GL0v0BnKYG4N1OKlAU15LXGeGer8vm
 Sv/yIvmdrELvhAbbo3w4a9TMYQA4XkIVLdvu3mvNOAet+8PMJxn26dbDhG809ALv
-EHY57lQsBS3G59RZyBPVqAqmImWNJnVzAgMBAAGjKTAnMCUGA1UdEQQeMByCGnNl
-bGYtc2lnbmVkLnB5dGhvbnRlc3QubmV0MA0GCSqGSIb3DQEBBQUAA4GBAIOXmdtM
-eG9qzP9TiXW/Gc/zI4cBfdCpC+Y4gOfC9bQUC7hefix4iO3+iZjgy3X/FaRxUUoV
-HKiXcXIaWqTSUWp45cSh0MbwZXudp6JIAptzdAhvvCrPKeC9i9GvxsPD4LtDAL97
-vSaxQBezA7hdxZd90/EeyMgVZgAnTCnvAWX9
+EHY57lQsBS3G59RZyBPVqAqmImWNJnVzAgMBAAGjNzA1MCUGA1UdEQQeMByCGnNl
+bGYtc2lnbmVkLnB5dGhvbnRlc3QubmV0MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcN
+AQEFBQADgYEAIuzAhgMouJpNdf3URCHIineyoSt6WK/9+eyUcjlKOrDoXNZaD72h
+TXMeKYoWvJyVcSLKL8ckPtDobgP2OTt0UkyAaj0n+ZHaqq1lH2yVfGUA1ILJv515
+C8BqbvVZuqm3i7ygmw3bqE/lYMgOrYtXXnqOrz6nvsE6Yc9V9rFflOM=
 -END CERTIFICATE-
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
@@ -23,9 +23,6 @@
 
 PROTOCOLS = sorted(ssl._PROTOCOL_NAMES)
 HOST = support.HOST
-IS_LIBRESSL = ssl.OPENSSL_VERSION.startswith('LibreSSL')
-IS_OPENSSL_1_1 = not IS_LIBRESSL and ssl.OPENSSL_VERSION_INFO >= (1, 1, 0)
-
 
 def data_file(*name):
 return os.path.join(os.path.dirname(__file__), *name)
@@ -57,8 +54,6 @@
 SIGNED_CERTFILE = data_file("keycert3.pem")
 SIGNED_CERTFILE2 = data_file("keycert4.pem")
 SIGNING_CA = data_file("pycacert.pem")
-# cert with all kinds of subject alt names
-ALLSANFILE = data_file("allsans.pem")
 
 REMOTE_HOST = "self-signed.pythontest.net"
 REMOTE_ROOT_CERT = data_file("selfsigned_pythontestdotnet.pem")
@@ -148,8 +143,8 @@
 def test_str_for_enums(self):
 # Make sure that the PROTOCOL_* constants have enum-like string
 # reprs.
-proto = ssl.PROTOCOL_TLS
- 

[pypy-commit] pypy py3.5-ssl: some simplifications, removed comments

2016-11-17 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5-ssl
Changeset: r88429:d4d6dd1d67d1
Date: 2016-11-17 13:45 +0100
http://bitbucket.org/pypy/pypy/changeset/d4d6dd1d67d1/

Log:some simplifications, removed comments

diff --git a/lib_pypy/openssl/_cffi_src/openssl/ssl.py 
b/lib_pypy/openssl/_cffi_src/openssl/ssl.py
--- a/lib_pypy/openssl/_cffi_src/openssl/ssl.py
+++ b/lib_pypy/openssl/_cffi_src/openssl/ssl.py
@@ -248,8 +248,6 @@
 Cryptography_STACK_OF_X509_NAME *SSL_load_client_CA_file(const char *);
 
 const char *SSL_get_servername(const SSL *, const int);
-//long SSL_CTX_callback_ctrl(SSL_CTX *, int, void (*)(void));
-//long SSL_CTX_ctrl(SSL_CTX *, int, long, void *);
 """
 
 MACROS = """
diff --git a/lib_pypy/openssl/_cffi_src/openssl/x509v3.py 
b/lib_pypy/openssl/_cffi_src/openssl/x509v3.py
--- a/lib_pypy/openssl/_cffi_src/openssl/x509v3.py
+++ b/lib_pypy/openssl/_cffi_src/openssl/x509v3.py
@@ -183,12 +183,9 @@
 GENERAL_NAMES *GENERAL_NAMES_new(void);
 void GENERAL_NAMES_free(GENERAL_NAMES *);
 void *X509V3_EXT_d2i(X509_EXTENSION *);
-/* X509_get_ext_d2i is already defined, there might be a better solution
-   to expose it to the lib object?  */
-void * _X509_get_ext_d2i(X509 *, int, int *, int *);
 /* X509 is private, there is no way to access the field crldp other than
adding it to the typedef or expose a function like this: */
-Cryptography_STACK_OF_DIST_POINT * _X509_get_crldp(const X509 *);
+Cryptography_STACK_OF_DIST_POINT * Cryptography_X509_get_crldp(const X509 *);
 int X509_check_ca(X509 *);
 """
 
@@ -302,15 +299,17 @@
 DIST_POINT_NAME *DIST_POINT_NAME_new(void);
 void DIST_POINT_NAME_free(DIST_POINT_NAME *);
 
+void * X509_get_ext_d2i(const X509 *, int, int *, int *);
 """
 
 CUSTOMIZATIONS = """
-void * _X509_get_ext_d2i(X509 * x, int nid, int * a, int * b) {
-return X509_get_ext_d2i(x, nid, a, b);
+#if OPENSSL_VERSION_NUMBER >= 0x10001000L
+Cryptography_STACK_OF_DIST_POINT * Cryptography_X509_get_crldp(const X509 * x) 
{
+return x->crldp;
 }
-#if OPENSSL_VERSION_NUMBER >= 0x10001000L
-Cryptography_STACK_OF_DIST_POINT * _X509_get_crldp(const X509 * x) {
-return x->crldp;
+#else
+Cryptography_STACK_OF_DIST_POINT * Cryptography_X509_get_crldp(const X509 * x) 
{
+return NULL;
 }
 #endif
 """
diff --git a/lib_pypy/openssl/_stdssl/certificate.py 
b/lib_pypy/openssl/_stdssl/certificate.py
--- a/lib_pypy/openssl/_stdssl/certificate.py
+++ b/lib_pypy/openssl/_stdssl/certificate.py
@@ -26,7 +26,7 @@
 return (name, value)
 
 def _get_aia_uri(certificate, nid):
-info = lib._X509_get_ext_d2i(certificate, lib.NID_info_access, ffi.NULL, 
ffi.NULL)
+info = lib.X509_get_ext_d2i(certificate, lib.NID_info_access, ffi.NULL, 
ffi.NULL)
 if (info == ffi.NULL):
 return None;
 if lib.sk_ACCESS_DESCRIPTION_num(info) == 0:
@@ -244,16 +244,12 @@
 
 
 def _get_crl_dp(certificate):
-#STACK_OF(DIST_POINT) *dps;
-#int i, j;
-#PyObject *lst, *res = NULL;
-#
 if lib.OPENSSL_VERSION_NUMBER < 0x10001000:
 dps = lib.X509_get_ext_d2i(certificate, 
lib.NID_crl_distribution_points, ffi.NULL, ffi.NULL)
 else:
 # Calls x509v3_cache_extensions and sets up crldp
 lib.X509_check_ca(certificate)
-dps = lib._X509_get_crldp(certificate)
+dps = lib.Cryptography_X509_get_crldp(certificate)
 if dps is ffi.NULL:
 return None
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy clean-exported-state: Close branch clean-exported-state

2016-11-17 Thread arigo
Author: Armin Rigo 
Branch: clean-exported-state
Changeset: r88430:c01760e8436e
Date: 2016-11-17 13:14 +
http://bitbucket.org/pypy/pypy/changeset/c01760e8436e/

Log:Close branch clean-exported-state

___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Merged in clean-exported-state (pull request #490)

2016-11-17 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r88431:ab8a0b092d2d
Date: 2016-11-17 13:14 +
http://bitbucket.org/pypy/pypy/changeset/ab8a0b092d2d/

Log:Merged in clean-exported-state (pull request #490)

Clean exported state

diff --git a/rpython/jit/metainterp/compile.py 
b/rpython/jit/metainterp/compile.py
--- a/rpython/jit/metainterp/compile.py
+++ b/rpython/jit/metainterp/compile.py
@@ -108,7 +108,7 @@
 """
 log_noopt = False
 
-def __init__(self, trace, celltoken, state,
+def __init__(self, trace, celltoken, state, runtime_boxes,
  call_pure_results=None, enable_opts=None,
  inline_short_preamble=True):
 self.trace = trace
@@ -117,6 +117,8 @@
 self.state = state
 self.call_pure_results = call_pure_results
 self.inline_short_preamble = inline_short_preamble
+assert runtime_boxes is not None
+self.runtime_boxes = runtime_boxes
 
 def optimize(self, metainterp_sd, jitdriver_sd, optimizations, unroll):
 from rpython.jit.metainterp.optimizeopt.unroll import UnrollOptimizer
@@ -124,7 +126,11 @@
 assert unroll # we should not be here if it's disabled
 opt = UnrollOptimizer(metainterp_sd, jitdriver_sd, optimizations)
 return opt.optimize_peeled_loop(self.trace, self.celltoken, self.state,
-self.call_pure_results, self.inline_short_preamble)
+self.runtime_boxes, self.call_pure_results, 
self.inline_short_preamble)
+
+def forget_optimization_info(self):
+self.state.forget_optimization_info()
+CompileData.forget_optimization_info(self)
 
 def show_procedures(metainterp_sd, procedure=None, error=None):
 # debugging
@@ -290,7 +296,7 @@
 start_descr = TargetToken(jitcell_token,
   original_jitcell_token=jitcell_token)
 jitcell_token.target_tokens = [start_descr]
-loop_data = UnrolledLoopData(trace, jitcell_token, start_state,
+loop_data = UnrolledLoopData(trace, jitcell_token, start_state, jumpargs,
  call_pure_results=call_pure_results,
  enable_opts=enable_opts)
 try:
@@ -360,7 +366,7 @@
 history.record(rop.JUMP, jumpargs[:], None, descr=loop_jitcell_token)
 enable_opts = jitdriver_sd.warmstate.enable_opts
 call_pure_results = metainterp.call_pure_results
-loop_data = UnrolledLoopData(trace, loop_jitcell_token, start_state,
+loop_data = UnrolledLoopData(trace, loop_jitcell_token, start_state, 
jumpargs,
  call_pure_results=call_pure_results,
  enable_opts=enable_opts)
 try:
@@ -372,6 +378,7 @@
 history.cut(cut)
 history.record(rop.JUMP, jumpargs[:], None, descr=loop_jitcell_token)
 loop_data = UnrolledLoopData(trace, loop_jitcell_token, start_state,
+ jumpargs,
  call_pure_results=call_pure_results,
  enable_opts=enable_opts,
  inline_short_preamble=False)
@@ -516,7 +523,7 @@
 for item in lst:
 item.set_forwarded(None)
 # XXX we should really do it, but we need to remember the values
-# somehoe for ContinueRunningNormally
+# somehow for ContinueRunningNormally
 if reset_values:
 item.reset_value()
 
diff --git a/rpython/jit/metainterp/optimizeopt/heap.py 
b/rpython/jit/metainterp/optimizeopt/heap.py
--- a/rpython/jit/metainterp/optimizeopt/heap.py
+++ b/rpython/jit/metainterp/optimizeopt/heap.py
@@ -12,7 +12,7 @@
 from rpython.jit.metainterp.optimize import InvalidLoop
 from rpython.jit.metainterp.resoperation import rop, ResOperation, OpHelpers,\
  AbstractResOp, GuardResOp
-from rpython.rlib.objectmodel import we_are_translated
+from rpython.rlib.objectmodel import we_are_translated, we_are_debug
 from rpython.jit.metainterp.optimizeopt import info
 
 
@@ -172,7 +172,7 @@
 
 def _getfield(self, opinfo, descr, optheap, true_force=True):
 res = opinfo.getfield(descr, optheap)
-if not we_are_translated() and res:
+if we_are_debug() and res:
 if isinstance(opinfo, info.AbstractStructPtrInfo):
 assert opinfo in self.cached_infos
 if isinstance(res, PreambleOp):
@@ -202,7 +202,7 @@
 
 def _getfield(self, opinfo, descr, optheap, true_force=True):
 res = opinfo.getitem(descr, self.index, optheap)
-if not we_are_translated() and res:
+if we_are_debug() and res:
 if isinstance(opinfo, info.ArrayPtrInfo):
 assert opinfo in self.cached_infos
 if (isinstance(res, PreambleOp) and
diff --git a/rpython/jit/metainterp/optimizeopt/optimizer.py 
b/rpython/jit/metainterp/optimizeopt/optimizer.py
--- a/rpython/jit/metainterp/optimizeopt/optimizer.py
+++ b/rpython/jit/metainterp/optimiz

[pypy-commit] pypy default: document branch

2016-11-17 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r88433:5990b8c98760
Date: 2016-11-17 14:17 +0100
http://bitbucket.org/pypy/pypy/changeset/5990b8c98760/

Log:document branch

diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -14,3 +14,7 @@
 .. branch: union-side-effects-2
 
 Try to improve the consistency of RPython annotation unions.
+
+.. branch: clean-exported-state
+
+Clean-ups in the jit optimizeopt
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: merge heads

2016-11-17 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r88434:3dc381df7878
Date: 2016-11-17 14:18 +0100
http://bitbucket.org/pypy/pypy/changeset/3dc381df7878/

Log:merge heads

diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -15,6 +15,8 @@
 
 Try to improve the consistency of RPython annotation unions.
 
+.. branch: pytest-2.9.2
+
 .. branch: clean-exported-state
 
 Clean-ups in the jit optimizeopt
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: document

2016-11-17 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r88432:dc3941998986
Date: 2016-11-17 10:20 +0100
http://bitbucket.org/pypy/pypy/changeset/dc3941998986/

Log:document

diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -14,3 +14,5 @@
 .. branch: union-side-effects-2
 
 Try to improve the consistency of RPython annotation unions.
+
+.. branch: pytest-2.9.2
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5-ssl: copy changes made to cryptography, rename method name of call site

2016-11-17 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5-ssl
Changeset: r88435:74ee14214a4e
Date: 2016-11-17 14:18 +0100
http://bitbucket.org/pypy/pypy/changeset/74ee14214a4e/

Log:copy changes made to cryptography, rename method name of call site

diff --git a/lib_pypy/openssl/_cffi_src/build_openssl.py 
b/lib_pypy/openssl/_cffi_src/build_openssl.py
--- a/lib_pypy/openssl/_cffi_src/build_openssl.py
+++ b/lib_pypy/openssl/_cffi_src/build_openssl.py
@@ -7,7 +7,7 @@
 import os
 import sys
 
-from openssl._cffi_src.utils import (
+from _cffi_src.utils import (
 build_ffi_for_binding, compiler_type, extra_link_args
 )
 
diff --git a/lib_pypy/openssl/_cffi_src/hazmat_src/padding.c 
b/lib_pypy/openssl/_cffi_src/hazmat_src/padding.c
--- a/lib_pypy/openssl/_cffi_src/hazmat_src/padding.c
+++ b/lib_pypy/openssl/_cffi_src/hazmat_src/padding.c
@@ -4,25 +4,25 @@
 
 /* Returns the value of the input with the most-significant-bit copied to all
of the bits. */
-static uint8_t Cryptography_DUPLICATE_MSB_TO_ALL(uint8_t a) {
-return (1 - (a >> (sizeof(uint8_t) * 8 - 1))) - 1;
+static uint16_t Cryptography_DUPLICATE_MSB_TO_ALL(uint16_t a) {
+return (1 - (a >> (sizeof(uint16_t) * 8 - 1))) - 1;
 }
 
-/* This returns 0xFF if a < b else 0x00, but does so in a constant time
+/* This returns 0x if a < b else 0x, but does so in a constant time
fashion */
-static uint8_t Cryptography_constant_time_lt(uint8_t a, uint8_t b) {
+static uint16_t Cryptography_constant_time_lt(uint16_t a, uint16_t b) {
 a -= b;
 return Cryptography_DUPLICATE_MSB_TO_ALL(a);
 }
 
 uint8_t Cryptography_check_pkcs7_padding(const uint8_t *data,
- uint8_t block_len) {
-uint8_t i;
-uint8_t pad_size = data[block_len - 1];
-uint8_t mismatch = 0;
+ uint16_t block_len) {
+uint16_t i;
+uint16_t pad_size = data[block_len - 1];
+uint16_t mismatch = 0;
 for (i = 0; i < block_len; i++) {
 unsigned int mask = Cryptography_constant_time_lt(i, pad_size);
-uint8_t b = data[block_len - 1 - i];
+uint16_t b = data[block_len - 1 - i];
 mismatch |= (mask & (pad_size ^ b));
 }
 
@@ -31,6 +31,7 @@
 mismatch |= Cryptography_constant_time_lt(block_len, pad_size);
 
 /* Make sure any bits set are copied to the lowest bit */
+mismatch |= mismatch >> 8;
 mismatch |= mismatch >> 4;
 mismatch |= mismatch >> 2;
 mismatch |= mismatch >> 1;
@@ -39,14 +40,14 @@
 }
 
 uint8_t Cryptography_check_ansix923_padding(const uint8_t *data,
-uint8_t block_len) {
-uint8_t i;
-uint8_t pad_size = data[block_len - 1];
-uint8_t mismatch = 0;
+uint16_t block_len) {
+uint16_t i;
+uint16_t pad_size = data[block_len - 1];
+uint16_t mismatch = 0;
 /* Skip the first one with the pad size */
 for (i = 1; i < block_len; i++) {
 unsigned int mask = Cryptography_constant_time_lt(i, pad_size);
-uint8_t b = data[block_len - 1 - i];
+uint16_t b = data[block_len - 1 - i];
 mismatch |= (mask & b);
 }
 
@@ -55,6 +56,7 @@
 mismatch |= Cryptography_constant_time_lt(block_len, pad_size);
 
 /* Make sure any bits set are copied to the lowest bit */
+mismatch |= mismatch >> 8;
 mismatch |= mismatch >> 4;
 mismatch |= mismatch >> 2;
 mismatch |= mismatch >> 1;
diff --git a/lib_pypy/openssl/_cffi_src/openssl/callbacks.py 
b/lib_pypy/openssl/_cffi_src/openssl/callbacks.py
--- a/lib_pypy/openssl/_cffi_src/openssl/callbacks.py
+++ b/lib_pypy/openssl/_cffi_src/openssl/callbacks.py
@@ -12,6 +12,9 @@
 #include 
 #include 
 #include 
+#include 
+
+#include 
 """
 
 TYPES = """
@@ -37,6 +40,7 @@
 """
 
 FUNCTIONS = """
+int _setup_ssl_threads(void);
 """
 
 MACROS = """
@@ -50,4 +54,71 @@
 # backwards compatibility for old cffi version on PyPy
 # and Python >=3.5 (https://github.com/pyca/cryptography/issues/2970)
 TYPES = "static const long Cryptography_STATIC_CALLBACKS;"
-CUSTOMIZATIONS = "static const long Cryptography_STATIC_CALLBACKS = 0;"
+CUSTOMIZATIONS = """static const long Cryptography_STATIC_CALLBACKS = 0;
+"""
+
+CUSTOMIZATIONS += """
+/* This code is derived from the locking code found in the Python _ssl module's
+   locking callback for OpenSSL.
+
+   Copyright 2001-2016 Python Software Foundation; All Rights Reserved.
+*/
+
+static unsigned int _ssl_locks_count = 0;
+static PyThread_type_lock *_ssl_locks = NULL;
+
+static void _ssl_thread_locking_function(int mode, int n, const char *file,
+ int line) {
+/* this function is needed to perform locking on shared data
+   structures. (Note that OpenSSL uses a number of global data
+   structures that will be implicitly shared whenever multiple
+   threads use OpenSSL.) Multi-threaded applications will
+   crash at random if it is not set

[pypy-commit] pypy py3.5-ssl: remove the old pypy/module/_ssl module

2016-11-17 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5-ssl
Changeset: r88436:c22e66d77f66
Date: 2016-11-17 14:19 +0100
http://bitbucket.org/pypy/pypy/changeset/c22e66d77f66/

Log:remove the old pypy/module/_ssl module

diff too long, truncating to 2000 out of 3517 lines

diff --git a/pypy/module/_ssl/__init__.py b/pypy/module/_ssl/__init__.py
deleted file mode 100644
--- a/pypy/module/_ssl/__init__.py
+++ /dev/null
@@ -1,67 +0,0 @@
-import sys
-from rpython.rlib.rarithmetic import intmask
-from pypy.interpreter.mixedmodule import MixedModule
-from pypy.module._ssl import ssl_data
-
-class Module(MixedModule):
-"""Implementation module for SSL socket operations.
-See the socket module for documentation."""
-
-interpleveldefs = {
-'_test_decode_cert': 'interp_ssl._test_decode_cert',
-'txt2obj': 'interp_ssl.txt2obj',
-'nid2obj': 'interp_ssl.nid2obj',
-'get_default_verify_paths': 'interp_ssl.get_default_verify_paths',
-
-'SSLError': 'interp_ssl.get_error(space).w_error',
-'SSLZeroReturnError': 'interp_ssl.get_error(space).w_ZeroReturnError',
-'SSLWantReadError': 'interp_ssl.get_error(space).w_WantReadError',
-'SSLWantWriteError': 'interp_ssl.get_error(space).w_WantWriteError',
-'SSLEOFError': 'interp_ssl.get_error(space).w_EOFError',
-'SSLSyscallError': 'interp_ssl.get_error(space).w_SyscallError',
-
-'_SSLSocket': 'interp_ssl.SSLSocket',
-'_SSLContext': 'interp_ssl.SSLContext',
-'MemoryBIO': 'interp_ssl.MemoryBIO',
-}
-
-if sys.platform == 'win32':
-interpleveldefs['enum_certificates'] = 
'interp_win32.enum_certificates_w'
-interpleveldefs['enum_crls'] = 'interp_win32.enum_crls_w'
-
-appleveldefs = {
-}
-
-@classmethod
-def buildloaders(cls):
-# init the SSL module
-from pypy.module._ssl.interp_ssl import constants, HAVE_OPENSSL_RAND
-
-for constant, value in constants.iteritems():
-if constant.startswith('OP_'):
-value = intmask(value)  # Convert to C long and wrap around.
-Module.interpleveldefs[constant] = "space.wrap(%r)" % (value,)
-
-if HAVE_OPENSSL_RAND:
-Module.interpleveldefs['RAND_add'] = "interp_ssl.RAND_add"
-Module.interpleveldefs['RAND_bytes'] = "interp_ssl.RAND_bytes"
-Module.interpleveldefs['RAND_pseudo_bytes'] = 
"interp_ssl.RAND_pseudo_bytes"
-Module.interpleveldefs['RAND_status'] = "interp_ssl.RAND_status"
-Module.interpleveldefs['RAND_egd'] = "interp_ssl.RAND_egd"
-
-for name, value in ssl_data.ALERT_DESCRIPTION_CODES.items():
-Module.interpleveldefs[name] = "space.wrap(%r)" % value
-
-super(Module, cls).buildloaders()
-
-def setup_after_space_initialization(self):
-"""NOT_RPYTHON"""
-from pypy.module._ssl.interp_ssl import PWINFO_STORAGE
-PWINFO_STORAGE.clear()
-
-def startup(self, space):
-from rpython.rlib.ropenssl import init_ssl
-init_ssl()
-if space.config.objspace.usemodules.thread:
-from pypy.module._ssl.thread_lock import setup_ssl_threads
-setup_ssl_threads()
diff --git a/pypy/module/_ssl/interp_ssl.py b/pypy/module/_ssl/interp_ssl.py
deleted file mode 100644
--- a/pypy/module/_ssl/interp_ssl.py
+++ /dev/null
@@ -1,1913 +0,0 @@
-import weakref
-
-from rpython.rlib import rpoll, rsocket, rthread, rweakref, rgc
-from rpython.rlib.rarithmetic import intmask, widen, r_uint
-from rpython.rlib.ropenssl import *
-from rpython.rlib._rsocket_rffi import MAX_FD_SIZE
-from rpython.rlib.rposix import get_saved_errno
-from rpython.rlib.rweakref import RWeakValueDictionary
-from rpython.rlib.objectmodel import specialize, compute_unique_id
-from rpython.rtyper.lltypesystem import lltype, rffi
-
-from pypy.interpreter.baseobjspace import W_Root
-from pypy.interpreter.error import OperationError, oefmt, wrap_oserror
-from pypy.interpreter.gateway import interp2app, unwrap_spec
-from pypy.interpreter.typedef import TypeDef, GetSetProperty
-from pypy.interpreter.unicodehelper import fsdecode
-from pypy.module._ssl.ssl_data import (
-LIBRARY_CODES_TO_NAMES, ERROR_CODES_TO_NAMES)
-from pypy.module._socket import interp_socket
-from pypy.module.exceptions import interp_exceptions
-
-
-# user defined constants
-X509_NAME_MAXLEN = 256
-# these mirror ssl.h
-PY_SSL_ERROR_NONE, PY_SSL_ERROR_SSL = 0, 1
-PY_SSL_ERROR_WANT_READ, PY_SSL_ERROR_WANT_WRITE = 2, 3
-PY_SSL_ERROR_WANT_X509_LOOKUP = 4
-PY_SSL_ERROR_SYSCALL = 5  # look at error stack/return value/errno
-PY_SSL_ERROR_ZERO_RETURN, PY_SSL_ERROR_WANT_CONNECT = 6, 7
-# start of non ssl.h errorcodes
-PY_SSL_ERROR_EOF = 8  # special case of SSL_ERROR_SYSCALL
-PY_SSL_ERROR_INVALID_ERROR_CODE = 9
-
-PY_SSL_CERT_NONE, PY_SSL_CERT_OPTIONAL, PY_SSL_CERT_REQUIRED = 0, 1, 2
-
-PY_SSL_CLIENT, PY_SSL_SERVER = 0, 1
-
-(PY_SSL_VERSION_SSL2, PY_SSL_VERSION_SSL3,
- PY_SSL_VERSION_TLS, PY

[pypy-commit] pypy py3.5-ssl: rename openssl to _cffi_ssl

2016-11-17 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5-ssl
Changeset: r88437:032895d1e16c
Date: 2016-11-17 14:25 +0100
http://bitbucket.org/pypy/pypy/changeset/032895d1e16c/

Log:rename openssl to _cffi_ssl

diff too long, truncating to 2000 out of 18999 lines

diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -78,9 +78,3 @@
 ^.hypothesis/
 ^release/
 ^rpython/_cache$
-^lib_pypy/_.*cffi.*.c$
-^lib_pypy/_.*cffi.*.o$
-^lib_pypy/_.*cffi.*.so$
-^lib_pypy/_openssl.c$
-^lib_pypy/_openssl.o$
-^lib_pypy/_openssl.*.so$
diff --git a/lib_pypy/_cffi_ssl/.gitignore b/lib_pypy/_cffi_ssl/.gitignore
new file mode 100644
--- /dev/null
+++ b/lib_pypy/_cffi_ssl/.gitignore
@@ -0,0 +1,95 @@
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+env/
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+*.egg-info/
+.installed.cfg
+*.egg
+
+# PyInstaller
+#  Usually these files are written by a python script from a template
+#  before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*,cover
+.hypothesis/
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+local_settings.py
+
+# Flask stuff:
+instance/
+.webassets-cache
+
+# Scrapy stuff:
+.scrapy
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+target/
+
+# Jupyter Notebook
+.ipynb_checkpoints
+
+# pyenv
+.python-version
+
+# celery beat schedule file
+celerybeat-schedule
+
+# dotenv
+.env
+
+# virtualenv
+.venv/
+venv/
+ENV/
+
+# Spyder project settings
+.spyderproject
+
+# Rope project settings
+.ropeproject
+
+# Vim
+
+*.swp
+*.swo
diff --git a/lib_pypy/_cffi_ssl/LICENSE b/lib_pypy/_cffi_ssl/LICENSE
new file mode 100644
--- /dev/null
+++ b/lib_pypy/_cffi_ssl/LICENSE
@@ -0,0 +1,26 @@
+
+Except when otherwise stated (look for LICENSE files in directories or
+information at the beginning of each file) all software and
+documentation is licensed as follows: 
+
+The MIT License
+
+Permission is hereby granted, free of charge, to any person 
+obtaining a copy of this software and associated documentation 
+files (the "Software"), to deal in the Software without 
+restriction, including without limitation the rights to use, 
+copy, modify, merge, publish, distribute, sublicense, and/or 
+sell copies of the Software, and to permit persons to whom the 
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included 
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
MERCHANTABILITY, 
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
+DEALINGS IN THE SOFTWARE.
+
diff --git a/lib_pypy/_cffi_ssl/README.md b/lib_pypy/_cffi_ssl/README.md
new file mode 100644
--- /dev/null
+++ b/lib_pypy/_cffi_ssl/README.md
@@ -0,0 +1,8 @@
+# PyPy's SSL module
+
+Most of the CFFI code is copied from cryptography
+
+# Tests?
+
+Currently this module is tested using CPython's standard library test suite.
+
diff --git a/lib_pypy/_cffi_ssl/_cffi_src/.build_openssl.py.swn 
b/lib_pypy/_cffi_ssl/_cffi_src/.build_openssl.py.swn
new file mode 100644
index 
e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..180c02ff82d3363f34a334aae22c9876d4c96481
GIT binary patch

[cut]

diff --git a/lib_pypy/_cffi_ssl/_cffi_src/__init__.py 
b/lib_pypy/_cffi_ssl/_cffi_src/__init__.py
new file mode 100644
diff --git a/lib_pypy/_cffi_ssl/_cffi_src/build_commoncrypto.py 
b/lib_pypy/_cffi_ssl/_cffi_src/build_commoncrypto.py
new file mode 100644
--- /dev/null
+++ b/lib_pypy/_cffi_ssl/_cffi_src/build_commoncrypto.py
@@ -0,0 +1,33 @@
+# This file is dual licensed under the terms of the Apache License, Version
+# 2.0, and the BSD License. See the LICENSE file in the root of this repository
+# for complete details.
+
+from __future__ import absolute_import, division, print_function
+
+from _cffi_src.utils import build_ffi_for_binding
+
+
+ffi = build_ffi_for_binding(
+module_name="_commoncrypto",
+module_prefix="_cffi_src.commoncrypto.",
+modules=[
+"cf",
+"common_digest",
+"common_hmac",
+"common_key_derivation",
+"common_cryptor",
+"common_symmetric_key_wrap",
+"seccertificate",
+"secimport",
+"secitem",
+"seckey",
+"seckeychain",
+"secpolicy",
+"s

[pypy-commit] pypy py3.5-ssl: remove _ssl module from the list in pypy options

2016-11-17 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5-ssl
Changeset: r88438:0af0b1854309
Date: 2016-11-17 14:31 +0100
http://bitbucket.org/pypy/pypy/changeset/0af0b1854309/

Log:remove _ssl module from the list in pypy options

diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -36,7 +36,7 @@
 "_socket", "unicodedata", "mmap", "fcntl", "_locale", "pwd",
 "select", "zipimport", "_lsprof", "crypt", "signal", "_rawffi", "termios",
 "zlib", "bz2", "struct", "_hashlib", "_md5", "_minimal_curses",
-"thread", "itertools", "pyexpat", "_ssl", "cpyext", "array",
+"thread", "itertools", "pyexpat", "cpyext", "array",
 "binascii", "_multiprocessing", '_warnings', "_collections",
 "_multibytecodec", "_continuation", "_cffi_backend",
 "_csv", "_pypyjson", "_posixsubprocess", # "cppyy", "micronumpy"
@@ -118,7 +118,6 @@
 "zlib"  : ["rpython.rlib.rzlib"],
 "bz2"   : ["pypy.module.bz2.interp_bz2"],
 "pyexpat"   : ["pypy.module.pyexpat.interp_pyexpat"],
-"_ssl"  : ["pypy.module._ssl.interp_ssl"],
 "_hashlib"  : ["pypy.module._ssl.interp_ssl"],
 "_minimal_curses": ["pypy.module._minimal_curses.fficurses"],
 "_continuation": ["rpython.rlib.rstacklet"],
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5-refactor-sys_exc_info: hg merge py3.5

2016-11-17 Thread arigo
Author: Armin Rigo 
Branch: py3.5-refactor-sys_exc_info
Changeset: r88439:a915a719632d
Date: 2016-11-17 14:42 +
http://bitbucket.org/pypy/pypy/changeset/a915a719632d/

Log:hg merge py3.5

diff too long, truncating to 2000 out of 16450 lines

diff --git a/_pytest/__init__.py b/_pytest/__init__.py
--- a/_pytest/__init__.py
+++ b/_pytest/__init__.py
@@ -1,2 +1,2 @@
 #
-__version__ = '2.5.2'
+__version__ = '2.9.2'
diff --git a/_pytest/_argcomplete.py b/_pytest/_argcomplete.py
--- a/_pytest/_argcomplete.py
+++ b/_pytest/_argcomplete.py
@@ -88,9 +88,6 @@
 return completion
 
 if os.environ.get('_ARGCOMPLETE'):
-# argcomplete 0.5.6 is not compatible with python 2.5.6: print/with/format
-if sys.version_info[:2] < (2, 6):
-sys.exit(1)
 try:
 import argcomplete.completers
 except ImportError:
diff --git a/_pytest/_code/__init__.py b/_pytest/_code/__init__.py
new file mode 100644
--- /dev/null
+++ b/_pytest/_code/__init__.py
@@ -0,0 +1,12 @@
+""" python inspection/code generation API """
+from .code import Code  # noqa
+from .code import ExceptionInfo  # noqa
+from .code import Frame  # noqa
+from .code import Traceback  # noqa
+from .code import getrawcode  # noqa
+from .code import patch_builtins  # noqa
+from .code import unpatch_builtins  # noqa
+from .source import Source  # noqa
+from .source import compile_ as compile  # noqa
+from .source import getfslineno  # noqa
+
diff --git a/_pytest/_code/_py2traceback.py b/_pytest/_code/_py2traceback.py
new file mode 100644
--- /dev/null
+++ b/_pytest/_code/_py2traceback.py
@@ -0,0 +1,81 @@
+# copied from python-2.7.3's traceback.py
+# CHANGES:
+# - some_str is replaced, trying to create unicode strings
+#
+import types
+
+def format_exception_only(etype, value):
+"""Format the exception part of a traceback.
+
+The arguments are the exception type and value such as given by
+sys.last_type and sys.last_value. The return value is a list of
+strings, each ending in a newline.
+
+Normally, the list contains a single string; however, for
+SyntaxError exceptions, it contains several lines that (when
+printed) display detailed information about where the syntax
+error occurred.
+
+The message indicating which exception occurred is always the last
+string in the list.
+
+"""
+
+# An instance should not have a meaningful value parameter, but
+# sometimes does, particularly for string exceptions, such as
+# >>> raise string1, string2  # deprecated
+#
+# Clear these out first because issubtype(string1, SyntaxError)
+# would throw another exception and mask the original problem.
+if (isinstance(etype, BaseException) or
+isinstance(etype, types.InstanceType) or
+etype is None or type(etype) is str):
+return [_format_final_exc_line(etype, value)]
+
+stype = etype.__name__
+
+if not issubclass(etype, SyntaxError):
+return [_format_final_exc_line(stype, value)]
+
+# It was a syntax error; show exactly where the problem was found.
+lines = []
+try:
+msg, (filename, lineno, offset, badline) = value.args
+except Exception:
+pass
+else:
+filename = filename or ""
+lines.append('  File "%s", line %d\n' % (filename, lineno))
+if badline is not None:
+if isinstance(badline, bytes):  # python 2 only
+badline = badline.decode('utf-8', 'replace')
+lines.append(u'%s\n' % badline.strip())
+if offset is not None:
+caretspace = badline.rstrip('\n')[:offset].lstrip()
+# non-space whitespace (likes tabs) must be kept for alignment
+caretspace = ((c.isspace() and c or ' ') for c in caretspace)
+# only three spaces to account for offset1 == pos 0
+lines.append('   %s^\n' % ''.join(caretspace))
+value = msg
+
+lines.append(_format_final_exc_line(stype, value))
+return lines
+
+def _format_final_exc_line(etype, value):
+"""Return a list of a single line -- normal case for 
format_exception_only"""
+valuestr = _some_str(value)
+if value is None or not valuestr:
+line = "%s\n" % etype
+else:
+line = "%s: %s\n" % (etype, valuestr)
+return line
+
+def _some_str(value):
+try:
+return unicode(value)
+except Exception:
+try:
+return str(value)
+except Exception:
+pass
+return '' % type(value).__name__
diff --git a/_pytest/_code/code.py b/_pytest/_code/code.py
new file mode 100644
--- /dev/null
+++ b/_pytest/_code/code.py
@@ -0,0 +1,805 @@
+import sys
+from inspect import CO_VARARGS, CO_VARKEYWORDS
+
+import py
+
+builtin_repr = repr
+
+reprlib = py.builtin._tryimport('repr', 'reprlib')
+
+if sys.version_info[0] >= 3:
+from traceback import format_exception_only
+else:
+from ._py2traceback import format_exception_only
+
+class Code(object):
+

[pypy-commit] pypy py3.5-refactor-sys_exc_info: fix test

2016-11-17 Thread arigo
Author: Armin Rigo 
Branch: py3.5-refactor-sys_exc_info
Changeset: r88440:aed287295356
Date: 2016-11-17 14:45 +
http://bitbucket.org/pypy/pypy/changeset/aed287295356/

Log:fix test

diff --git a/pypy/interpreter/astcompiler/test/test_compiler.py 
b/pypy/interpreter/astcompiler/test/test_compiler.py
--- a/pypy/interpreter/astcompiler/test/test_compiler.py
+++ b/pypy/interpreter/astcompiler/test/test_compiler.py
@@ -869,7 +869,7 @@
 with a: pass
 """
 code = compile_with_astcompiler(source, 'exec', self.space)
-assert code.co_stacksize == 6  # i.e. <= 7, there is no systematic leak
+assert code.co_stacksize == 5  # i.e. <= 7, there is no systematic leak
 
 def test_stackeffect_bug5(self):
 source = """if 1:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5-refactor-sys_exc_info: Add a (passing) check for sys_exc_info being saved/restored in all cases

2016-11-17 Thread arigo
Author: Armin Rigo 
Branch: py3.5-refactor-sys_exc_info
Changeset: r88441:4bbf0a7c9f6c
Date: 2016-11-17 15:03 +
http://bitbucket.org/pypy/pypy/changeset/4bbf0a7c9f6c/

Log:Add a (passing) check for sys_exc_info being saved/restored in all
cases

diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py
--- a/pypy/interpreter/pyframe.py
+++ b/pypy/interpreter/pyframe.py
@@ -248,8 +248,20 @@
 """Start this frame's execution."""
 if self._is_generator_or_coroutine():
 return self.initialize_as_generator(name, qualname)
+elif we_are_translated():
+return self.execute_frame()
 else:
-return self.execute_frame()
+# untranslated: check that sys_exc_info is exactly
+# restored after running any Python function
+executioncontext = self.space.getexecutioncontext()
+exc_on_enter = executioncontext.sys_exc_info()
+try:
+w_res = self.execute_frame()
+except OperationError:
+assert exc_on_enter is executioncontext.sys_exc_info()
+raise
+assert exc_on_enter is executioncontext.sys_exc_info()
+return w_res
 run._always_inline_ = True
 
 def initialize_as_generator(self, name, qualname):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5-refactor-sys_exc_info: Before running a test, make sure sys_exc_info is cleared

2016-11-17 Thread arigo
Author: Armin Rigo 
Branch: py3.5-refactor-sys_exc_info
Changeset: r88442:0418a55cd4e9
Date: 2016-11-17 15:03 +
http://bitbucket.org/pypy/pypy/changeset/0418a55cd4e9/

Log:Before running a test, make sure sys_exc_info is cleared (might be a
left-over from a previous failing test)

diff --git a/pypy/tool/pytest/apptest.py b/pypy/tool/pytest/apptest.py
--- a/pypy/tool/pytest/apptest.py
+++ b/pypy/tool/pytest/apptest.py
@@ -212,6 +212,7 @@
 
 def execute_appex(self, space, target, *args):
 self.space = space
+space.getexecutioncontext().set_sys_exc_info(None)
 try:
 target(*args)
 except OperationError as e:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: un-recursivify all_cycles()

2016-11-17 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r88445:924339af3d65
Date: 2016-11-17 16:16 +0100
http://bitbucket.org/pypy/pypy/changeset/924339af3d65/

Log:un-recursivify all_cycles()

diff --git a/rpython/tool/algo/graphlib.py b/rpython/tool/algo/graphlib.py
--- a/rpython/tool/algo/graphlib.py
+++ b/rpython/tool/algo/graphlib.py
@@ -106,13 +106,20 @@
 for edge in edges[v]:
 if edge.target in vertices:
 edgestack.append(edge)
-visit(edge.target)
+yield visit(edge.target)
 edgestack.pop()
 stackpos[v] = None
 else:
 if stackpos[v] is not None:   # back-edge
 result.append(edgestack[stackpos[v]:])
-visit(root)
+
+pending = [visit(root)]
+while pending:
+generator = pending[-1]
+try:
+pending.append(next(generator))
+except StopIteration:
+pending.pop()
 return result
 
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Test depth_first_search

2016-11-17 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r88443:198fd97491aa
Date: 2016-11-17 16:00 +0100
http://bitbucket.org/pypy/pypy/changeset/198fd97491aa/

Log:Test depth_first_search

diff --git a/rpython/tool/algo/test/test_graphlib.py 
b/rpython/tool/algo/test/test_graphlib.py
--- a/rpython/tool/algo/test/test_graphlib.py
+++ b/rpython/tool/algo/test/test_graphlib.py
@@ -20,6 +20,22 @@
 'G': [],
 }
 
+def test_depth_first_search(self):
+# 'D' missing from the list of vertices
+lst = depth_first_search('A', list('ABCEFG'), self.edges)
+assert lst == [
+('start', 'A'),
+('start', 'B'),
+('start', 'E'),
+('start', 'C'),
+('start', 'F'),
+('stop', 'F'),
+('stop', 'C'),
+('stop', 'E'),
+('stop', 'B'),
+('stop', 'A'),
+]
+
 def test_strong_components(self):
 edges = self.edges
 saved = copy_edges(edges)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: un-recursivify depth_first_search()

2016-11-17 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r88444:c49289d2da96
Date: 2016-11-17 16:12 +0100
http://bitbucket.org/pypy/pypy/changeset/c49289d2da96/

Log:un-recursivify depth_first_search()

diff --git a/rpython/tool/algo/graphlib.py b/rpython/tool/algo/graphlib.py
--- a/rpython/tool/algo/graphlib.py
+++ b/rpython/tool/algo/graphlib.py
@@ -25,18 +25,27 @@
 return edges
 
 def depth_first_search(root, vertices, edges):
-seen = {}
+seen = set([root])
 result = []
-def visit(vertex):
-result.append(('start', vertex))
-seen[vertex] = True
-for edge in edges[vertex]:
-w = edge.target
-if w in vertices and w not in seen:
-visit(w)
-result.append(('stop', vertex))
-visit(root)
-return result
+stack = []
+while True:
+result.append(('start', root))
+stack.append((root, iter(edges[root])))
+while True:
+vertex, iterator = stack[-1]
+try:
+edge = next(iterator)
+except StopIteration:
+stack.pop()
+result.append(('stop', vertex))
+if not stack:
+return result
+else:
+w = edge.target
+if w in vertices and w not in seen:
+seen.add(w)
+root = w
+break
 
 def vertices_reachable_from(root, vertices, edges):
 for event, v in depth_first_search(root, vertices, edges):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: un-recursivify is_acyclic()

2016-11-17 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r88446:da7ce96af92c
Date: 2016-11-17 16:19 +0100
http://bitbucket.org/pypy/pypy/changeset/da7ce96af92c/

Log:un-recursivify is_acyclic()

diff --git a/rpython/tool/algo/graphlib.py b/rpython/tool/algo/graphlib.py
--- a/rpython/tool/algo/graphlib.py
+++ b/rpython/tool/algo/graphlib.py
@@ -180,14 +180,20 @@
 raise CycleFound
 if w in unvisited:
 del unvisited[w]
-visit(w)
+yield visit(w)
 del visiting[vertex]
 try:
 unvisited = vertices.copy()
 while unvisited:
 visiting = {}
 root = unvisited.popitem()[0]
-visit(root)
+pending = [visit(root)]
+while pending:
+generator = pending[-1]
+try:
+pending.append(next(generator))
+except StopIteration:
+pending.pop()
 except CycleFound:
 return False
 else:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: dead code, left over from a merge

2016-11-17 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r88448:311ce573fdad
Date: 2016-11-17 16:35 +0100
http://bitbucket.org/pypy/pypy/changeset/311ce573fdad/

Log:dead code, left over from a merge

diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py
--- a/pypy/interpreter/pyframe.py
+++ b/pypy/interpreter/pyframe.py
@@ -324,8 +324,6 @@
 raise
 except Exception as e:  # general fall-back
 raise self._convert_unexpected_exception(e)
-w_exitvalue = self.dispatch(self.pycode, next_instr,
-executioncontext)
 finally:
 executioncontext.return_trace(self, w_exitvalue)
 # it used to say self.last_exception = None
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: test and fix: math.logN(very_large_int)

2016-11-17 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r88447:5b3bd2f5c4ef
Date: 2016-11-17 16:35 +0100
http://bitbucket.org/pypy/pypy/changeset/5b3bd2f5c4ef/

Log:test and fix: math.logN(very_large_int)

diff --git a/pypy/module/math/interp_math.py b/pypy/module/math/interp_math.py
--- a/pypy/module/math/interp_math.py
+++ b/pypy/module/math/interp_math.py
@@ -191,7 +191,9 @@
 try:
 try:
 x = _get_double(space, w_x)
-except OverflowError:
+except OperationError as e:
+if not e.match(space, space.w_OverflowError):
+raise
 if not space.isinstance_w(w_x, space.w_int):
 raise
 # special case to support log(extremely-large-long)
diff --git a/pypy/module/math/test/test_math.py 
b/pypy/module/math/test/test_math.py
--- a/pypy/module/math/test/test_math.py
+++ b/pypy/module/math/test/test_math.py
@@ -167,6 +167,10 @@
 self.ftest(math.log10(100), 2)
 self.ftest(math.log10(0.01), -2)
 
+def test_log_largevalue(self):
+import math
+assert math.log2(2**1234) == 1234.0
+
 def test_acosh(self):
 import math
 self.ftest(math.acosh(1), 0)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: Seems at least this internal exception has both __cause__ and

2016-11-17 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r88449:a5e66da0d50f
Date: 2016-11-17 17:03 +0100
http://bitbucket.org/pypy/pypy/changeset/a5e66da0d50f/

Log:Seems at least this internal exception has both __cause__ and
__context__ attributes set

diff --git a/pypy/interpreter/generator.py b/pypy/interpreter/generator.py
--- a/pypy/interpreter/generator.py
+++ b/pypy/interpreter/generator.py
@@ -226,6 +226,7 @@
 space.wrap("%s raised StopIteration" %
self.KIND))
 e2.chain_exceptions(space, e)
+e2.set_cause(space, e.get_w_value(space))
 e2.record_context(space, self.frame)
 raise e2
 else:
diff --git a/pypy/interpreter/test/test_generator.py 
b/pypy/interpreter/test/test_generator.py
--- a/pypy/interpreter/test/test_generator.py
+++ b/pypy/interpreter/test/test_generator.py
@@ -775,3 +775,17 @@
 """, d)
 f = d['f']
 raises(RuntimeError, next, f(5))
+
+def test_generator_stop_cause(self):
+d = {}
+exec("""from __future__ import generator_stop
+
+def gen1():
+yield 42
+""", d)
+my_gen = d['gen1']()
+assert next(my_gen) == 42
+stop_exc = StopIteration('spam')
+e = raises(RuntimeError, my_gen.throw, StopIteration, stop_exc, None)
+assert e.value.__cause__ is stop_exc
+assert e.value.__context__ is stop_exc
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5-ssl: make new parameter optional to fix compression buildbot step

2016-11-17 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5-ssl
Changeset: r88450:04030a587cc7
Date: 2016-11-17 17:11 +0100
http://bitbucket.org/pypy/pypy/changeset/04030a587cc7/

Log:make new parameter optional to fix compression buildbot step

diff --git a/pypy/tool/build_cffi_imports.py b/pypy/tool/build_cffi_imports.py
--- a/pypy/tool/build_cffi_imports.py
+++ b/pypy/tool/build_cffi_imports.py
@@ -21,7 +21,7 @@
 "xx": None,# for testing: 'None' should be completely ignored
 }
 
-def create_cffi_import_libraries(pypy_c, options, basedir, only):
+def create_cffi_import_libraries(pypy_c, options, basedir, only=None):
 from rpython.tool.runsubprocess import run_subprocess
 
 shutil.rmtree(str(join(basedir,'lib_pypy','__pycache__')),
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5-ssl: force parameters of create_cffi_import_libraries to str paths

2016-11-17 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5-ssl
Changeset: r88451:4492eb10be95
Date: 2016-11-17 17:15 +0100
http://bitbucket.org/pypy/pypy/changeset/4492eb10be95/

Log:force parameters of create_cffi_import_libraries to str paths

diff --git a/pypy/tool/release/package.py b/pypy/tool/release/package.py
--- a/pypy/tool/release/package.py
+++ b/pypy/tool/release/package.py
@@ -84,7 +84,7 @@
 if not _fake and not pypy_runs(pypy_c):
 raise OSError("Running %r failed!" % (str(pypy_c),))
 if not options.no_cffi:
-failures = create_cffi_import_libraries(pypy_c, options, basedir)
+failures = create_cffi_import_libraries(str(pypy_c), options, 
str(basedir))
 for key, module in failures:
 print >>sys.stderr, """!!\nBuilding {0} bindings failed.
 You can either install development headers package,
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix _ssl test_ztranslation

2016-11-17 Thread rlamy
Author: Ronan Lamy 
Branch: 
Changeset: r88452:5625ca7b74d8
Date: 2016-11-17 18:47 +
http://bitbucket.org/pypy/pypy/changeset/5625ca7b74d8/

Log:fix _ssl test_ztranslation

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
@@ -182,6 +182,12 @@
 return s
 """)
 
+def teardown_method(self, method):
+# pytest may keep some objects alive.
+# So do some clean-up now without waiting for them to die
+from ..interp_ssl import SOCKET_STORAGE
+SOCKET_STORAGE._dict.clear()
+
 def test_connect(self):
 import socket, gc
 ss = socket.ssl(self.s)
@@ -484,7 +490,7 @@
 c = _socket.socket()
 c.connect(s.getsockname())
 c.setblocking(False)
-
+
 c = ctx._wrap_socket(c, False)
 try:
 exc = raises(_ssl.SSLWantReadError, c.do_handshake)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: Typo in the test, and fix the test

2016-11-17 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r88453:9a277fe1750d
Date: 2016-11-17 17:52 +0100
http://bitbucket.org/pypy/pypy/changeset/9a277fe1750d/

Log:Typo in the test, and fix the test

diff --git a/pypy/module/_collections/interp_deque.py 
b/pypy/module/_collections/interp_deque.py
--- a/pypy/module/_collections/interp_deque.py
+++ b/pypy/module/_collections/interp_deque.py
@@ -3,8 +3,9 @@
 from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.typedef import TypeDef, make_weakref_descr
 from pypy.interpreter.typedef import GetSetProperty
-from pypy.interpreter.gateway import interp2app, unwrap_spec
+from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 from pypy.interpreter.error import OperationError, oefmt
+from pypy.objspace.std.sliceobject import unwrap_start_stop
 from rpython.rlib.debug import check_nonneg
 from rpython.rlib.objectmodel import specialize
 
@@ -48,7 +49,9 @@
 self.data = [None] * BLOCKLEN
 
 class Lock(object):
-pass
+"""This is not a lock.  It is a marker to detect concurrent
+modifications (including in the single-threaded case).
+"""
 
 # 
 
@@ -340,31 +343,16 @@
 def iter(self):
 return W_DequeIter(self)
 
-def index(self, w_x, w_start=None, w_stop=None):
+@unwrap_spec(w_start=WrappedDefault(0), w_stop=WrappedDefault(sys.maxint))
+def index(self, w_x, w_start, w_stop):
 space = self.space
 w_iter = space.iter(self)
 _len = self.len
-start = 0
-stop = _len
 lock = self.getlock()
 
-if w_start is not None:
-start = space.int_w(w_start)
-if start < 0:
-start += _len
-if start < 0:
-start = 0
-elif start > _len:
-start = _len
+start, stop = unwrap_start_stop(space, _len, w_start, w_stop)
 
-if w_stop is not None:
-stop = space.int_w(w_stop)
-if stop < 0:
-stop += _len
-if 0 <= stop > _len:
-stop = _len
-
-for i in range(0, stop):
+for i in range(0, min(_len, stop)):
 try:
 w_obj = space.next(w_iter)
 if i < start:
diff --git a/pypy/module/_collections/test/test_deque.py 
b/pypy/module/_collections/test/test_deque.py
--- a/pypy/module/_collections/test/test_deque.py
+++ b/pypy/module/_collections/test/test_deque.py
@@ -416,4 +416,4 @@
 import sys
 elements = 'ABCDEFGHI'
 d = deque([-2, -1, 0, 0, 1, 2])
-assert a.index(0, -4*sys.maxsize, 4*sys.maxsize) == 2
+assert d.index(0, -4*sys.maxsize, 4*sys.maxsize) == 2
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: Pass _multiprocessing/test/test_connection.py -k test_exception

2016-11-17 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r88454:8a4da5e45a8c
Date: 2016-11-17 17:59 +0100
http://bitbucket.org/pypy/pypy/changeset/8a4da5e45a8c/

Log:Pass _multiprocessing/test/test_connection.py -k test_exception

diff --git a/pypy/module/_multiprocessing/interp_connection.py 
b/pypy/module/_multiprocessing/interp_connection.py
--- a/pypy/module/_multiprocessing/interp_connection.py
+++ b/pypy/module/_multiprocessing/interp_connection.py
@@ -2,6 +2,7 @@
 from errno import EINTR
 
 from rpython.rlib import rpoll, rsocket
+from rpython.rlib.objectmodel import we_are_translated
 from rpython.rlib.rarithmetic import intmask
 from rpython.rtyper.lltypesystem import lltype, rffi
 
@@ -29,7 +30,10 @@
 w_builtins, '__import__', space.wrap("pickle"))
 
 def BufferTooShort(space, w_data):
-w_BufferTooShort = space.fromcache(State).w_BufferTooShort
+state = space.fromcache(State)
+if not we_are_translated() and not hasattr(state, 'w_BufferTooShort'):
+state.init(space)   # xxx for test/test_connection.py
+w_BufferTooShort = state.w_BufferTooShort
 return OperationError(w_BufferTooShort, w_data)
 
 def w_handle(space, handle):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: Fix test

2016-11-17 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r88456:b6bd9894b86e
Date: 2016-11-17 18:22 +0100
http://bitbucket.org/pypy/pypy/changeset/b6bd9894b86e/

Log:Fix test

diff --git a/pypy/module/exceptions/test/test_exc.py 
b/pypy/module/exceptions/test/test_exc.py
--- a/pypy/module/exceptions/test/test_exc.py
+++ b/pypy/module/exceptions/test/test_exc.py
@@ -395,7 +395,12 @@
 source = case.format(keyword)
 exc = raises(SyntaxError, exec_, source)
 assert custom_msg in exc.value.msg
-assert exc.value.args[0] == 'invalid syntax'
+# XXX the following line passes on CPython but not on
+# PyPy, but do we really care about this single special
+# case?
+#assert exc.value.args[0] == 'invalid syntax'
+
 source = source.replace("foo", "(foo.)")
 exc = raises(SyntaxError, exec_, source)
-assert custom_msg not in exc.value.msg
+assert (custom_msg not in exc.value.msg) == (
+('print (' in source or 'exec (' in source))
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: Allow the current behavior as correct too (see comments)

2016-11-17 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r88455:d80ac9390f6f
Date: 2016-11-17 18:11 +0100
http://bitbucket.org/pypy/pypy/changeset/d80ac9390f6f/

Log:Allow the current behavior as correct too (see comments)

diff --git a/pypy/module/array/test/test_array.py 
b/pypy/module/array/test/test_array.py
--- a/pypy/module/array/test/test_array.py
+++ b/pypy/module/array/test/test_array.py
@@ -182,7 +182,22 @@
 b = self.array(t, b'\x00' * a.itemsize * 2)
 assert len(b) == 2 and b[0] == 0 and b[1] == 0
 if t in 'bB':
-raises(BufferError, a.frombytes, a)
+old_items = a.tolist()
+try:
+a.frombytes(a)
+except BufferError:
+# CPython behavior:
+# "cannot resize an array that is exporting buffers"
+# This is the general error we get when we try to
+# resize the array while a buffer to that array is
+# alive.
+assert a.tolist() == old_items
+else:
+# PyPy behavior: we can't reasonably implement that.
+# It's harder to crash PyPy in this case, but not
+# impossible, because of get_raw_address().  Too
+# bad I suppose.
+assert a.tolist() == old_items * 2
 else:
 raises(TypeError, a.frombytes, a)
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: check for NULL strides (prevent crash in cython tests)

2016-11-17 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r88457:e782e19bf1de
Date: 2016-11-18 00:34 +0200
http://bitbucket.org/pypy/pypy/changeset/e782e19bf1de/

Log:check for NULL strides (prevent crash in cython tests)

diff --git a/pypy/module/cpyext/slotdefs.py b/pypy/module/cpyext/slotdefs.py
--- a/pypy/module/cpyext/slotdefs.py
+++ b/pypy/module/cpyext/slotdefs.py
@@ -386,7 +386,10 @@
 size = pybuf.c_len
 ndim = widen(pybuf.c_ndim)
 shape =   [pybuf.c_shape[i]   for i in range(ndim)]
-strides = [pybuf.c_strides[i] for i in range(ndim)]
+if pybuf.c_strides:
+strides = [pybuf.c_strides[i] for i in range(ndim)]
+else:
+strides = [1]
 if pybuf.c_format:
 format = rffi.charp2str(pybuf.c_format)
 else:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: Implement http://bugs.python.org/issue17636

2016-11-17 Thread rlamy
Author: Ronan Lamy 
Branch: py3.5
Changeset: r88458:3dc6e1434de4
Date: 2016-11-18 01:50 +
http://bitbucket.org/pypy/pypy/changeset/3dc6e1434de4/

Log:Implement http://bugs.python.org/issue17636

diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -1019,14 +1019,25 @@
 def IMPORT_FROM(self, nameindex, next_instr):
 w_name = self.getname_w(nameindex)
 w_module = self.peekvalue()
+self.pushvalue(self.import_from(w_module, w_name))
+
+def import_from(self, w_module, w_name):
+space = self.space
 try:
-w_obj = self.space.getattr(w_module, w_name)
+return space.getattr(w_module, w_name)
 except OperationError as e:
-if not e.match(self.space, self.space.w_AttributeError):
+if not e.match(space, space.w_AttributeError):
 raise
-raise oefmt(self.space.w_ImportError,
-"cannot import name %R", w_name)
-self.pushvalue(w_obj)
+try:
+w_pkgname = space.getattr(
+w_module, space.newunicode(u'__name__'))
+w_fullname = space.newunicode(u'%s.%s' %
+(space.unicode_w(w_pkgname), space.unicode_w(w_name)))
+return space.getitem(space.sys.get('modules'), w_fullname)
+except OperationError:
+raise oefmt(
+space.w_ImportError, "cannot import name %R", w_name)
+
 
 def YIELD_VALUE(self, oparg, next_instr):
 raise Yield
diff --git a/pypy/module/imp/test/test_import.py 
b/pypy/module/imp/test/test_import.py
--- a/pypy/module/imp/test/test_import.py
+++ b/pypy/module/imp/test/test_import.py
@@ -128,6 +128,10 @@
  a = '',
  b = '',
  c = '')
+setuppkg('circular',
+ circ1="from . import circ2",
+ circ2="from . import circ1")
+
 p = setuppkg("encoded",
  # actually a line 2, setuppkg() sets up a line1
  line2 = "# encoding: iso-8859-1\n",
@@ -179,7 +183,7 @@
 
 class AppTestImport(BaseFSEncodeTest):
 spaceconfig = {
-"usemodules": ['_md5', 'time', 'struct', '_pypyjson'],
+"usemodules": ['_md5', 'time', 'struct'],
 }
 
 def setup_class(cls):
@@ -510,6 +514,9 @@
 check_absolute()
 raises(TypeError, check_relative)
 
+def test_relative_circular(self):
+import circular.circ1  # doesn't fail
+
 def test_import_function(self):
 # More tests for __import__
 import sys
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: Ensure that binascii.crc_hqx() only returns values below 0xffff (cpython issue #23728)

2016-11-17 Thread rlamy
Author: Ronan Lamy 
Branch: py3.5
Changeset: r88459:d897004ed662
Date: 2016-11-18 02:26 +
http://bitbucket.org/pypy/pypy/changeset/d897004ed662/

Log:Ensure that binascii.crc_hqx() only returns values below 0x
(cpython issue #23728)

diff --git a/pypy/module/binascii/interp_hqx.py 
b/pypy/module/binascii/interp_hqx.py
--- a/pypy/module/binascii/interp_hqx.py
+++ b/pypy/module/binascii/interp_hqx.py
@@ -240,7 +240,7 @@
 @unwrap_spec(data='bufferstr', oldcrc=int)
 def crc_hqx(space, data, oldcrc):
 "Compute hqx CRC incrementally."
-crc = oldcrc
+crc = oldcrc & 0x
 for c in data:
 crc = ((crc << 8) & 0xff00) ^ crctab_hqx[((crc >> 8) & 0xff) ^ ord(c)]
 return space.wrap(crc)
diff --git a/pypy/module/binascii/test/test_binascii.py 
b/pypy/module/binascii/test/test_binascii.py
--- a/pypy/module/binascii/test/test_binascii.py
+++ b/pypy/module/binascii/test/test_binascii.py
@@ -314,6 +314,7 @@
 def test_crc_hqx(self):
 for input, initial, expected in [
 (b"", 0, 0),
+(b'', 0x12345, 0x2345),
 (b"", 123, 123),
 (b"hello", 321, 28955),
 (b"world", 65535, 12911),
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit