[pypy-commit] pypy py3k: merge default

2016-10-09 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r87685:e0d72435262a
Date: 2016-10-09 19:59 -0700
http://bitbucket.org/pypy/pypy/changeset/e0d72435262a/

Log:merge default

diff --git a/pypy/interpreter/test/test_zzpickle_and_slow.py 
b/pypy/interpreter/test/test_zzpickle_and_slow.py
--- a/pypy/interpreter/test/test_zzpickle_and_slow.py
+++ b/pypy/interpreter/test/test_zzpickle_and_slow.py
@@ -391,10 +391,10 @@
 def test_pickle_reversesequenceiter_stopped(self):
 import pickle
 iter = reversed([])
-raises(StopIteration, iter.next)
+raises(StopIteration, next, iter)
 pckl   = pickle.dumps(iter)
 result = pickle.loads(pckl)
-raises(StopIteration, result.next)
+raises(StopIteration, next, result)
 
 # This test used to be marked xfail and it tried to test for the past
 # support of pickling dictiter objects.
@@ -428,10 +428,10 @@
 raise IndexError
 for it in (), IE():
 iter = reversed(it)
-raises(StopIteration, iter.next)
+raises(StopIteration, next, iter)
 pckl   = pickle.dumps(iter)
 result = pickle.loads(pckl)
-raises(StopIteration, result.next)
+raises(StopIteration, next, result)
 
 def test_pickle_enum(self):
 import pickle
diff --git a/pypy/objspace/std/test/test_iterobject.py 
b/pypy/objspace/std/test/test_iterobject.py
--- a/pypy/objspace/std/test/test_iterobject.py
+++ b/pypy/objspace/std/test/test_iterobject.py
@@ -120,8 +120,8 @@
 n = 10
 d = range(n)
 it = reversed(d)
-it.next()
-it.next()
+next(it)
+next(it)
 assert it.__length_hint__() == n-2
 d.append(n)
 assert it.__length_hint__() == n-2
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: merge default

2016-10-09 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r87681:6434baec5a74
Date: 2016-10-09 18:01 -0700
http://bitbucket.org/pypy/pypy/changeset/6434baec5a74/

Log:merge default

diff too long, truncating to 2000 out of 38623 lines

diff --git a/lib-python/2.7/BaseHTTPServer.py b/lib-python/2.7/BaseHTTPServer.py
--- a/lib-python/2.7/BaseHTTPServer.py
+++ b/lib-python/2.7/BaseHTTPServer.py
@@ -362,14 +362,25 @@
 message = short
 explain = long
 self.log_error("code %d, message %s", code, message)
-# using _quote_html to prevent Cross Site Scripting attacks (see bug 
#1100201)
-content = (self.error_message_format %
-   {'code': code, 'message': _quote_html(message), 'explain': 
explain})
 self.send_response(code, message)
-self.send_header("Content-Type", self.error_content_type)
 self.send_header('Connection', 'close')
+
+# Message body is omitted for cases described in:
+#  - RFC7230: 3.3. 1xx, 204(No Content), 304(Not Modified)
+#  - RFC7231: 6.3.6. 205(Reset Content)
+content = None
+if code >= 200 and code not in (204, 205, 304):
+# HTML encode to prevent Cross Site Scripting attacks
+# (see bug #1100201)
+content = (self.error_message_format % {
+'code': code,
+'message': _quote_html(message),
+'explain': explain
+})
+self.send_header("Content-Type", self.error_content_type)
 self.end_headers()
-if self.command != 'HEAD' and code >= 200 and code not in (204, 304):
+
+if self.command != 'HEAD' and content:
 self.wfile.write(content)
 
 error_message_format = DEFAULT_ERROR_MESSAGE
diff --git a/lib-python/2.7/CGIHTTPServer.py b/lib-python/2.7/CGIHTTPServer.py
--- a/lib-python/2.7/CGIHTTPServer.py
+++ b/lib-python/2.7/CGIHTTPServer.py
@@ -84,7 +84,7 @@
 path begins with one of the strings in self.cgi_directories
 (and the next character is a '/' or the end of the string).
 """
-collapsed_path = _url_collapse_path(urllib.unquote(self.path))
+collapsed_path = _url_collapse_path(self.path)
 dir_sep = collapsed_path.find('/', 1)
 head, tail = collapsed_path[:dir_sep], collapsed_path[dir_sep+1:]
 if head in self.cgi_directories:
@@ -120,11 +120,7 @@
 break
 
 # find an explicit query string, if present.
-i = rest.rfind('?')
-if i >= 0:
-rest, query = rest[:i], rest[i+1:]
-else:
-query = ''
+rest, _, query = rest.partition('?')
 
 # dissect the part after the directory name into a script name &
 # a possible additional path, to be stored in PATH_INFO.
@@ -308,13 +304,15 @@
 The utility of this function is limited to is_cgi method and helps
 preventing some security attacks.
 
-Returns: A tuple of (head, tail) where tail is everything after the final /
-and head is everything before it.  Head will always start with a '/' and,
-if it contains anything else, never have a trailing '/'.
+Returns: The reconstituted URL, which will always start with a '/'.
 
 Raises: IndexError if too many '..' occur within the path.
 
 """
+# Query component should not be involved.
+path, _, query = path.partition('?')
+path = urllib.unquote(path)
+
 # Similar to os.path.split(os.path.normpath(path)) but specific to URL
 # path semantics rather than local operating system semantics.
 path_parts = path.split('/')
@@ -335,6 +333,9 @@
 else:
 tail_part = ''
 
+if query:
+tail_part = '?'.join((tail_part, query))
+
 splitpath = ('/' + '/'.join(head_parts), tail_part)
 collapsed_path = "/".join(splitpath)
 
diff --git a/lib-python/2.7/Cookie.py b/lib-python/2.7/Cookie.py
--- a/lib-python/2.7/Cookie.py
+++ b/lib-python/2.7/Cookie.py
@@ -190,7 +190,7 @@
 Backwards Compatibility
 ---
 
-In order to keep compatibilty with earlier versions of Cookie.py,
+In order to keep compatibility with earlier versions of Cookie.py,
 it is still possible to use Cookie.Cookie() to create a Cookie.  In
 fact, this simply returns a SmartCookie.
 
diff --git a/lib-python/2.7/SimpleHTTPServer.py 
b/lib-python/2.7/SimpleHTTPServer.py
--- a/lib-python/2.7/SimpleHTTPServer.py
+++ b/lib-python/2.7/SimpleHTTPServer.py
@@ -167,9 +167,9 @@
 words = filter(None, words)
 path = os.getcwd()
 for word in words:
-drive, word = os.path.splitdrive(word)
-head, word = os.path.split(word)
-if word in (os.curdir, os.pardir): continue
+if os.path.dirname(word) or word in (os.curdir, os.pardir):
+# Ignore components that are not a simple file/directory name
+continue
 path = os.path.join(path, word)
 if 

[pypy-commit] pypy py3k: merge default

2016-10-09 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r87678:ce7a5c1077b4
Date: 2016-10-09 17:35 -0700
http://bitbucket.org/pypy/pypy/changeset/ce7a5c1077b4/

Log:merge default

diff too long, truncating to 2000 out of 2071 lines

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
@@ -67,3 +67,8 @@
 Change the ``timeit`` module: it now prints the average time and the standard
 deviation over 7 runs by default, instead of the minimum. The minimum is often
 misleading.
+
+.. branch: unrecursive-opt
+
+Make optimiseopt iterative instead of recursive so it can be reasoned about
+more easily and debugging is faster.
diff --git a/pypy/module/faulthandler/faulthandler.c 
b/pypy/module/faulthandler/faulthandler.c
--- a/pypy/module/faulthandler/faulthandler.c
+++ b/pypy/module/faulthandler/faulthandler.c
@@ -323,7 +323,7 @@
 faulthandler_register(int signum, int chain, _Py_sighandler_t *p_previous)
 {
 struct sigaction action;
-action.sa_handler = faulthandler_user;
+action.sa_sigaction = faulthandler_user;
 sigemptyset(_mask);
 /* if the signal is received while the kernel is executing a system
call, try to restart the system call instead of interrupting it and
diff --git a/rpython/jit/backend/tool/viewcode.py 
b/rpython/jit/backend/tool/viewcode.py
--- a/rpython/jit/backend/tool/viewcode.py
+++ b/rpython/jit/backend/tool/viewcode.py
@@ -28,7 +28,7 @@
 pass
 
 def find_objdump():
-exe = ('objdump', 'gobjdump')
+exe = ('objdump', 'gobjdump', 'objdump.exe')
 path = os.environ['PATH'].split(os.pathsep)
 for e in exe:
 for p in path:
diff --git a/rpython/jit/metainterp/optimizeopt/earlyforce.py 
b/rpython/jit/metainterp/optimizeopt/earlyforce.py
--- a/rpython/jit/metainterp/optimizeopt/earlyforce.py
+++ b/rpython/jit/metainterp/optimizeopt/earlyforce.py
@@ -26,7 +26,7 @@
 
 for arg in op.getarglist():
 self.optimizer.force_box(arg, self)
-self.emit_operation(op)
+return self.emit(op)
 
 def setup(self):
 self.optimizer.optearlyforce = self
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
@@ -128,7 +128,7 @@
 if a is optheap.postponed_op:
 optheap.emit_postponed_op()
 break
-optheap.next_optimization.propagate_forward(op)
+optheap.emit_extra(op, emit=False)
 if not can_cache:
 return
 # Once it is done, we can put at least one piece of information
@@ -259,7 +259,7 @@
 if self.postponed_op:
 postponed_op = self.postponed_op
 self.postponed_op = None
-self.next_optimization.propagate_forward(postponed_op)
+self.emit_extra(postponed_op, emit=False)
 
 def produce_potential_short_preamble_ops(self, sb):
 descrkeys = self.cached_fields.keys()
@@ -312,7 +312,7 @@
 cf = submap[index] = ArrayCachedItem(index)
 return cf
 
-def emit_operation(self, op):
+def emit(self, op):
 self.emitting_operation(op)
 self.emit_postponed_op()
 opnum = op.opnum
@@ -320,7 +320,7 @@
 or rop.is_ovf(opnum)):
 self.postponed_op = op
 else:
-Optimization.emit_operation(self, op)
+return Optimization.emit(self, op)
 
 def emitting_operation(self, op):
 if rop.has_no_side_effect(op.opnum):
@@ -370,7 +370,7 @@
 if oopspecindex == EffectInfo.OS_DICT_LOOKUP:
 if self._optimize_CALL_DICT_LOOKUP(op):
 return
-self.emit_operation(op)
+return self.emit(op)
 optimize_CALL_F = optimize_CALL_I
 optimize_CALL_R = optimize_CALL_I
 optimize_CALL_N = optimize_CALL_I
@@ -428,7 +428,7 @@
 def optimize_GUARD_NO_EXCEPTION(self, op):
 if self.last_emitted_operation is REMOVED:
 return
-self.emit_operation(op)
+return self.emit(op)
 
 optimize_GUARD_EXCEPTION = optimize_GUARD_NO_EXCEPTION
 
@@ -543,12 +543,21 @@
 return
 # default case: produce the operation
 self.make_nonnull(op.getarg(0))
-self.emit_operation(op)
+# return self.emit(op)
+return self.emit(op)
+
+def postprocess_GETFIELD_GC_I(self, op):
 # then remember the result of reading the field
-structinfo.setfield(descr, op.getarg(0), op, optheap=self, cf=cf)
+structinfo = self.ensure_ptr_info_arg0(op)
+cf = self.field_cache(op.getdescr())
+structinfo.setfield(op.getdescr(), op.getarg(0), op, optheap=self,
+cf=cf)
 optimize_GETFIELD_GC_R = optimize_GETFIELD_GC_I
 optimize_GETFIELD_GC_F = 

[pypy-commit] pypy py3k: merge default

2016-10-05 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: py3k
Changeset: r87586:c0c28e08bb1c
Date: 2016-10-04 17:53 +0200
http://bitbucket.org/pypy/pypy/changeset/c0c28e08bb1c/

Log:merge default

(the methodcall stuff needed a slightly different approach than on
default)

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
@@ -57,3 +57,7 @@
 .. branch: test-cpyext
 
 Refactor cpyext testing to be more pypy3-friendly.
+
+.. branch: better-error-missing-self
+
+Improve the error message when the user forgot the "self" argument of a method.
diff --git a/pypy/interpreter/argument.py b/pypy/interpreter/argument.py
--- a/pypy/interpreter/argument.py
+++ b/pypy/interpreter/argument.py
@@ -23,7 +23,8 @@
 ###  Construction  ###
 #@enforceargs(keywords=[unicode])
 def __init__(self, space, args_w, keywords=None, keywords_w=None,
- w_stararg=None, w_starstararg=None, keyword_names_w=None):
+ w_stararg=None, w_starstararg=None, keyword_names_w=None,
+ methodcall=False):
 self.space = space
 assert isinstance(args_w, list)
 self.arguments_w = args_w
@@ -43,6 +44,9 @@
 # a flag that specifies whether the JIT can unroll loops that operate
 # on the keywords
 self._jit_few_keywords = self.keywords is None or 
jit.isconstant(len(self.keywords))
+# a flag whether this is likely a method call, which doesn't change the
+# behaviour but produces better error messages
+self.methodcall = methodcall
 
 def __repr__(self):
 """ NOT_RPYTHON """
@@ -270,7 +274,11 @@
 for i in range(co_argcount, co_argcount + co_kwonlyargcount):
 if scope_w[i] is not None:
 kwonly_given += 1
-raise ArgErrTooMany(signature.num_argnames(),
+if self.methodcall:
+cls = ArgErrTooManyMethod
+else:
+cls = ArgErrTooMany
+raise cls(signature,
 0 if defaults_w is None else len(defaults_w),
 avail, kwonly_given)
 
@@ -498,14 +506,14 @@
 
 
 class ArgErrTooMany(ArgErr):
-def __init__(self, num_args, num_defaults, given, kwonly_given):
-self.num_args = num_args
+def __init__(self, signature, num_defaults, given, kwonly_given):
+self.signature = signature
 self.num_defaults = num_defaults
 self.given = given
 self.kwonly_given = kwonly_given
 
 def getmsg(self):
-num_args = self.num_args
+num_args = self.signature.num_argnames()
 num_defaults = self.num_defaults
 if num_defaults:
 takes_str = "from %d to %d positional arguments" % (
@@ -524,6 +532,22 @@
 msg = "takes %s but %s given" % (takes_str, given_str)
 return msg
 
+class ArgErrTooManyMethod(ArgErrTooMany):
+""" A subclass of ArgErrCount that is used if the argument matching is done
+as part of a method call, in which case more information is added to the
+error message, if the cause of the error is likely a forgotten `self`
+argument.
+"""
+
+def getmsg(self):
+msg = ArgErrTooMany.getmsg(self)
+n = self.signature.num_argnames()
+if (self.given == n + 1 and
+(n == 0 or self.signature.argnames[0] != "self")):
+msg += ". Did you forget 'self' in the function definition?"
+return msg
+
+
 class ArgErrMultipleValues(ArgErr):
 
 def __init__(self, argname):
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1117,7 +1117,8 @@
 args = Arguments(self, list(args_w))
 return self.call_args(w_func, args)
 
-def call_valuestack(self, w_func, nargs, frame):
+def call_valuestack(self, w_func, nargs, frame, methodcall=False):
+# methodcall is only used for better error messages in argument.py
 from pypy.interpreter.function import Function, Method, is_builtin_code
 if frame.get_is_being_profiled() and is_builtin_code(w_func):
 # XXX: this code is copied :-( from the slow path below
@@ -1131,10 +1132,12 @@
 # reuse callable stack place for w_inst
 frame.settopvalue(w_func.w_instance, nargs)
 nargs += 1
+methodcall = True
 w_func = w_func.w_function
 
 if isinstance(w_func, Function):
-return w_func.funccall_valuestack(nargs, frame)
+return w_func.funccall_valuestack(
+nargs, frame, methodcall=methodcall)
 # end of hack for performance
 
 args = frame.make_arguments(nargs)
diff --git a/pypy/interpreter/function.py b/pypy/interpreter/function.py
--- 

[pypy-commit] pypy py3k: merge default

2016-09-22 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r87337:2bac03f27a04
Date: 2016-09-22 19:57 -0700
http://bitbucket.org/pypy/pypy/changeset/2bac03f27a04/

Log:merge default

diff --git a/lib_pypy/_winapi.py b/lib_pypy/_winapi.py
--- a/lib_pypy/_winapi.py
+++ b/lib_pypy/_winapi.py
@@ -22,7 +22,10 @@
 code, message = _ffi.getwinerror()
 raise WindowsError(code, message)
 
-_INVALID_HANDLE_VALUE = _ffi.cast("HANDLE", -1)
+def _int2handle(val):
+return _ffi.cast("HANDLE", val)
+
+_INVALID_HANDLE_VALUE = _int2handle(-1)
 
 class _handle(object):
 def __init__(self, c_handle):
@@ -70,9 +73,9 @@
 target = _ffi.new("HANDLE[1]")
 
 res = _kernel32.DuplicateHandle(
-_ffi.cast("HANDLE", source_process),
-_ffi.cast("HANDLE", source),
-_ffi.cast("HANDLE", target_process),
+_int2handle(source_process),
+_int2handle(source),
+_int2handle(target_process),
 target, access, inherit, options)
 
 if not res:
@@ -120,12 +123,14 @@
 if not res:
 raise _WinError()
 
-return _handle(pi.hProcess), _handle(pi.hThread), pi.dwProcessId, 
pi.dwThreadId
+return (_handle(pi.hProcess),
+_handle(pi.hThread),
+pi.dwProcessId,
+pi.dwThreadId)
 
 def WaitForSingleObject(handle, milliseconds):
 # CPython: the first argument is expected to be an integer.
-res = _kernel32.WaitForSingleObject(_ffi.cast("HANDLE", handle),
-milliseconds)
+res = _kernel32.WaitForSingleObject(_int2handle(handle), milliseconds)
 if res < 0:
 raise _WinError()
 
@@ -135,7 +140,7 @@
 # CPython: the first argument is expected to be an integer.
 code = _ffi.new("DWORD[1]")
 
-res = _kernel32.GetExitCodeProcess(_ffi.cast("HANDLE", handle), code)
+res = _kernel32.GetExitCodeProcess(_int2handle(handle), code)
 
 if not res:
 raise _WinError()
@@ -145,7 +150,7 @@
 def TerminateProcess(handle, exitcode):
 # CPython: the first argument is expected to be an integer.
 # The second argument is silently wrapped in a UINT.
-res = _kernel32.TerminateProcess(_ffi.cast("HANDLE", handle),
+res = _kernel32.TerminateProcess(_int2handle(handle),
  _ffi.cast("UINT", exitcode))
 
 if not res:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: merge default

2016-09-03 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r86855:83f439eeb461
Date: 2016-09-03 12:07 -0700
http://bitbucket.org/pypy/pypy/changeset/83f439eeb461/

Log:merge default

diff --git a/_pytest/python.py b/_pytest/python.py
--- a/_pytest/python.py
+++ b/_pytest/python.py
@@ -498,7 +498,10 @@
 """ Collector for test methods. """
 def collect(self):
 if hasinit(self.obj):
-pytest.skip("class %s.%s with __init__ won't get collected" % (
+# XXX used to be skip(), but silently skipping classes
+# XXX just because they have been written long ago is
+# XXX imho a very, very, very bad idea
+pytest.fail("class %s.%s with __init__ won't get collected" % (
 self.obj.__module__,
 self.obj.__name__,
 ))
diff --git a/lib_pypy/cffi.egg-info/PKG-INFO b/lib_pypy/cffi.egg-info/PKG-INFO
--- a/lib_pypy/cffi.egg-info/PKG-INFO
+++ b/lib_pypy/cffi.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: cffi
-Version: 1.8.0
+Version: 1.8.1
 Summary: Foreign Function Interface for Python calling C code.
 Home-page: http://cffi.readthedocs.org
 Author: Armin Rigo, Maciej Fijalkowski
diff --git a/lib_pypy/cffi/__init__.py b/lib_pypy/cffi/__init__.py
--- a/lib_pypy/cffi/__init__.py
+++ b/lib_pypy/cffi/__init__.py
@@ -4,8 +4,8 @@
 from .api import FFI, CDefError, FFIError
 from .ffiplatform import VerificationError, VerificationMissing
 
-__version__ = "1.8.0"
-__version_info__ = (1, 8, 0)
+__version__ = "1.8.1"
+__version_info__ = (1, 8, 1)
 
 # The verifier module file names are based on the CRC32 of a string that
 # contains the following version number.  It may be older than __version__
diff --git a/lib_pypy/cffi/_cffi_include.h b/lib_pypy/cffi/_cffi_include.h
--- a/lib_pypy/cffi/_cffi_include.h
+++ b/lib_pypy/cffi/_cffi_include.h
@@ -1,4 +1,20 @@
 #define _CFFI_
+
+/* We try to define Py_LIMITED_API before including Python.h.
+
+   Mess: we can only define it if Py_DEBUG, Py_TRACE_REFS and
+   Py_REF_DEBUG are not defined.  This is a best-effort approximation:
+   we can learn about Py_DEBUG from pyconfig.h, but it is unclear if
+   the same works for the other two macros.  Py_DEBUG implies them,
+   but not the other way around.
+*/
+#ifndef _CFFI_USE_EMBEDDING
+#  include 
+#  if !defined(Py_DEBUG) && !defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG)
+#define Py_LIMITED_API
+#  endif
+#endif
+
 #include 
 #ifdef __cplusplus
 extern "C" {
diff --git a/lib_pypy/cffi/_embedding.h b/lib_pypy/cffi/_embedding.h
--- a/lib_pypy/cffi/_embedding.h
+++ b/lib_pypy/cffi/_embedding.h
@@ -233,7 +233,7 @@
 f = PySys_GetObject((char *)"stderr");
 if (f != NULL && f != Py_None) {
 PyFile_WriteString("\nFrom: " _CFFI_MODULE_NAME
-   "\ncompiled with cffi version: 1.8.0"
+   "\ncompiled with cffi version: 1.8.1"
"\n_cffi_backend module: ", f);
 modules = PyImport_GetModuleDict();
 mod = PyDict_GetItemString(modules, "_cffi_backend");
diff --git a/lib_pypy/cffi/api.py b/lib_pypy/cffi/api.py
--- a/lib_pypy/cffi/api.py
+++ b/lib_pypy/cffi/api.py
@@ -652,7 +652,7 @@
 recompile(self, module_name, source,
   c_file=filename, call_c_compiler=False, **kwds)
 
-def compile(self, tmpdir='.', verbose=0, target=None):
+def compile(self, tmpdir='.', verbose=0, target=None, debug=None):
 """The 'target' argument gives the final file name of the
 compiled DLL.  Use '*' to force distutils' choice, suitable for
 regular CPython C API modules.  Use a file name ending in '.*'
@@ -669,7 +669,7 @@
 module_name, source, source_extension, kwds = self._assigned_source
 return recompile(self, module_name, source, tmpdir=tmpdir,
  target=target, source_extension=source_extension,
- compiler_verbose=verbose, **kwds)
+ compiler_verbose=verbose, debug=debug, **kwds)
 
 def init_once(self, func, tag):
 # Read _init_once_cache[tag], which is either (False, lock) if
diff --git a/lib_pypy/cffi/backend_ctypes.py b/lib_pypy/cffi/backend_ctypes.py
--- a/lib_pypy/cffi/backend_ctypes.py
+++ b/lib_pypy/cffi/backend_ctypes.py
@@ -997,29 +997,37 @@
 assert onerror is None   # XXX not implemented
 return BType(source, error)
 
+_weakref_cache_ref = None
+
 def gcp(self, cdata, destructor):
-BType = self.typeof(cdata)
+if self._weakref_cache_ref is None:
+import weakref
+class MyRef(weakref.ref):
+def __eq__(self, other):
+myref = self()
+return self is other or (
+myref is not None and myref is other())
+def __ne__(self, other):
+return not (self == other)
+  

[pypy-commit] pypy py3k: merge default

2016-08-30 Thread plan_rich
Author: Richard Plangger 
Branch: py3k
Changeset: r86723:a803524ac2de
Date: 2016-08-30 10:12 +0200
http://bitbucket.org/pypy/pypy/changeset/a803524ac2de/

Log:merge default

diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -74,6 +74,7 @@
   Seo Sanghyeon
   Ronny Pfannschmidt
   Justin Peel
+  Raffael Tfirst
   David Edelsohn
   Anders Hammarquist
   Jakub Gustak
@@ -117,7 +118,6 @@
   Wenzhu Man
   John Witulski
   Laurence Tratt
-  Raffael Tfirst
   Ivan Sichmann Freitas
   Greg Price
   Dario Bertini
@@ -141,6 +141,7 @@
   tav
   Taavi Burns
   Georg Brandl
+  Nicolas Truessel
   Bert Freudenberg
   Stian Andreassen
   Wanja Saatkamp
@@ -211,6 +212,7 @@
   Vaibhav Sood
   Alan McIntyre
   Alexander Sedov
+  p_ziesch...@yahoo.de
   Attila Gobi
   Jasper.Schulz
   Christopher Pope
@@ -221,6 +223,7 @@
   Arjun Naik
   Valentina Mukhamedzhanova
   Stefano Parmesan
+  touilleMan
   Alexis Daboville
   Jens-Uwe Mager
   Carl Meyer
@@ -229,12 +232,14 @@
   Gabriel
   Lukas Vacek
   Kunal Grover
+  Aaron Gallagher
   Andrew Dalke
   Sylvain Thenault
   Jakub Stasiak
   Nathan Taylor
   Vladimir Kryachko
   Omer Katz
+  Mark Williams
   Jacek Generowicz
   Alejandro J. Cura
   Jacob Oscarson
@@ -355,12 +360,15 @@
   yasirs
   Michael Chermside
   Anna Ravencroft
+  pizi
   Andrey Churin
   Dan Crosta
+  Eli Stevens
   Tobias Diaz
   Julien Phalip
   Roman Podoliaka
   Dan Loewenherz
+  werat
 
   Heinrich-Heine University, Germany 
   Open End AB (formerly AB Strakt), Sweden
@@ -468,15 +476,3 @@
 
 https://github.com/gperftools/gperftools/blob/master/COPYING
 
-License for 'liblzma and 'lzmaffi'
---
-
-This copy of PyPy may be linked (dynamically or statically) with the
-liblzma library, which was put in the "public domain":
-
-http://tukaani.org/xz/
-
-The cffi bindings to liblzma (in lib_pypy/_lzma.py) are derived from
-the lzmaffi project which is distributed under a BSD license:
-
-https://pypi.python.org/pypi/lzmaffi/0.3.0
diff --git a/pypy/doc/contributor.rst b/pypy/doc/contributor.rst
--- a/pypy/doc/contributor.rst
+++ b/pypy/doc/contributor.rst
@@ -44,6 +44,7 @@
   Seo Sanghyeon
   Ronny Pfannschmidt
   Justin Peel
+  Raffael Tfirst
   David Edelsohn
   Anders Hammarquist
   Jakub Gustak
@@ -87,7 +88,6 @@
   Wenzhu Man
   John Witulski
   Laurence Tratt
-  Raffael Tfirst
   Ivan Sichmann Freitas
   Greg Price
   Dario Bertini
@@ -111,6 +111,7 @@
   tav
   Taavi Burns
   Georg Brandl
+  Nicolas Truessel
   Bert Freudenberg
   Stian Andreassen
   Wanja Saatkamp
@@ -181,6 +182,7 @@
   Vaibhav Sood
   Alan McIntyre
   Alexander Sedov
+  p_ziesch...@yahoo.de
   Attila Gobi
   Jasper.Schulz
   Christopher Pope
@@ -191,6 +193,7 @@
   Arjun Naik
   Valentina Mukhamedzhanova
   Stefano Parmesan
+  touilleMan
   Alexis Daboville
   Jens-Uwe Mager
   Carl Meyer
@@ -199,12 +202,14 @@
   Gabriel
   Lukas Vacek
   Kunal Grover
+  Aaron Gallagher
   Andrew Dalke
   Sylvain Thenault
   Jakub Stasiak
   Nathan Taylor
   Vladimir Kryachko
   Omer Katz
+  Mark Williams
   Jacek Generowicz
   Alejandro J. Cura
   Jacob Oscarson
@@ -325,9 +330,12 @@
   yasirs
   Michael Chermside
   Anna Ravencroft
+  pizi
   Andrey Churin
   Dan Crosta
+  Eli Stevens
   Tobias Diaz
   Julien Phalip
   Roman Podoliaka
   Dan Loewenherz
+  werat
diff --git a/pypy/doc/release-pypy2.7-v5.4.0.rst 
b/pypy/doc/release-pypy2.7-v5.4.0.rst
--- a/pypy/doc/release-pypy2.7-v5.4.0.rst
+++ b/pypy/doc/release-pypy2.7-v5.4.0.rst
@@ -3,7 +3,8 @@
 
 
 We have released PyPy2.7 v5.4, a little under two months after PyPy2.7 v5.3.
-This new PyPy2.7 release includes further improvements to our C-API 
compatability layer (cpyext), enabling us to pass over 99% of the upstream
+This new PyPy2.7 release includes incremental improvements to our C-API
+compatability layer (cpyext), enabling us to pass over 99% of the upstream
 numpy `test suite`_. We updated built-in cffi_ support to version 1.8,
 which now supports the "limited API" mode for c-extensions on 
 CPython >=3.2.
@@ -12,9 +13,7 @@
 support to OpenBSD and Dragon Fly BSD
 
 As always, this release fixed many issues and bugs raised by the
-growing community of PyPy users. 
-
-X MORE ???
+growing community of PyPy users. We strongly recommend updating.
 
 You can download the PyPy2.7 v5.4 release here:
 
@@ -110,8 +109,8 @@
 
   * (RPython) add `rposix_scandir` portably, needed for Python 3.5
 
-  * Support for memoryview attributes (format, itemsize, ...) which also
-adds support for `PyMemoryView_FromObject`
+  * Increased but incomplete support for memoryview attributes (format, 
+itemsize, ...) which also adds support for `PyMemoryView_FromObject`
 
 * Bug Fixes
 
@@ -153,10 +152,6 @@
   * Make `hash(-1)` return -2, as CPython does, and fix all the
 ancilary places this matters
 
-  * Issues reported with our previous release were resolved_ after
-reports from users on our issue tracker at
-

[pypy-commit] pypy py3k: merge default

2016-08-28 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r86672:8d7e62c4cbd9
Date: 2016-08-28 20:10 -0700
http://bitbucket.org/pypy/pypy/changeset/8d7e62c4cbd9/

Log:merge default

diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -1159,8 +1159,8 @@
 # 'flags' might be ignored.  Check the result.
 if _WIN32:
 # 'flags' ignored
-ralloc = lltype.scoped_alloc(rwin32.LPHANDLE.TO, 1, flavor='raw')
-walloc = lltype.scoped_alloc(rwin32.LPHANDLE.TO, 1, flavor='raw')
+ralloc = lltype.scoped_alloc(rwin32.LPHANDLE.TO, 1)
+walloc = lltype.scoped_alloc(rwin32.LPHANDLE.TO, 1)
 with ralloc as pread, walloc as pwrite:
 if CreatePipe(pread, pwrite, lltype.nullptr(rffi.VOIDP.TO), 0):
 fdread = c_open_osfhandle(
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: merge default

2016-08-24 Thread plan_rich
Author: Richard Plangger 
Branch: py3k
Changeset: r86459:281ace7115cb
Date: 2016-08-24 09:59 +0200
http://bitbucket.org/pypy/pypy/changeset/281ace7115cb/

Log:merge default

diff --git a/lib_pypy/_ctypes/basics.py b/lib_pypy/_ctypes/basics.py
--- a/lib_pypy/_ctypes/basics.py
+++ b/lib_pypy/_ctypes/basics.py
@@ -166,8 +166,8 @@
 else:
 return self.value
 
-def __buffer__(self):
-return memoryview(self._buffer)
+def __buffer__(self, flags):
+return buffer(self._buffer)
 
 def _get_b_base(self):
 try:
@@ -208,7 +208,7 @@
 
 def cdata_from_address(self, address):
 # fix the address: turn it into as unsigned, in case it's a negative number
-address = address & (sys.maxsize * 2 + 1)
+address = address & (sys.maxint * 2 + 1)
 instance = self.__new__(self)
 lgt = getattr(self, '_length_', 1)
 instance._buffer = self._ffiarray.fromaddress(address, lgt)
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
@@ -150,3 +150,8 @@
 
 Reduce the size of the generated C code by constant-folding ``we_are_jitted``
 in non-jitcode.
+
+.. branch: memoryview-attributes
+
+Support for memoryview attributes (format, itemsize, ...).
+Extends the cpyext emulation layer.
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -585,6 +585,11 @@
 self.sys = Module(self, w_name)
 self.sys.install()
 
+from pypy.module.imp import Module
+w_name = self.wrap('imp')
+mod = Module(self, w_name)
+mod.install()
+
 from pypy.module.__builtin__ import Module
 w_name = self.wrap('builtins')
 self.builtin = Module(self, w_name)
@@ -1993,7 +1998,7 @@
 
 ObjSpace.IrregularOpTable = [
 'wrap',
-'bytes_w',
+'str_w',
 'int_w',
 'float_w',
 'uint_w',
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -120,7 +120,7 @@
 Py_TPFLAGS_READY Py_TPFLAGS_READYING Py_TPFLAGS_HAVE_GETCHARBUFFER
 METH_COEXIST METH_STATIC METH_CLASS Py_TPFLAGS_BASETYPE
 METH_NOARGS METH_VARARGS METH_KEYWORDS METH_O
-Py_TPFLAGS_HEAPTYPE Py_TPFLAGS_HAVE_CLASS
+Py_TPFLAGS_HEAPTYPE Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_HAVE_NEWBUFFER
 Py_LT Py_LE Py_EQ Py_NE Py_GT Py_GE Py_TPFLAGS_CHECKTYPES
 Py_CLEANUP_SUPPORTED
 """.split()
@@ -651,6 +651,7 @@
 #('smalltable', rffi.CFixedArray(Py_ssize_t, 2)),
 ('internal', rffi.VOIDP)
 ))
+Py_bufferP = lltype.Ptr(Py_buffer)
 
 @specialize.memo()
 def is_PyObject(TYPE):
diff --git a/pypy/module/cpyext/buffer.py b/pypy/module/cpyext/buffer.py
--- a/pypy/module/cpyext/buffer.py
+++ b/pypy/module/cpyext/buffer.py
@@ -1,8 +1,37 @@
+from pypy.interpreter.error import oefmt
 from rpython.rtyper.lltypesystem import rffi, lltype
 from rpython.rlib import buffer
 from pypy.module.cpyext.api import (
 cpython_api, CANNOT_FAIL, Py_buffer)
-from pypy.module.cpyext.pyobject import PyObject, Py_DecRef
+from pypy.module.cpyext.pyobject import PyObject
+
+@cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
+def PyObject_CheckBuffer(space, w_obj):
+"""Return 1 if obj supports the buffer interface otherwise 0."""
+return 0  # the bf_getbuffer field is never filled by cpyext
+
+@cpython_api([PyObject, lltype.Ptr(Py_buffer), rffi.INT_real],
+ rffi.INT_real, error=-1)
+def PyObject_GetBuffer(space, w_obj, view, flags):
+"""Export obj into a Py_buffer, view.  These arguments must
+never be NULL.  The flags argument is a bit field indicating what
+kind of buffer the caller is prepared to deal with and therefore what
+kind of buffer the exporter is allowed to return.  The buffer interface
+allows for complicated memory sharing possibilities, but some caller may
+not be able to handle all the complexity but may want to see if the
+exporter will let them take a simpler view to its memory.
+
+Some exporters may not be able to share memory in every possible way and
+may need to raise errors to signal to some consumers that something is
+just not possible. These errors should be a BufferError unless
+there is another error that is actually causing the problem. The
+exporter can use flags information to simplify how much of the
+Py_buffer structure is filled in with non-default values and/or
+raise an error if the object can't support a simpler view of its memory.
+
+0 is returned on success and -1 on error."""
+raise oefmt(space.w_TypeError,
+"PyPy does not yet implement the new buffer interface")
 
 @cpython_api([lltype.Ptr(Py_buffer), lltype.Char], rffi.INT_real, 
error=CANNOT_FAIL)
 def PyBuffer_IsContiguous(space, view, fortran):
diff --git a/pypy/module/cpyext/memoryobject.py 

[pypy-commit] pypy py3k: merge default

2016-05-26 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r84716:bf1da7965176
Date: 2016-05-26 12:52 -0700
http://bitbucket.org/pypy/pypy/changeset/bf1da7965176/

Log:merge default

diff --git a/lib_pypy/_winapi.py b/lib_pypy/_winapi.py
--- a/lib_pypy/_winapi.py
+++ b/lib_pypy/_winapi.py
@@ -4,6 +4,9 @@
 subprocess module on Windows.
 """
 
+import sys
+if sys.platform != 'win32':
+raise ImportError("The '_subprocess' module is only available on Windows")
 
 # Declare external Win32 functions
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: merge default

2016-05-25 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r84693:0d7d00536295
Date: 2016-05-25 20:04 -0700
http://bitbucket.org/pypy/pypy/changeset/0d7d00536295/

Log:merge default

diff --git a/lib_pypy/cffi/commontypes.py b/lib_pypy/cffi/commontypes.py
--- a/lib_pypy/cffi/commontypes.py
+++ b/lib_pypy/cffi/commontypes.py
@@ -35,8 +35,11 @@
"you call ffi.set_unicode()" % (commontype,))
 else:
 if commontype == cdecl:
-raise api.FFIError("Unsupported type: %r.  Please file a bug "
-   "if you think it should be." % 
(commontype,))
+raise api.FFIError(
+"Unsupported type: %r.  Please look at "
+"http://cffi.readthedocs.io/en/latest/cdef.html#ffi-cdef-limitations "
+"and file an issue if you think this type should really "
+"be supported." % (commontype,))
 result, quals = parser.parse_type_and_quals(cdecl)   # recursive
 
 assert isinstance(result, model.BaseTypeByIdentity)
diff --git a/pypy/module/__builtin__/functional.py 
b/pypy/module/__builtin__/functional.py
--- a/pypy/module/__builtin__/functional.py
+++ b/pypy/module/__builtin__/functional.py
@@ -117,8 +117,17 @@
 else:
 compare = space.lt
 jitdriver = min_jitdriver
+any_kwds = bool(args.keywords)
 args_w = args.arguments_w
 if len(args_w) > 1:
+if unroll and len(args_w) == 2 and not any_kwds:
+# a fast path for the common case, useful for interpreted
+# mode and to reduce the length of the jit trace
+w0, w1 = args_w
+if space.is_true(compare(w1, w0)):
+return w1
+else:
+return w0
 w_sequence = space.newtuple(args_w)
 elif len(args_w):
 w_sequence = args_w[0]
@@ -127,8 +136,8 @@
 "%s() expects at least one argument",
 implementation_of)
 w_key = None
-kwds = args.keywords
-if kwds:
+if any_kwds:
+kwds = args.keywords
 if kwds[0] == "key" and len(kwds) == 1:
 w_key = args.keywords_w[0]
 else:
diff --git a/pypy/module/__builtin__/test/test_functional.py 
b/pypy/module/__builtin__/test/test_functional.py
--- a/pypy/module/__builtin__/test/test_functional.py
+++ b/pypy/module/__builtin__/test/test_functional.py
@@ -585,6 +585,11 @@
 assert min([1, 2, 3]) == 1
 raises(TypeError, min, 1, 2, bar=2)
 raises(TypeError, min, 1, 2, key=lambda x: x, bar=2)
+assert type(min(1, 1.0)) is int
+assert type(min(1.0, 1)) is float
+assert type(min(1, 1.0, 1L)) is int
+assert type(min(1.0, 1L, 1)) is float
+assert type(min(1L, 1, 1.0)) is long
 
 def test_max(self):
 assert max(1, 2) == 2
@@ -592,3 +597,8 @@
 assert max([1, 2, 3]) == 3
 raises(TypeError, max, 1, 2, bar=2)
 raises(TypeError, max, 1, 2, key=lambda x: x, bar=2)
+assert type(max(1, 1.0)) is int
+assert type(max(1.0, 1)) is float
+assert type(max(1, 1.0, 1L)) is int
+assert type(max(1.0, 1L, 1)) is float
+assert type(max(1L, 1, 1.0)) is long
diff --git a/pypy/module/_cffi_backend/lib_obj.py 
b/pypy/module/_cffi_backend/lib_obj.py
--- a/pypy/module/_cffi_backend/lib_obj.py
+++ b/pypy/module/_cffi_backend/lib_obj.py
@@ -196,9 +196,13 @@
 if is_getattr and attr == '__dict__':
 return self.full_dict_copy()
 if is_getattr and attr == '__class__':
-return self.space.type(self)
+# used to be space.type(self).  But HAACK!
+# That makes help() behave correctly.  I couldn't
+# find a more reasonable way.  Urgh.
+from pypy.interpreter.module import Module
+return self.space.gettypeobject(Module.typedef)
 if is_getattr and attr == '__name__':
-return self.descr_repr()
+return self.space.wrap("%s.lib" % self.libname)
 raise oefmt(self.space.w_AttributeError,
 "cffi library '%s' has no function, constant "
 "or global variable named '%s'",
diff --git a/pypy/module/_cffi_backend/test/test_recompiler.py 
b/pypy/module/_cffi_backend/test/test_recompiler.py
--- a/pypy/module/_cffi_backend/test/test_recompiler.py
+++ b/pypy/module/_cffi_backend/test/test_recompiler.py
@@ -1039,8 +1039,8 @@
 assert MYFOO == 42
 assert hasattr(lib, '__dict__')
 assert lib.__all__ == ['MYFOO', 'mybar']   # but not 'myvar'
-assert lib.__name__ == repr(lib)
-assert lib.__class__ is type(lib)
+assert 

[pypy-commit] pypy py3k: merge default

2016-05-23 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r84650:09d354bfe1d5
Date: 2016-05-23 18:48 -0700
http://bitbucket.org/pypy/pypy/changeset/09d354bfe1d5/

Log:merge default

diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -1928,6 +1928,7 @@
 [rffi.CCHARP, TIMEVAL2P], rffi.INT,
 save_err=rffi.RFFI_SAVE_ERRNO)
 
+@specialize.argtype(1)
 def lutimes(pathname, times):
 if times is None:
 error = c_lutimes(pathname, lltype.nullptr(TIMEVAL2P.TO))
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: merge default

2016-05-23 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r84646:c42012dd2124
Date: 2016-05-23 16:44 -0700
http://bitbucket.org/pypy/pypy/changeset/c42012dd2124/

Log:merge default

diff --git a/rpython/jit/backend/x86/test/test_rx86_32_auto_encoding.py 
b/rpython/jit/backend/x86/test/test_rx86_32_auto_encoding.py
--- a/rpython/jit/backend/x86/test/test_rx86_32_auto_encoding.py
+++ b/rpython/jit/backend/x86/test/test_rx86_32_auto_encoding.py
@@ -1,4 +1,4 @@
-import os, random, struct
+import sys, os, random, struct
 import py
 from rpython.jit.backend.x86 import rx86
 from rpython.rlib.rarithmetic import intmask
@@ -257,6 +257,9 @@
 g.close()
 error = [line for line in got.splitlines() if 'error' in line.lower()]
 if error:
+if (sys.maxint <= 2**32 and
+'no compiled in support for x86_64' in error[0]):
+py.test.skip(error)
 raise Exception("Assembler got an error: %r" % error[0])
 error = [line for line in got.splitlines()
  if 'warning' in line.lower()]
diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -1219,21 +1219,14 @@
 if times is None:
 error = c_utime(path, lltype.nullptr(UTIMBUFP.TO))
 else:
-actime, modtime = times
 if HAVE_UTIMES:
-import math
-l_times = lltype.malloc(TIMEVAL2P.TO, 2, flavor='raw')
-fracpart, intpart = math.modf(actime)
-rffi.setintfield(l_times[0], 'c_tv_sec', int(intpart))
-rffi.setintfield(l_times[0], 'c_tv_usec', int(fracpart * 1e6))
-fracpart, intpart = math.modf(modtime)
-rffi.setintfield(l_times[1], 'c_tv_sec', int(intpart))
-rffi.setintfield(l_times[1], 'c_tv_usec', int(fracpart * 1e6))
-error = c_utimes(path, l_times)
-lltype.free(l_times, flavor='raw')
+with lltype.scoped_alloc(TIMEVAL2P.TO, 2) as l_timeval2p:
+times_to_timeval2p(times, l_timeval2p)
+error = c_utimes(path, l_timeval2p)
 else:
 # we only have utime(), which does not allow
 # sub-second resolution
+actime, modtime = times
 l_utimbuf = lltype.malloc(UTIMBUFP.TO, flavor='raw')
 l_utimbuf.c_actime  = rffi.r_time_t(actime)
 l_utimbuf.c_modtime = rffi.r_time_t(modtime)
@@ -1276,6 +1269,17 @@
 lltype.free(atime, flavor='raw')
 lltype.free(mtime, flavor='raw')
 
+def times_to_timeval2p(times, l_timeval2p):
+actime, modtime = times
+_time_to_timeval(actime, l_timeval2p[0])
+_time_to_timeval(modtime, l_timeval2p[1])
+
+def _time_to_timeval(t, l_timeval):
+import math
+fracpart, intpart = math.modf(t)
+rffi.setintfield(l_timeval, 'c_tv_sec', int(intpart))
+rffi.setintfield(l_timeval, 'c_tv_usec', int(fracpart * 1e6))
+
 if not _WIN32:
 TMSP = lltype.Ptr(TMS)
 c_times = external('times', [TMSP], CLOCK_T,
@@ -1763,6 +1767,7 @@
 class CConfig:
 _compilation_info_ = ExternalCompilationInfo(
 includes=['sys/stat.h',
+  'sys/time.h',
   'unistd.h',
   'fcntl.h'],
 )
@@ -1918,6 +1923,20 @@
 lltype.free(l_times, flavor='raw')
 handle_posix_error('utimensat', error)
 
+if HAVE_LUTIMES:
+c_lutimes = external('lutimes',
+[rffi.CCHARP, TIMEVAL2P], rffi.INT,
+save_err=rffi.RFFI_SAVE_ERRNO)
+
+def lutimes(pathname, times):
+if times is None:
+error = c_lutimes(pathname, lltype.nullptr(TIMEVAL2P.TO))
+else:
+with lltype.scoped_alloc(TIMEVAL2P.TO, 2) as l_timeval2p:
+times_to_timeval2p(times, l_timeval2p)
+error = c_lutimes(pathname, l_timeval2p)
+handle_posix_error('lutimes', error)
+
 if HAVE_MKDIRAT:
 c_mkdirat = external('mkdirat',
 [rffi.INT, rffi.CCHARP, rffi.INT], rffi.INT,
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: merge default

2016-05-22 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r84605:ba8f19066ea5
Date: 2016-05-22 15:02 -0700
http://bitbucket.org/pypy/pypy/changeset/ba8f19066ea5/

Log:merge default

diff --git a/pypy/objspace/fake/objspace.py b/pypy/objspace/fake/objspace.py
--- a/pypy/objspace/fake/objspace.py
+++ b/pypy/objspace/fake/objspace.py
@@ -291,6 +291,11 @@
 def type(self, w_obj):
 return w_some_type()
 
+def issubtype_w(self, w_sub, w_type):
+is_root(w_sub)
+is_root(w_type)
+return NonConstant(True)
+
 def isinstance_w(self, w_inst, w_type):
 is_root(w_inst)
 is_root(w_type)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: merge default

2016-05-22 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r84581:c003d9ab8b20
Date: 2016-05-22 11:19 -0700
http://bitbucket.org/pypy/pypy/changeset/c003d9ab8b20/

Log:merge default

diff --git a/pypy/interpreter/astcompiler/test/test_ast.py 
b/pypy/interpreter/astcompiler/test/test_ast.py
--- a/pypy/interpreter/astcompiler/test/test_ast.py
+++ b/pypy/interpreter/astcompiler/test/test_ast.py
@@ -1,8 +1,8 @@
 from pypy.interpreter.astcompiler import ast
 class TestAstToObject:
 def test_types(self, space):
-assert space.is_true(space.issubtype(
-ast.get(space).w_Module, ast.get(space).w_mod))
+assert space.issubtype_w(
+ast.get(space).w_Module, ast.get(space).w_mod)
   
 def test_num(self, space):
 value = space.wrap(42)
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1206,7 +1206,7 @@
 
 def abstract_issubclass_w(self, w_cls1, w_cls2):
 # Equivalent to 'issubclass(cls1, cls2)'.
-return self.is_true(self.issubtype(w_cls1, w_cls2))
+return self.issubtype_w(w_cls1, w_cls2)
 
 def abstract_isinstance_w(self, w_obj, w_cls):
 # Equivalent to 'isinstance(obj, cls)'.
@@ -1236,16 +1236,16 @@
 def exception_is_valid_obj_as_class_w(self, w_obj):
 if not self.isinstance_w(w_obj, self.w_type):
 return False
-return self.is_true(self.issubtype(w_obj, self.w_BaseException))
+return self.issubtype_w(w_obj, self.w_BaseException)
 
 def exception_is_valid_class_w(self, w_cls):
-return self.is_true(self.issubtype(w_cls, self.w_BaseException))
+return self.issubtype_w(w_cls, self.w_BaseException)
 
 def exception_getclass(self, w_obj):
 return self.type(w_obj)
 
 def exception_issubclass_w(self, w_cls1, w_cls2):
-return self.is_true(self.issubtype(w_cls1, w_cls2))
+return self.issubtype_w(w_cls1, w_cls2)
 
 def new_exception_class(self, *args, **kwargs):
 "NOT_RPYTHON; convenience method to create excceptions in modules"
diff --git a/pypy/module/__builtin__/abstractinst.py 
b/pypy/module/__builtin__/abstractinst.py
--- a/pypy/module/__builtin__/abstractinst.py
+++ b/pypy/module/__builtin__/abstractinst.py
@@ -73,11 +73,10 @@
 try:
 if space.is_w(w_pretendtype, space.type(w_obj)):
 return False # common case: obj.__class__ is type(obj)
-if allow_override:
-w_result = space.issubtype_allow_override(w_pretendtype,
-  w_klass_or_tuple)
-else:
-w_result = space.issubtype(w_pretendtype, w_klass_or_tuple)
+if not allow_override:
+return space.issubtype_w(w_pretendtype, w_klass_or_tuple)
+w_result = space.issubtype_allow_override(w_pretendtype,
+  w_klass_or_tuple)
 except OperationError as e:
 if e.async(space):
 raise
@@ -130,11 +129,9 @@
 
 # -- case (type, type)
 try:
-if allow_override:
-w_result = space.issubtype_allow_override(w_derived,
-  w_klass_or_tuple)
-else:
-w_result = space.issubtype(w_derived, w_klass_or_tuple)
+if not allow_override:
+return space.issubtype_w(w_derived, w_klass_or_tuple)
+w_result = space.issubtype_allow_override(w_derived, w_klass_or_tuple)
 except OperationError as e:   # if one of the args was not a type, ignore 
it
 if not e.match(space, space.w_TypeError):
 raise   # propagate other errors
diff --git a/pypy/module/__builtin__/descriptor.py 
b/pypy/module/__builtin__/descriptor.py
--- a/pypy/module/__builtin__/descriptor.py
+++ b/pypy/module/__builtin__/descriptor.py
@@ -20,7 +20,7 @@
 w_type = None  # unbound super object
 w_obj_or_type = space.w_None
 else:
-w_type = _supercheck(space, w_starttype, w_obj_or_type)
+w_type = _super_check(space, w_starttype, w_obj_or_type)
 self.w_starttype = w_starttype
 self.w_objtype = w_type
 self.w_self = w_obj_or_type
@@ -83,16 +83,16 @@
 raise oefmt(space.w_RuntimeError, "super(): empty __class__ cell")
 return w_starttype, w_obj
 
-def _supercheck(space, w_starttype, w_obj_or_type):
+def _super_check(space, w_starttype, w_obj_or_type):
 """Check that the super() call makes sense. Returns a type"""
 w_objtype = space.type(w_obj_or_type)
 
-if (space.is_true(space.issubtype(w_objtype, space.w_type)) and
-space.is_true(space.issubtype(w_obj_or_type, w_starttype))):
+if (space.issubtype_w(w_objtype, space.w_type) and
+

[pypy-commit] pypy py3k: merge default

2016-05-21 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r84567:e5c6a87e1f71
Date: 2016-05-21 18:12 -0700
http://bitbucket.org/pypy/pypy/changeset/e5c6a87e1f71/

Log:merge default

diff --git a/pypy/module/__builtin__/__init__.py 
b/pypy/module/__builtin__/__init__.py
--- a/pypy/module/__builtin__/__init__.py
+++ b/pypy/module/__builtin__/__init__.py
@@ -72,8 +72,8 @@
 'max'   : 'functional.max',
 'reversed'  : 'functional.W_ReversedIterator',
 'super' : 'descriptor.W_Super',
-'staticmethod'  : 'descriptor.StaticMethod',
-'classmethod'   : 'descriptor.ClassMethod',
+'staticmethod'  : 'pypy.interpreter.function.StaticMethod',
+'classmethod'   : 'pypy.interpreter.function.ClassMethod',
 'property'  : 'descriptor.W_Property',
 
 'globals'   : 'interp_inspect.globals',
diff --git a/pypy/module/__builtin__/descriptor.py 
b/pypy/module/__builtin__/descriptor.py
--- a/pypy/module/__builtin__/descriptor.py
+++ b/pypy/module/__builtin__/descriptor.py
@@ -1,31 +1,41 @@
 from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.error import OperationError, oefmt
-from pypy.interpreter.function import StaticMethod, ClassMethod
-from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
+from pypy.interpreter.gateway import WrappedDefault, interp2app, unwrap_spec
 from pypy.interpreter.typedef import (
-TypeDef, interp_attrproperty_w, generic_new_descr, GetSetProperty)
+GetSetProperty, TypeDef, generic_new_descr, interp_attrproperty_w)
 from pypy.objspace.descroperation import object_getattribute
 
 
 class W_Super(W_Root):
-def __init__(self, space, w_starttype, w_objtype, w_self):
+
+def __init__(self, space):
+self.w_starttype = None
+self.w_objtype = None
+self.w_self = None
+
+def descr_init(self, space, w_starttype=None, w_obj_or_type=None):
+if space.is_none(w_starttype):
+w_starttype, w_obj_or_type = _super_from_frame(space)
+if space.is_none(w_obj_or_type):
+w_type = None  # unbound super object
+w_obj_or_type = space.w_None
+else:
+w_type = _supercheck(space, w_starttype, w_obj_or_type)
 self.w_starttype = w_starttype
-self.w_objtype = w_objtype
-self.w_self = w_self
+self.w_objtype = w_type
+self.w_self = w_obj_or_type
 
 def get(self, space, w_obj, w_type=None):
-w = space.wrap
 if self.w_self is None or space.is_w(w_obj, space.w_None):
-return w(self)
+return self
 else:
 # if type(self) is W_Super:
 # XXX write a fast path for this common case
-w_selftype = space.type(w(self))
+w_selftype = space.type(self)
 return space.call_function(w_selftype, self.w_starttype, w_obj)
 
-@unwrap_spec(name=str)
-def getattribute(self, space, name):
-w = space.wrap
+def getattribute(self, space, w_name):
+name = space.str_w(w_name)
 # only use a special logic for bound super objects and not for
 # getting the __class__ of the super object itself.
 if self.w_objtype is not None and name != '__class__':
@@ -45,73 +55,70 @@
 return space.get_and_call_function(w_get, w_value,
w_obj, self.w_objtype)
 # fallback to object.__getattribute__()
-return space.call_function(object_getattribute(space),
-   w(self), w(name))
+return space.call_function(object_getattribute(space), self, w_name)
 
-def descr_new_super(space, w_subtype, w_starttype=None, w_obj_or_type=None):
-if space.is_none(w_starttype):
-# Call super(), without args -- fill in from __class__
-# and first local variable on the stack.
-ec = space.getexecutioncontext()
-frame = ec.gettopframe()
-code = frame.pycode
-if not code:
-raise oefmt(space.w_RuntimeError, "super(): no code object")
-if code.co_argcount == 0:
-raise oefmt(space.w_RuntimeError, "super(): no arguments")
-w_obj = frame.locals_cells_stack_w[0]
-if not w_obj:
-raise oefmt(space.w_RuntimeError, "super(): arg[0] deleted")
-index = 0
-for name in code.co_freevars:
-if name == "__class__":
-break
-index += 1
-else:
-raise oefmt(space.w_RuntimeError,
-"super(): __class__ cell not found")
-# a kind of LOAD_DEREF
-cell = frame._getcell(len(code.co_cellvars) + index)
-try:
-w_starttype = cell.get()
-except ValueError:
-raise oefmt(space.w_RuntimeError, "super(): empty __class__ cell")
-w_obj_or_type = w_obj
+def _super_from_frame(space):
+"""super() 

[pypy-commit] pypy py3k: merge default

2016-05-14 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r84433:aa1a6a3e01e0
Date: 2016-05-14 11:19 -0700
http://bitbucket.org/pypy/pypy/changeset/aa1a6a3e01e0/

Log:merge default

diff --git a/lib-python/2.7/test/test_sys_settrace.py 
b/lib-python/2.7/test/test_sys_settrace.py
--- a/lib-python/2.7/test/test_sys_settrace.py
+++ b/lib-python/2.7/test/test_sys_settrace.py
@@ -328,8 +328,8 @@
 
 def test_13_genexp(self):
 if self.using_gc:
+gc.enable()
 test_support.gc_collect()
-gc.enable()
 try:
 self.run_test(generator_example)
 # issue1265: if the trace function contains a generator,
diff --git a/rpython/memory/gc/env.py b/rpython/memory/gc/env.py
--- a/rpython/memory/gc/env.py
+++ b/rpython/memory/gc/env.py
@@ -230,7 +230,6 @@
 data = ''.join(data)
 linepos = 0
 while True:
-print linepos
 start = _findend(data, '\n' + label, linepos)
 if start < 0:
 break# done
@@ -242,11 +241,11 @@
 break
 linepos = end
 size = data[start:end]
-if size[len(size)-1] not in ('K', 'k'):# assume kilobytes for 
now
+last_char = len(size)-1
+assert 0 <= last_char < len(size)
+if size[last_char] not in ('K', 'k'):# assume kilobytes for now
 continue
-last = len(size) - 1
-assert last >= 0
-number = int(size[:last]) * 1024
+number = int(size[:last_char])* 1024
 # for now we look for the smallest of the L2 caches of the CPUs
 if number < L2cache:
 L2cache = number
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: merge default

2016-05-12 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r84412:1ba51b01cb26
Date: 2016-05-12 21:51 -0700
http://bitbucket.org/pypy/pypy/changeset/1ba51b01cb26/

Log:merge default

diff --git a/rpython/memory/gc/env.py b/rpython/memory/gc/env.py
--- a/rpython/memory/gc/env.py
+++ b/rpython/memory/gc/env.py
@@ -244,7 +244,9 @@
 size = data[start:end]
 if size[len(size)-1] not in ('K', 'k'):# assume kilobytes for 
now
 continue
-number = int(size[:len(size)-1])* 1024
+last = len(size) - 1
+assert last >= 0
+number = int(size[:last]) * 1024
 # for now we look for the smallest of the L2 caches of the CPUs
 if number < L2cache:
 L2cache = number
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: merge default (oefmt pypy/module/!(_*))

2016-05-02 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r84161:5067460e27d9
Date: 2016-05-02 18:12 -0700
http://bitbucket.org/pypy/pypy/changeset/5067460e27d9/

Log:merge default (oefmt pypy/module/!(_*))

diff too long, truncating to 2000 out of 3288 lines

diff --git a/pypy/doc/coding-guide.rst b/pypy/doc/coding-guide.rst
--- a/pypy/doc/coding-guide.rst
+++ b/pypy/doc/coding-guide.rst
@@ -266,7 +266,13 @@
 
 To raise an application-level exception::
 
-raise OperationError(space.w_XxxError, space.wrap("message"))
+from pypy.interpreter.error import oefmt
+
+raise oefmt(space.w_XxxError, "message")
+
+raise oefmt(space.w_XxxError, "file '%s' not found in '%s'", filename, dir)
+
+raise oefmt(space.w_XxxError, "file descriptor '%d' not open", fd)
 
 To catch a specific application-level exception::
 
diff --git a/pypy/module/array/interp_array.py 
b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -18,17 +18,16 @@
 @unwrap_spec(typecode=str)
 def w_array(space, w_cls, typecode, __args__):
 if len(__args__.arguments_w) > 1:
-msg = 'array() takes at most 2 arguments'
-raise OperationError(space.w_TypeError, space.wrap(msg))
+raise oefmt(space.w_TypeError, "array() takes at most 2 arguments")
 if len(typecode) != 1:
-msg = 'array() argument 1 must be char, not str'
-raise OperationError(space.w_TypeError, space.wrap(msg))
+raise oefmt(space.w_TypeError,
+"array() argument 1 must be char, not str")
 typecode = typecode[0]
 
 if space.is_w(w_cls, space.gettypeobject(W_ArrayBase.typedef)):
 if __args__.keywords:
-msg = 'array.array() does not take keyword arguments'
-raise OperationError(space.w_TypeError, space.wrap(msg))
+raise oefmt(space.w_TypeError,
+"array.array() does not take keyword arguments")
 
 for tc in unroll_typecodes:
 if typecode == tc:
@@ -52,8 +51,9 @@
 a.descr_frombytes(space, buf)
 break
 else:
-msg = 'bad typecode (must be b, B, u, h, H, i, I, l, L, q, Q, f or d)'
-raise OperationError(space.w_ValueError, space.wrap(msg))
+raise oefmt(space.w_ValueError,
+"bad typecode (must be b, B, u, h, H, i, I, l, L, q, Q, f "
+"or d)")
 
 return a
 
@@ -214,8 +214,7 @@
 Append items to array from list.
 """
 if not space.isinstance_w(w_lst, space.w_list):
-raise OperationError(space.w_TypeError,
- space.wrap("arg must be list"))
+raise oefmt(space.w_TypeError, "arg must be list")
 s = self.len
 try:
 self.fromsequence(w_lst)
@@ -272,8 +271,8 @@
 fromfile() method).
 """
 if len(s) % self.itemsize != 0:
-msg = 'string length not a multiple of item size'
-raise OperationError(self.space.w_ValueError, self.space.wrap(msg))
+raise oefmt(self.space.w_ValueError,
+"string length not a multiple of item size")
 oldlen = self.len
 new = len(s) / self.itemsize
 if not new:
@@ -303,8 +302,7 @@
 if n != 0:
 item = item[0:elems]
 self.descr_frombytes(space, item)
-msg = "not enough items in file"
-raise OperationError(space.w_EOFError, space.wrap(msg))
+raise oefmt(space.w_EOFError, "not enough items in file")
 self.descr_fromstring(space, w_item)
 
 def descr_tofile(self, space, w_f):
@@ -332,8 +330,8 @@
 if self.typecode == 'u':
 self.fromsequence(w_ustr)
 else:
-msg = "fromunicode() may only be called on type 'u' arrays"
-raise OperationError(space.w_ValueError, space.wrap(msg))
+raise oefmt(space.w_ValueError,
+"fromunicode() may only be called on type 'u' arrays")
 
 def descr_tounicode(self, space):
 """ tounicode() -> unicode
@@ -347,8 +345,8 @@
 buf = rffi.cast(UNICODE_ARRAY, self._buffer_as_unsigned())
 return space.wrap(rffi.wcharpsize2unicode(buf, self.len))
 else:
-msg = "tounicode() may only be called on type 'u' arrays"
-raise OperationError(space.w_ValueError, space.wrap(msg))
+raise oefmt(space.w_ValueError,
+"tounicode() may only be called on type 'u' arrays")
 
 def descr_buffer_info(self, space):
 """ buffer_info() -> (address, length)
@@ -420,8 +418,8 @@
 not 1, 2, 4, or 8 bytes in size, RuntimeError is raised.
 """
 if self.itemsize not in [1, 2, 4, 8]:
-msg = "byteswap not supported for this array"
-raise OperationError(space.w_RuntimeError, space.wrap(msg))
+raise 

[pypy-commit] pypy py3k: merge default (oefmt pypy/module/_*)

2016-05-02 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r84158:72ab4cdc6bd2
Date: 2016-05-02 17:47 -0700
http://bitbucket.org/pypy/pypy/changeset/72ab4cdc6bd2/

Log:merge default (oefmt pypy/module/_*)

diff too long, truncating to 2000 out of 2441 lines

diff --git a/pypy/module/__builtin__/compiling.py 
b/pypy/module/__builtin__/compiling.py
--- a/pypy/module/__builtin__/compiling.py
+++ b/pypy/module/__builtin__/compiling.py
@@ -3,7 +3,7 @@
 """
 
 from pypy.interpreter.pycode import PyCode
-from pypy.interpreter.error import OperationError
+from pypy.interpreter.error import OperationError, oefmt
 from pypy.interpreter.astcompiler import consts, ast
 from pypy.interpreter.gateway import unwrap_spec
 from pypy.interpreter.argument import Arguments
@@ -30,8 +30,7 @@
 if flags & ~(ec.compiler.compiler_flags | consts.PyCF_ONLY_AST |
  consts.PyCF_DONT_IMPLY_DEDENT | consts.PyCF_SOURCE_IS_UTF8 |
  consts.PyCF_ACCEPT_NULL_BYTES):
-raise OperationError(space.w_ValueError,
- space.wrap("compile() unrecognized flags"))
+raise oefmt(space.w_ValueError, "compile() unrecognized flags")
 
 if not dont_inherit:
 caller = ec.gettopframe_nohidden()
@@ -39,9 +38,8 @@
 flags |= ec.compiler.getcodeflags(caller.getcode())
 
 if mode not in ('exec', 'eval', 'single'):
-raise OperationError(
-space.w_ValueError,
-space.wrap("compile() arg 3 must be 'exec', 'eval' or 'single'"))
+raise oefmt(space.w_ValueError,
+"compile() arg 3 must be 'exec', 'eval' or 'single'")
 
 if space.isinstance_w(w_source, space.gettypeobject(ast.W_AST.typedef)):
 ast_node = ast.mod.from_object(space, w_source)
diff --git a/pypy/module/__builtin__/descriptor.py 
b/pypy/module/__builtin__/descriptor.py
--- a/pypy/module/__builtin__/descriptor.py
+++ b/pypy/module/__builtin__/descriptor.py
@@ -1,5 +1,5 @@
 from pypy.interpreter.baseobjspace import W_Root
-from pypy.interpreter.error import OperationError
+from pypy.interpreter.error import OperationError, oefmt
 from pypy.interpreter.function import StaticMethod, ClassMethod
 from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 from pypy.interpreter.typedef import (
@@ -100,9 +100,9 @@
 raise
 w_type = w_objtype
 if not space.is_true(space.issubtype(w_type, w_starttype)):
-raise OperationError(space.w_TypeError,
-space.wrap("super(type, obj): "
-   "obj must be an instance or subtype of type"))
+raise oefmt(space.w_TypeError,
+"super(type, obj): obj must be an instance or "
+"subtype of type")
 # XXX the details of how allocate_instance() should be used are not
 # really well defined
 w_result = space.allocate_instance(W_Super, w_subtype)
@@ -159,21 +159,18 @@
 if space.is_w(w_obj, space.w_None):
 return space.wrap(self)
 if space.is_w(self.w_fget, space.w_None):
-raise OperationError(space.w_AttributeError, space.wrap(
-"unreadable attribute"))
+raise oefmt(space.w_AttributeError, "unreadable attribute")
 return space.call_function(self.w_fget, w_obj)
 
 def set(self, space, w_obj, w_value):
 if space.is_w(self.w_fset, space.w_None):
-raise OperationError(space.w_AttributeError, space.wrap(
-"can't set attribute"))
+raise oefmt(space.w_AttributeError, "can't set attribute")
 space.call_function(self.w_fset, w_obj, w_value)
 return space.w_None
 
 def delete(self, space, w_obj):
 if space.is_w(self.w_fdel, space.w_None):
-raise OperationError(space.w_AttributeError, space.wrap(
-"can't delete attribute"))
+raise oefmt(space.w_AttributeError, "can't delete attribute")
 space.call_function(self.w_fdel, w_obj)
 return space.w_None
 
diff --git a/pypy/module/__builtin__/functional.py 
b/pypy/module/__builtin__/functional.py
--- a/pypy/module/__builtin__/functional.py
+++ b/pypy/module/__builtin__/functional.py
@@ -61,8 +61,7 @@
 else:
 w_step = space.index(w_slice.w_step)
 if space.is_true(space.eq(w_step, w_0)):
-raise OperationError(space.w_ValueError,
- space.wrap("slice step cannot be zero"))
+raise oefmt(space.w_ValueError, "slice step cannot be zero")
 negative_step = space.is_true(space.lt(w_step, w_0))
 if space.is_w(w_slice.w_start, space.w_None):
 if negative_step:
@@ -124,16 +123,18 @@
 elif len(args_w):
 w_sequence = args_w[0]
 else:
-msg = "%s() expects at least one argument" % (implementation_of,)
-raise 

[pypy-commit] pypy py3k: merge default (oefmt pypy/{objspace, tool}/)

2016-05-02 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r84156:35dcdbf2fb5d
Date: 2016-05-02 17:27 -0700
http://bitbucket.org/pypy/pypy/changeset/35dcdbf2fb5d/

Log:merge default (oefmt pypy/{objspace,tool}/)

diff --git a/pypy/objspace/descroperation.py b/pypy/objspace/descroperation.py
--- a/pypy/objspace/descroperation.py
+++ b/pypy/objspace/descroperation.py
@@ -294,8 +294,7 @@
 w_iter = space.get_and_call_function(w_descr, w_obj)
 w_next = space.lookup(w_iter, '__next__')
 if w_next is None:
-raise OperationError(space.w_TypeError,
- space.wrap("iter() returned non-iterator"))
+raise oefmt(space.w_TypeError, "iter() returned non-iterator")
 return w_iter
 
 def next(space, w_obj):
@@ -370,8 +369,7 @@
 if _check_notimplemented(space, w_res):
 return w_res
 
-raise OperationError(space.w_TypeError,
-space.wrap("operands do not support **"))
+raise oefmt(space.w_TypeError, "operands do not support **")
 
 def inplace_pow(space, w_lhs, w_rhs):
 w_impl = space.lookup(w_lhs, '__ipow__')
@@ -475,8 +473,7 @@
 def issubtype_allow_override(space, w_sub, w_type):
 w_check = space.lookup(w_type, "__subclasscheck__")
 if w_check is None:
-raise OperationError(space.w_TypeError,
- space.wrap("issubclass not supported here"))
+raise oefmt(space.w_TypeError, "issubclass not supported here")
 return space.get_and_call_function(w_check, w_type, w_sub)
 
 def isinstance_allow_override(space, w_inst, w_type):
diff --git a/pypy/objspace/std/dictproxyobject.py 
b/pypy/objspace/std/dictproxyobject.py
--- a/pypy/objspace/std/dictproxyobject.py
+++ b/pypy/objspace/std/dictproxyobject.py
@@ -63,7 +63,8 @@
 if space.is_w(space.type(w_key), space.w_unicode):
 self.setitem_str(w_dict, self.space.str_w(w_key), w_value)
 else:
-raise OperationError(space.w_TypeError, space.wrap("cannot add 
non-string keys to dict of a type"))
+raise oefmt(space.w_TypeError,
+"cannot add non-string keys to dict of a type")
 
 def setitem_str(self, w_dict, key, w_value):
 w_type = self.unerase(w_dict.dstorage)
diff --git a/pypy/objspace/std/formatting.py b/pypy/objspace/std/formatting.py
--- a/pypy/objspace/std/formatting.py
+++ b/pypy/objspace/std/formatting.py
@@ -28,27 +28,24 @@
 try:
 w_result = self.values_w[self.values_pos]
 except IndexError:
-space = self.space
-raise OperationError(space.w_TypeError, space.wrap(
-'not enough arguments for format string'))
+raise oefmt(self.space.w_TypeError,
+"not enough arguments for format string")
 else:
 self.values_pos += 1
 return w_result
 
 def checkconsumed(self):
 if self.values_pos < len(self.values_w) and self.w_valuedict is None:
-space = self.space
-raise OperationError(space.w_TypeError,
-   space.wrap('not all arguments converted '
-'during string formatting'))
+raise oefmt(self.space.w_TypeError,
+"not all arguments converted during string formatting")
 
 def std_wp_int(self, r, prefix=''):
 # use self.prec to add some '0' on the left of the number
 if self.prec >= 0:
 if self.prec > 1000:
-raise OperationError(
-self.space.w_OverflowError, self.space.wrap(
-'formatted integer is too long (precision too large?)'))
+raise oefmt(self.space.w_OverflowError,
+"formatted integer is too long (precision too "
+"large?)")
 sign = r[0] == '-'
 padding = self.prec - (len(r)-int(sign))
 if padding > 0:
@@ -164,9 +161,7 @@
 try:
 return self.fmt[self.fmtpos]
 except IndexError:
-space = self.space
-raise OperationError(space.w_ValueError,
- space.wrap("incomplete format"))
+raise oefmt(self.space.w_ValueError, "incomplete format")
 
 # Only shows up if we've already started inlining format(), so just
 # unconditionally unroll this.
@@ -182,8 +177,7 @@
 c = fmt[i]
 except IndexError:
 space = self.space
-raise OperationError(space.w_ValueError,
- space.wrap("incomplete format key"))
+raise oefmt(space.w_ValueError, "incomplete format key")
 if c == ')':
 pcount -= 1
 if pcount == 0:
@@ 

[pypy-commit] pypy py3k: merge default (oefmt pypy/interpreter/)

2016-05-02 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r84154:a4878080a536
Date: 2016-05-02 17:18 -0700
http://bitbucket.org/pypy/pypy/changeset/a4878080a536/

Log:merge default (oefmt pypy/interpreter/)

diff --git a/pypy/doc/index-of-release-notes.rst 
b/pypy/doc/index-of-release-notes.rst
--- a/pypy/doc/index-of-release-notes.rst
+++ b/pypy/doc/index-of-release-notes.rst
@@ -6,6 +6,7 @@
 
 .. toctree::
 
+   release-5.1.1.rst
release-5.1.0.rst
release-5.0.1.rst
release-5.0.0.rst
diff --git a/pypy/interpreter/argument.py b/pypy/interpreter/argument.py
--- a/pypy/interpreter/argument.py
+++ b/pypy/interpreter/argument.py
@@ -387,9 +387,7 @@
 key = space.identifier_w(w_key)
 except OperationError as e:
 if e.match(space, space.w_TypeError):
-raise OperationError(
-space.w_TypeError,
-space.wrap("keywords must be strings"))
+raise oefmt(space.w_TypeError, "keywords must be strings")
 if e.match(space, space.w_UnicodeEncodeError):
 # Allow this to pass through
 key = None
diff --git a/pypy/interpreter/astcompiler/ast.py 
b/pypy/interpreter/astcompiler/ast.py
--- a/pypy/interpreter/astcompiler/ast.py
+++ b/pypy/interpreter/astcompiler/ast.py
@@ -15,8 +15,8 @@
 def check_string(space, w_obj):
 if not (space.isinstance_w(w_obj, space.w_str) or
 space.isinstance_w(w_obj, space.w_unicode)):
-raise OperationError(space.w_TypeError, space.wrap(
-'AST string must be of type str or unicode'))
+raise oefmt(space.w_TypeError,
+"AST string must be of type str or unicode")
 return w_obj
 
 def get_field(space, w_node, name, optional):
diff --git a/pypy/interpreter/astcompiler/tools/asdl_py.py 
b/pypy/interpreter/astcompiler/tools/asdl_py.py
--- a/pypy/interpreter/astcompiler/tools/asdl_py.py
+++ b/pypy/interpreter/astcompiler/tools/asdl_py.py
@@ -420,8 +420,8 @@
 def check_string(space, w_obj):
 if not (space.isinstance_w(w_obj, space.w_str) or
 space.isinstance_w(w_obj, space.w_unicode)):
-raise OperationError(space.w_TypeError, space.wrap(
-'AST string must be of type str or unicode'))
+raise oefmt(space.w_TypeError,
+   "AST string must be of type str or unicode")
 return w_obj
 
 def get_field(space, w_node, name, optional):
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -91,8 +91,8 @@
 return space.gettypeobject(self.typedef)
 
 def setclass(self, space, w_subtype):
-raise OperationError(space.w_TypeError,
- space.wrap("__class__ assignment: only for heap 
types"))
+raise oefmt(space.w_TypeError,
+"__class__ assignment: only for heap types")
 
 def user_setup(self, space, w_subtype):
 raise NotImplementedError("only for interp-level user subclasses "
@@ -725,8 +725,7 @@
 try:
 return rthread.allocate_lock()
 except rthread.error:
-raise OperationError(self.w_RuntimeError,
- self.wrap("out of resources"))
+raise oefmt(self.w_RuntimeError, "out of resources")
 
 # Following is a friendly interface to common object space operations
 # that can be defined in term of more primitive ones.  Subclasses
@@ -986,8 +985,8 @@
 
 hint = self.int_w(w_hint)
 if hint < 0:
-raise OperationError(self.w_ValueError, self.wrap(
-"__length_hint__() should return >= 0"))
+raise oefmt(self.w_ValueError,
+"__length_hint__() should return >= 0")
 return hint
 
 def fixedview(self, w_iterable, expected_length=-1):
@@ -1328,8 +1327,7 @@
 if start < 0:
 start += seqlength
 if not (0 <= start < seqlength):
-raise OperationError(self.w_IndexError,
- self.wrap("index out of range"))
+raise oefmt(self.w_IndexError, "index out of range")
 stop = 0
 step = 0
 return start, stop, step
@@ -1349,8 +1347,7 @@
 if start < 0:
 start += seqlength
 if not (0 <= start < seqlength):
-raise OperationError(self.w_IndexError,
- self.wrap("index out of range"))
+raise oefmt(self.w_IndexError, "index out of range")
 stop = 0
 step = 0
 length = 1
@@ -1406,20 +1403,17 @@
 try:
 return bigint.tolonglong()
 except OverflowError:
-raise OperationError(self.w_OverflowError,
- self.wrap('integer too large'))
+

[pypy-commit] pypy py3k: merge default

2016-05-01 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r84114:796445937161
Date: 2016-05-01 21:43 -0700
http://bitbucket.org/pypy/pypy/changeset/796445937161/

Log:merge default

diff --git a/pypy/module/cppyy/interp_cppyy.py 
b/pypy/module/cppyy/interp_cppyy.py
--- a/pypy/module/cppyy/interp_cppyy.py
+++ b/pypy/module/cppyy/interp_cppyy.py
@@ -436,7 +436,7 @@
 s = capi.c_resolve_name(self.space, s)
 if s != self.templ_args[i]:
 raise OperationError(self.space.w_TypeError, self.space.wrap(
-"non-matching template (got %s where %s expected" % (s, 
self.templ_args[i])))
+"non-matching template (got %s where %s expected)" % (s, 
self.templ_args[i])))
 return W_CPPBoundMethod(cppthis, self)
 
 def bound_call(self, cppthis, args_w):
diff --git a/pypy/objspace/std/newformat.py b/pypy/objspace/std/newformat.py
--- a/pypy/objspace/std/newformat.py
+++ b/pypy/objspace/std/newformat.py
@@ -568,7 +568,7 @@
 msg = "Sign not allowed in string format specifier"
 raise OperationError(space.w_ValueError, space.wrap(msg))
 if self._alternate:
-msg = "Alternate form not allowed in string format specifier"
+msg = "Alternate form (#) not allowed in string format 
specifier"
 raise OperationError(space.w_ValueError, space.wrap(msg))
 if self._align == "=":
 msg = "'=' alignment not allowed in string format specifier"
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: merge default

2016-04-17 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r83725:df440f20d566
Date: 2016-04-17 17:51 -0700
http://bitbucket.org/pypy/pypy/changeset/df440f20d566/

Log:merge default

diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -111,23 +111,24 @@
   Simon Burton
   Martin Matusiak
   Konstantin Lopuhin
+  Stefano Rivera
   Wenzhu Man
   John Witulski
   Laurence Tratt
   Ivan Sichmann Freitas
   Greg Price
   Dario Bertini
-  Stefano Rivera
   Mark Pearse
   Simon Cross
+  Edd Barrett
   Andreas Sthrk
-  Edd Barrett
   Jean-Philippe St. Pierre
   Guido van Rossum
   Pavel Vinogradov
+  Spenser Bauman
   Jeremy Thurgood
   Pawe Piotr Przeradowski
-  Spenser Bauman
+  Tobias Pape
   Paul deGrandis
   Ilya Osadchiy
   marky1991
@@ -139,7 +140,7 @@
   Georg Brandl
   Bert Freudenberg
   Stian Andreassen
-  Tobias Pape
+  Mark Young
   Wanja Saatkamp
   Gerald Klix
   Mike Blume
@@ -170,9 +171,9 @@
   Yichao Yu
   Rocco Moretti
   Gintautas Miliauskas
+  Devin Jeanpierre
   Michael Twomey
   Lucian Branescu Mihaila
-  Devin Jeanpierre
   Gabriel Lavoie
   Olivier Dormond
   Jared Grubb
@@ -183,6 +184,7 @@
   Victor Stinner
   Andrews Medina
   anatoly techtonik
+  Sergey Matyunin
   Stuart Williams
   Jasper Schulz
   Christian Hudon
@@ -217,7 +219,6 @@
   Arjun Naik
   Valentina Mukhamedzhanova
   Stefano Parmesan
-  Mark Young
   Alexis Daboville
   Jens-Uwe Mager
   Carl Meyer
@@ -225,7 +226,9 @@
   Pieter Zieschang
   Gabriel
   Lukas Vacek
+  Kunal Grover
   Andrew Dalke
+  Florin Papa
   Sylvain Thenault
   Jakub Stasiak
   Nathan Taylor
@@ -240,7 +243,6 @@
   Kristjan Valur Jonsson
   David Lievens
   Neil Blakey-Milner
-  Sergey Matyunin
   Lutz Paelike
   Lucio Torre
   Lars Wassermann
@@ -252,9 +254,11 @@
   Artur Lisiecki
   Sergey Kishchenko
   Ignas Mikalajunas
+  Alecsandru Patrascu
   Christoph Gerum
   Martin Blais
   Lene Wagner
+  Catalin Gabriel Manciu
   Tomo Cocoa
   Kim Jin Su
   Toni Mattis
@@ -291,6 +295,7 @@
   Akira Li
   Gustavo Niemeyer
   Stephan Busemann
+  florinpapa
   Rafa Gaczyski
   Matt Bogosian
   Christian Muirhead
@@ -305,6 +310,7 @@
   Boglarka Vezer
   Chris Pressey
   Buck Golemon
+  Diana Popa
   Konrad Delong
   Dinu Gherman
   Chris Lambacher
diff --git a/lib_pypy/cffi.egg-info/PKG-INFO b/lib_pypy/cffi.egg-info/PKG-INFO
--- a/lib_pypy/cffi.egg-info/PKG-INFO
+++ b/lib_pypy/cffi.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: cffi
-Version: 1.5.2
+Version: 1.6.0
 Summary: Foreign Function Interface for Python calling C code.
 Home-page: http://cffi.readthedocs.org
 Author: Armin Rigo, Maciej Fijalkowski
diff --git a/lib_pypy/cffi/__init__.py b/lib_pypy/cffi/__init__.py
--- a/lib_pypy/cffi/__init__.py
+++ b/lib_pypy/cffi/__init__.py
@@ -4,8 +4,8 @@
 from .api import FFI, CDefError, FFIError
 from .ffiplatform import VerificationError, VerificationMissing
 
-__version__ = "1.5.2"
-__version_info__ = (1, 5, 2)
+__version__ = "1.6.0"
+__version_info__ = (1, 6, 0)
 
 # The verifier module file names are based on the CRC32 of a string that
 # contains the following version number.  It may be older than __version__
diff --git a/lib_pypy/cffi/_embedding.h b/lib_pypy/cffi/_embedding.h
--- a/lib_pypy/cffi/_embedding.h
+++ b/lib_pypy/cffi/_embedding.h
@@ -233,7 +233,7 @@
 f = PySys_GetObject((char *)"stderr");
 if (f != NULL && f != Py_None) {
 PyFile_WriteString("\nFrom: " _CFFI_MODULE_NAME
-   "\ncompiled with cffi version: 1.5.2"
+   "\ncompiled with cffi version: 1.6.0"
"\n_cffi_backend module: ", f);
 modules = PyImport_GetModuleDict();
 mod = PyDict_GetItemString(modules, "_cffi_backend");
diff --git a/lib_pypy/cffi/api.py b/lib_pypy/cffi/api.py
--- a/lib_pypy/cffi/api.py
+++ b/lib_pypy/cffi/api.py
@@ -299,6 +299,23 @@
 """
 return self._backend.string(cdata, maxlen)
 
+def unpack(self, cdata, length):
+"""Unpack an array of C data of the given length, 
+returning a Python string/unicode/list.
+
+If 'cdata' is a pointer to 'char', returns a byte string.
+It does not stop at the first null.  This is equivalent to:
+ffi.buffer(cdata, length)[:]
+
+If 'cdata' is a pointer to 'wchar_t', returns a unicode string.
+'length' is measured in wchar_t's; it is not the size in bytes.
+
+If 'cdata' is a pointer to anything else, returns a list of
+'length' items.  This is a faster equivalent to:
+[cdata[i] for i in range(length)]
+"""
+return self._backend.unpack(cdata, length)
+
 def buffer(self, cdata, size=-1):
 """Return a read-write buffer object that references the raw C data
 pointed to by the given 'cdata'.  The 'cdata' must be a pointer or
@@ -721,6 +738,26 @@
 raise ValueError("ffi.def_extern() is only available on API-mode FFI "
 

[pypy-commit] pypy py3k: merge default

2016-04-15 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r83695:3bc87fc47479
Date: 2016-04-15 16:10 -0700
http://bitbucket.org/pypy/pypy/changeset/3bc87fc47479/

Log:merge default

diff --git a/pypy/module/_cffi_backend/__init__.py 
b/pypy/module/_cffi_backend/__init__.py
--- a/pypy/module/_cffi_backend/__init__.py
+++ b/pypy/module/_cffi_backend/__init__.py
@@ -48,6 +48,7 @@
 'from_buffer': 'func.from_buffer',
 
 'string': 'func.string',
+'rawstring': 'func.rawstring',
 'buffer': 'cbuffer.buffer',
 'memmove': 'func.memmove',
 
diff --git a/pypy/module/_cffi_backend/ctypearray.py 
b/pypy/module/_cffi_backend/ctypearray.py
--- a/pypy/module/_cffi_backend/ctypearray.py
+++ b/pypy/module/_cffi_backend/ctypearray.py
@@ -7,11 +7,12 @@
 from pypy.interpreter.gateway import interp2app
 from pypy.interpreter.typedef import TypeDef
 
-from rpython.rtyper.lltypesystem import rffi
+from rpython.rtyper.lltypesystem import lltype, rffi
 from rpython.rlib.rarithmetic import ovfcheck
 
 from pypy.module._cffi_backend import cdataobj
 from pypy.module._cffi_backend.ctypeptr import W_CTypePtrOrArray
+from pypy.module._cffi_backend import ctypeprim
 
 
 class W_CTypeArray(W_CTypePtrOrArray):
@@ -108,6 +109,21 @@
 def typeoffsetof_index(self, index):
 return self.ctptr.typeoffsetof_index(index)
 
+def rawstring(self, w_cdata):
+if isinstance(self.ctitem, ctypeprim.W_CTypePrimitive):
+space = self.space
+length = w_cdata.get_array_length()
+if self.ctitem.size == rffi.sizeof(lltype.Char):
+with w_cdata as ptr:
+s = rffi.charpsize2str(ptr, length)
+return space.wrapbytes(s)
+elif self.is_unichar_ptr_or_array():
+with w_cdata as ptr:
+cdata = rffi.cast(rffi.CWCHARP, ptr)
+u = rffi.wcharpsize2unicode(cdata, length)
+return space.wrap(u)
+return W_CTypePtrOrArray.rawstring(self, w_cdata)
+
 
 class W_CDataIter(W_Root):
 _immutable_fields_ = ['ctitem', 'cdata', '_stop']# but not '_next'
diff --git a/pypy/module/_cffi_backend/ctypeobj.py 
b/pypy/module/_cffi_backend/ctypeobj.py
--- a/pypy/module/_cffi_backend/ctypeobj.py
+++ b/pypy/module/_cffi_backend/ctypeobj.py
@@ -127,6 +127,12 @@
 raise oefmt(space.w_TypeError,
 "string(): unexpected cdata '%s' argument", self.name)
 
+def rawstring(self, cdataobj):
+space = self.space
+raise oefmt(space.w_TypeError,
+"expected a 'char[]' or 'uint8_t[]' or 'int8_t[]' "
+"or 'wchar_t[]', got '%s'", self.name)
+
 def add(self, cdata, i):
 space = self.space
 raise oefmt(space.w_TypeError, "cannot add a cdata '%s' and a number",
diff --git a/pypy/module/_cffi_backend/ffi_obj.py 
b/pypy/module/_cffi_backend/ffi_obj.py
--- a/pypy/module/_cffi_backend/ffi_obj.py
+++ b/pypy/module/_cffi_backend/ffi_obj.py
@@ -542,6 +542,21 @@
 return w_cdata.ctype.string(w_cdata, maxlen)
 
 
+@unwrap_spec(w_cdata=W_CData)
+def descr_rawstring(self, w_cdata):
+"""\
+Convert a cdata that is an array of 'char' or 'wchar_t' to
+a byte or unicode string.  Unlike ffi.string(), it does not stop
+at the first null.
+
+Note that if you have a pointer and an explicit length, you
+can use 'p[0:length]' to make an array view.  This is similar to
+the construct 'list(p[0:length])', which returns a list of chars/
+unichars/ints/floats."""
+#
+return w_cdata.ctype.rawstring(w_cdata)
+
+
 def descr_sizeof(self, w_arg):
 """\
 Return the size in bytes of the argument.
@@ -736,6 +751,7 @@
 new_allocator = interp2app(W_FFIObject.descr_new_allocator),
 new_handle  = interp2app(W_FFIObject.descr_new_handle),
 offsetof= interp2app(W_FFIObject.descr_offsetof),
+rawstring   = interp2app(W_FFIObject.descr_rawstring),
 sizeof  = interp2app(W_FFIObject.descr_sizeof),
 string  = interp2app(W_FFIObject.descr_string),
 typeof  = interp2app(W_FFIObject.descr_typeof),
diff --git a/pypy/module/_cffi_backend/func.py 
b/pypy/module/_cffi_backend/func.py
--- a/pypy/module/_cffi_backend/func.py
+++ b/pypy/module/_cffi_backend/func.py
@@ -78,6 +78,12 @@
 
 # 
 
+@unwrap_spec(w_cdata=cdataobj.W_CData)
+def rawstring(space, w_cdata):
+return w_cdata.ctype.rawstring(w_cdata)
+
+# 
+
 def _get_types(space):
 return space.newtuple([space.gettypefor(cdataobj.W_CData),
space.gettypefor(ctypeobj.W_CType)])
diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py 
b/pypy/module/_cffi_backend/test/_backend_test_c.py
--- a/pypy/module/_cffi_backend/test/_backend_test_c.py
+++ 

[pypy-commit] pypy py3k: merge default

2015-01-02 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r75216:b85a8b82049d
Date: 2015-01-02 18:14 -0800
http://bitbucket.org/pypy/pypy/changeset/b85a8b82049d/

Log:merge default

diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py
--- a/rpython/translator/c/genc.py
+++ b/rpython/translator/c/genc.py
@@ -400,15 +400,15 @@
 mk.definition('PROFOPT', profopt)
 
 rules = [
-('clean', '', 'rm -f $(OBJECTS) $(TARGET) $(GCMAPFILES) 
$(ASMFILES) *.gc?? ../module_cache/*.gc??'),
-('clean_noprof', '', 'rm -f $(OBJECTS) $(TARGET) $(GCMAPFILES) 
$(ASMFILES)'),
+('clean', '', 'rm -f $(OBJECTS) $(DEFAULT_TARGET) $(TARGET) 
$(GCMAPFILES) $(ASMFILES) *.gc?? ../module_cache/*.gc??'),
+('clean_noprof', '', 'rm -f $(OBJECTS) $(DEFAULT_TARGET) $(TARGET) 
$(GCMAPFILES) $(ASMFILES)'),
 ('debug', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT 
debug_target'),
 ('debug_exc', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT 
-DDO_LOG_EXC debug_target'),
 ('debug_mem', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT 
-DPYPY_USE_TRIVIAL_MALLOC debug_target'),
-('llsafer', '', '$(MAKE) CFLAGS=-O2 -DRPY_LL_ASSERT $(TARGET)'),
+('llsafer', '', '$(MAKE) CFLAGS=-O2 -DRPY_LL_ASSERT 
$(DEFAULT_TARGET)'),
 ('lldebug', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT 
-DRPY_LL_ASSERT debug_target'),
 ('lldebug0','', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -O0 -DRPY_ASSERT 
-DRPY_LL_ASSERT debug_target'),
-('profile', '', '$(MAKE) CFLAGS=-g -O1 -pg $(CFLAGS) 
-fno-omit-frame-pointer LDFLAGS=-pg $(LDFLAGS) $(TARGET)'),
+('profile', '', '$(MAKE) CFLAGS=-g -O1 -pg $(CFLAGS) 
-fno-omit-frame-pointer LDFLAGS=-pg $(LDFLAGS) $(DEFAULT_TARGET)'),
 ]
 if self.has_profopt():
 rules.append(
@@ -471,7 +471,7 @@
 if self.translator.platform.name == 'msvc':
 mk.rule('debug_target', 'debugmode_$(DEFAULT_TARGET)', 'rem')
 else:
-mk.rule('debug_target', '$(TARGET)', '#')
+mk.rule('debug_target', '$(DEFAULT_TARGET)', '#')
 mk.write()
 #self.translator.platform,
 #   ,
diff --git a/rpython/translator/platform/darwin.py 
b/rpython/translator/platform/darwin.py
--- a/rpython/translator/platform/darwin.py
+++ b/rpython/translator/platform/darwin.py
@@ -14,7 +14,9 @@
 
 def _args_for_shared(self, args):
 return (list(self.shared_only)
-+ ['-dynamiclib', '-install_name', '@rpath/$(TARGET)', 
'-undefined', 'dynamic_lookup']
++ ['-dynamiclib', '-install_name',
+   '@executable_path/$(TARGET)', '-undefined',
+   'dynamic_lookup']
 + args)
 
 def _include_dirs_for_libffi(self):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: merge default

2015-01-02 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r75210:ace68169b31e
Date: 2015-01-02 12:39 -0800
http://bitbucket.org/pypy/pypy/changeset/ace68169b31e/

Log:merge default

diff too long, truncating to 2000 out of 15159 lines

diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -28,7 +28,7 @@
 DEALINGS IN THE SOFTWARE.
 
 
-PyPy Copyright holders 2003-2014
+PyPy Copyright holders 2003-2015
 --- 
 
 Except when otherwise stated (look for LICENSE files or information at
diff --git a/lib-python/2.7/distutils/unixccompiler.py 
b/lib-python/2.7/distutils/unixccompiler.py
--- a/lib-python/2.7/distutils/unixccompiler.py
+++ b/lib-python/2.7/distutils/unixccompiler.py
@@ -58,7 +58,7 @@
 executables = {'preprocessor' : None,
'compiler' : [cc],
'compiler_so'  : [cc],
-   'compiler_cxx' : [cc],
+   'compiler_cxx' : [c++],  # pypy: changed, 'cc' is bogus
'linker_so': [cc, -shared],
'linker_exe'   : [cc],
'archiver' : [ar, -cr],
diff --git a/lib-python/2.7/sqlite3/test/dbapi.py 
b/lib-python/2.7/sqlite3/test/dbapi.py
--- a/lib-python/2.7/sqlite3/test/dbapi.py
+++ b/lib-python/2.7/sqlite3/test/dbapi.py
@@ -478,6 +478,29 @@
 except TypeError:
 pass
 
+def CheckCurDescription(self):
+self.cu.execute(select * from test)
+
+actual = self.cu.description
+expected = [
+('id', None, None, None, None, None, None),
+('name', None, None, None, None, None, None),
+('income', None, None, None, None, None, None),
+]
+self.assertEqual(expected, actual)
+
+def CheckCurDescriptionVoidStatement(self):
+self.cu.execute(insert into test(name) values (?), (foo,))
+self.assertIsNone(self.cu.description)
+
+def CheckCurDescriptionWithoutStatement(self):
+cu = self.cx.cursor()
+try:
+self.assertIsNone(cu.description)
+finally:
+cu.close()
+
+
 @unittest.skipUnless(threading, 'This test requires threading.')
 class ThreadTests(unittest.TestCase):
 def setUp(self):
diff --git a/lib-python/2.7/subprocess.py b/lib-python/2.7/subprocess.py
--- a/lib-python/2.7/subprocess.py
+++ b/lib-python/2.7/subprocess.py
@@ -1589,7 +1589,7 @@
   'copyfile' in caller.f_globals):
 dest_dir = sys.pypy_resolvedirof(target_executable)
 src_dir = sys.pypy_resolvedirof(sys.executable)
-for libname in ['libpypy-c.so']:
+for libname in ['libpypy-c.so', 'libpypy-c.dylib']:
 dest_library = os.path.join(dest_dir, libname)
 src_library = os.path.join(src_dir, libname)
 if os.path.exists(src_library):
diff --git a/lib-python/2.7/test/test_collections.py 
b/lib-python/2.7/test/test_collections.py
--- a/lib-python/2.7/test/test_collections.py
+++ b/lib-python/2.7/test/test_collections.py
@@ -1108,6 +1108,16 @@
 od.popitem()
 self.assertEqual(len(od), 0)
 
+def test_popitem_first(self):
+pairs = [('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)]
+shuffle(pairs)
+od = OrderedDict(pairs)
+while pairs:
+self.assertEqual(od.popitem(last=False), pairs.pop(0))
+with self.assertRaises(KeyError):
+od.popitem(last=False)
+self.assertEqual(len(od), 0)
+
 def test_pop(self):
 pairs = [('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)]
 shuffle(pairs)
@@ -1179,7 +1189,11 @@
 od = OrderedDict(pairs)
 # yaml.dump(od) --
 # '!!python/object/apply:__main__.OrderedDict\n- - [a, 1]\n  - [b, 
2]\n'
-self.assertTrue(all(type(pair)==list for pair in od.__reduce__()[1]))
+
+# PyPy bug fix: added [0] at the end of this line, because the
+# test is really about the 2-tuples that need to be 2-lists
+# inside the list of 6 of them
+self.assertTrue(all(type(pair)==list for pair in 
od.__reduce__()[1][0]))
 
 def test_reduce_not_too_fat(self):
 # do not save instance dictionary if not needed
@@ -1189,6 +1203,16 @@
 od.x = 10
 self.assertEqual(len(od.__reduce__()), 3)
 
+def test_reduce_exact_output(self):
+# PyPy: test that __reduce__() produces the exact same answer as
+# CPython does, even though in the 'all_ordered_dicts' branch we
+# have to emulate it.
+pairs = [['c', 1], ['b', 2], ['d', 4]]
+od = OrderedDict(pairs)
+self.assertEqual(od.__reduce__(), (OrderedDict, (pairs,)))
+od.x = 10
+self.assertEqual(od.__reduce__(), (OrderedDict, (pairs,), {'x': 10}))
+
 def test_repr(self):
 od = OrderedDict([('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), 
('f', 6)])
 self.assertEqual(repr(od),
diff --git 

[pypy-commit] pypy py3k: merge default

2014-11-30 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r74767:e01964ac6c50
Date: 2014-11-30 11:51 -0800
http://bitbucket.org/pypy/pypy/changeset/e01964ac6c50/

Log:merge default

diff too long, truncating to 2000 out of 3374 lines

diff --git a/lib-python/2.7/subprocess.py b/lib-python/2.7/subprocess.py
--- a/lib-python/2.7/subprocess.py
+++ b/lib-python/2.7/subprocess.py
@@ -655,6 +655,21 @@
 Create new Popen instance.
 _cleanup()
 
+# --- PyPy hack, see _pypy_install_libs_after_virtualenv() ---
+# match arguments passed by different versions of virtualenv
+if args[1:] in (
+['-c', 'import sys; print(sys.prefix)'],# 1.6 10ba3f3c
+['-c', \nimport sys\nprefix = sys.prefix\n# 1.7 0e9342ce
+ if sys.version_info[0] == 3:\n
+ prefix = prefix.encode('utf8')\n
+ if hasattr(sys.stdout, 'detach'):\n
+ sys.stdout = sys.stdout.detach()\n
+ elif hasattr(sys.stdout, 'buffer'):\n
+ sys.stdout = sys.stdout.buffer\nsys.stdout.write(prefix)\n],
+['-c', 'import sys;out=sys.stdout;getattr(out, buffer'
+ ', out).write(sys.prefix.encode(utf-8))']):  # 1.7.2 a9454bce
+_pypy_install_libs_after_virtualenv(args[0])
+
 if not isinstance(bufsize, (int, long)):
 raise TypeError(bufsize must be an integer)
 
@@ -1560,6 +1575,27 @@
 self.send_signal(signal.SIGKILL)
 
 
+def _pypy_install_libs_after_virtualenv(target_executable):
+# https://bitbucket.org/pypy/pypy/issue/1922/future-proofing-virtualenv
+#
+# PyPy 2.4.1 turned --shared on by default.  This means the pypy binary
+# depends on the 'libpypy-c.so' shared library to be able to run.
+# The virtualenv code existing at the time did not account for this
+# and would break.  Try to detect that we're running under such a
+# virtualenv in the Testing executable with phase and copy the
+# library ourselves.
+caller = sys._getframe(2)
+if ('virtualenv_version' in caller.f_globals and
+  'copyfile' in caller.f_globals):
+dest_dir = sys.pypy_resolvedirof(target_executable)
+src_dir = sys.pypy_resolvedirof(sys.executable)
+for libname in ['libpypy-c.so']:
+dest_library = os.path.join(dest_dir, libname)
+src_library = os.path.join(src_dir, libname)
+if os.path.exists(src_library):
+caller.f_globals['copyfile'](src_library, dest_library)
+
+
 def _demo_posix():
 #
 # Example 1: Simple redirection: Get process list
diff --git a/pypy/doc/cpython_differences.rst b/pypy/doc/cpython_differences.rst
--- a/pypy/doc/cpython_differences.rst
+++ b/pypy/doc/cpython_differences.rst
@@ -205,23 +205,28 @@
 The above is true both in CPython and in PyPy.  Differences
 can occur about whether a built-in function or method will
 call an overridden method of *another* object than ``self``.
-In PyPy, they are generally always called, whereas not in
-CPython.  For example, in PyPy, ``dict1.update(dict2)``
-considers that ``dict2`` is just a general mapping object, and
-will thus call overridden ``keys()``  and ``__getitem__()``
-methods on it.  So the following code prints ``42`` on PyPy
-but ``foo`` on CPython::
+In PyPy, they are often called in cases where CPython would not.
+Two examples::
 
- class D(dict):
- def __getitem__(self, key):
- return 42
-
-
- d1 = {}
- d2 = D(a='foo')
- d1.update(d2)
- print d1['a']
-42
+class D(dict):
+def __getitem__(self, key):
+return %r from D % (key,)
+
+class A(object):
+pass
+
+a = A()
+a.__dict__ = D()
+a.foo = a's own foo
+print a.foo
+# CPython = a's own foo
+# PyPy = 'foo' from D
+
+glob = D(foo=base item)
+loc = {}
+exec print foo in glob, loc
+# CPython = base item
+# PyPy = 'foo' from D
 
 
 Mutating classes of objects which are already used as dictionary keys
@@ -292,6 +297,9 @@
 above types will return a value that is computed from the argument, and can
 thus be larger than ``sys.maxint`` (i.e. it can be an arbitrary long).
 
+Notably missing from the list above are ``str`` and ``unicode``.  If your
+code relies on comparing strings with ``is``, then it might break in PyPy.
+
 
 Miscellaneous
 -
diff --git a/pypy/interpreter/astcompiler/assemble.py 
b/pypy/interpreter/astcompiler/assemble.py
--- a/pypy/interpreter/astcompiler/assemble.py
+++ b/pypy/interpreter/astcompiler/assemble.py
@@ -1,15 +1,13 @@
-
-Python control flow graph generation and bytecode assembly.
-
+Python control flow graph generation and bytecode assembly.
 
-from pypy.interpreter.astcompiler import ast, consts, symtable
-from pypy.interpreter import pycode
+from rpython.rlib import rfloat
+from rpython.rlib.objectmodel import specialize, we_are_translated
+

[pypy-commit] pypy py3k: merge default

2014-11-30 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r74769:f682ccbce64f
Date: 2014-11-30 14:12 -0800
http://bitbucket.org/pypy/pypy/changeset/f682ccbce64f/

Log:merge default

diff too long, truncating to 2000 out of 3147 lines

diff --git a/pypy/module/_cffi_backend/ctypeprim.py 
b/pypy/module/_cffi_backend/ctypeprim.py
--- a/pypy/module/_cffi_backend/ctypeprim.py
+++ b/pypy/module/_cffi_backend/ctypeprim.py
@@ -158,21 +158,14 @@
 
 
 class W_CTypePrimitiveSigned(W_CTypePrimitive):
-_attrs_= ['value_fits_long', 'vmin', 'vrangemax']
-_immutable_fields_ = ['value_fits_long', 'vmin', 'vrangemax']
+_attrs_= ['value_fits_long', 'value_smaller_than_long']
+_immutable_fields_ = ['value_fits_long', 'value_smaller_than_long']
 is_primitive_integer = True
 
 def __init__(self, *args):
 W_CTypePrimitive.__init__(self, *args)
 self.value_fits_long = self.size = rffi.sizeof(lltype.Signed)
-if self.size  rffi.sizeof(lltype.Signed):
-assert self.value_fits_long
-sh = self.size * 8
-self.vmin = r_uint(-1)  (sh - 1)
-self.vrangemax = (r_uint(1)  sh) - 1
-else:
-self.vmin = r_uint(0)
-self.vrangemax = r_uint(-1)
+self.value_smaller_than_long = self.size  rffi.sizeof(lltype.Signed)
 
 def cast_to_int(self, cdata):
 return self.convert_to_object(cdata)
@@ -192,8 +185,17 @@
 def convert_from_object(self, cdata, w_ob):
 if self.value_fits_long:
 value = misc.as_long(self.space, w_ob)
-if self.size  rffi.sizeof(lltype.Signed):
-if r_uint(value) - self.vmin  self.vrangemax:
+if self.value_smaller_than_long:
+size = self.size
+if size == 1:
+signextended = misc.signext(value, 1)
+elif size == 2:
+signextended = misc.signext(value, 2)
+elif size == 4:
+signextended = misc.signext(value, 4)
+else:
+raise AssertionError(unsupported size)
+if value != signextended:
 self._overflow(w_ob)
 misc.write_raw_signed_data(cdata, value, self.size)
 else:
@@ -221,7 +223,7 @@
 length = w_cdata.get_array_length()
 populate_list_from_raw_array(res, buf, length)
 return res
-elif self.value_fits_long:
+elif self.value_smaller_than_long:
 res = [0] * w_cdata.get_array_length()
 misc.unpack_list_from_raw_array(res, w_cdata._cdata, self.size)
 return res
@@ -235,8 +237,8 @@
 cdata = rffi.cast(rffi.LONGP, cdata)
 copy_list_to_raw_array(int_list, cdata)
 else:
-overflowed = misc.pack_list_to_raw_array_bounds(
-int_list, cdata, self.size, self.vmin, self.vrangemax)
+overflowed = misc.pack_list_to_raw_array_bounds_signed(
+int_list, cdata, self.size)
 if overflowed != 0:
 self._overflow(self.space.wrap(overflowed))
 return True
@@ -314,8 +316,8 @@
 def pack_list_of_items(self, cdata, w_ob):
 int_list = self.space.listview_int(w_ob)
 if int_list is not None:
-overflowed = misc.pack_list_to_raw_array_bounds(
-int_list, cdata, self.size, r_uint(0), self.vrangemax)
+overflowed = misc.pack_list_to_raw_array_bounds_unsigned(
+int_list, cdata, self.size, self.vrangemax)
 if overflowed != 0:
 self._overflow(self.space.wrap(overflowed))
 return True
diff --git a/pypy/module/_cffi_backend/misc.py 
b/pypy/module/_cffi_backend/misc.py
--- a/pypy/module/_cffi_backend/misc.py
+++ b/pypy/module/_cffi_backend/misc.py
@@ -222,6 +222,19 @@
 neg_msg = can't convert negative number to unsigned
 ovf_msg = long too big to convert
 
+@specialize.arg(1)
+def signext(value, size):
+# 'value' is sign-extended from 'size' bytes to a full integer.
+# 'size' should be a constant smaller than a full integer size.
+if size == rffi.sizeof(rffi.SIGNEDCHAR):
+return rffi.cast(lltype.Signed, rffi.cast(rffi.SIGNEDCHAR, value))
+elif size == rffi.sizeof(rffi.SHORT):
+return rffi.cast(lltype.Signed, rffi.cast(rffi.SHORT, value))
+elif size == rffi.sizeof(rffi.INT):
+return rffi.cast(lltype.Signed, rffi.cast(rffi.INT, value))
+else:
+raise AssertionError(unsupported size)
+
 # 
 
 class _NotStandardObject(Exception):
@@ -339,13 +352,26 @@
 
 # 
 
-def pack_list_to_raw_array_bounds(int_list, target, size, vmin, vrangemax):
+def pack_list_to_raw_array_bounds_signed(int_list, target, size):
 

[pypy-commit] pypy py3k: merge default

2014-11-17 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r74549:9a1ca4c16f23
Date: 2014-11-17 10:05 -0800
http://bitbucket.org/pypy/pypy/changeset/9a1ca4c16f23/

Log:merge default

diff too long, truncating to 2000 out of 7347 lines

diff --git a/lib-python/conftest.py b/lib-python/conftest.py
--- a/lib-python/conftest.py
+++ b/lib-python/conftest.py
@@ -60,7 +60,7 @@
  skip=None):
 self.basename = basename
 self._usemodules = usemodules.split() + [
-'_socket', 'binascii', 'rctime', 'select', 'signal']
+'_socket', 'binascii', 'time', 'select', 'signal']
 if not sys.platform == 'win32':
 self._usemodules.extend(['_posixsubprocess', 'fcntl'])
 self._compiler = compiler
diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -30,7 +30,7 @@
 # --allworkingmodules
 working_modules = default_modules.copy()
 working_modules.update([
-_socket, unicodedata, mmap, fcntl, _locale, pwd, rctime ,
+_socket, unicodedata, mmap, fcntl, _locale, pwd, time ,
 select, zipimport, _lsprof, crypt, signal, _rawffi, termios,
 zlib, bz2, struct, _hashlib, _md5, _minimal_curses,
 thread, itertools, pyexpat, _ssl, cpyext, array,
@@ -41,7 +41,7 @@
 
 translation_modules = default_modules.copy()
 translation_modules.update([
-fcntl, rctime, select, signal, _rawffi, zlib, struct,
+fcntl, time, select, signal, _rawffi, zlib, struct,
 array, binascii,
 # the following are needed for pyrepl (and hence for the
 # interactive prompt/pdb)
@@ -66,19 +66,15 @@
 default_modules.add(_locale)
 
 if sys.platform == sunos5:
-working_modules.remove('mmap')   # depend on ctypes, can't get at c-level 
'errono'
-working_modules.remove('rctime') # depend on ctypes, missing 
tm_zone/tm_gmtoff
-working_modules.remove('signal') # depend on ctypes, can't get at c-level 
'errono'
 working_modules.remove('fcntl')  # LOCK_NB not defined
 working_modules.remove(_minimal_curses)
 working_modules.remove(termios)
-working_modules.remove(_multiprocessing)   # depends on rctime
 if cppyy in working_modules:
 working_modules.remove(cppyy)  # depends on ctypes
 
 
 module_dependencies = {
-'_multiprocessing': [('objspace.usemodules.rctime', True),
+'_multiprocessing': [('objspace.usemodules.time', True),
  ('objspace.usemodules.thread', True)],
 'cpyext': [('objspace.usemodules.array', True)],
 'cppyy': [('objspace.usemodules.cpyext', True)],
diff --git a/pypy/doc/config/objspace.usemodules.rctime.txt 
b/pypy/doc/config/objspace.usemodules.rctime.txt
deleted file mode 100644
--- a/pypy/doc/config/objspace.usemodules.rctime.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-Use the 'rctime' module. 
-
-'rctime' is our `rffi`_ based implementation of the builtin 'time' module.
-It supersedes the less complete :config:`objspace.usemodules.time`,
-at least for C-like targets (the C and LLVM backends).
-
-.. _`rffi`: ../rffi.html
diff --git a/pypy/doc/config/objspace.usemodules.time.txt 
b/pypy/doc/config/objspace.usemodules.time.txt
--- a/pypy/doc/config/objspace.usemodules.time.txt
+++ b/pypy/doc/config/objspace.usemodules.time.txt
@@ -1,5 +1,1 @@
 Use the 'time' module. 
-
-Obsolete; use :config:`objspace.usemodules.rctime` for our up-to-date version
-of the application-level 'time' module, at least for C-like targets (the C
-and LLVM backends).
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
@@ -43,3 +43,11 @@
 .. branch nditer-external_loop
 
 Implement `external_loop` arguement to numpy's nditer
+
+.. branch kill-rctime
+
+Rename pypy/module/rctime to pypy/module/time, since it contains the 
implementation of the 'time' module.
+
+.. branch: ssa-flow
+
+Use SSA form for flow graphs inside build_flow() and part of simplify_graph()
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -500,11 +500,6 @@
 if name not in modules:
 modules.append(name)
 
-# a bit of custom logic: rctime take precedence over time
-# XXX this could probably be done as a requires in the config
-if 'rctime' in modules and 'time' in modules:
-modules.remove('time')
-
 self._builtinmodule_list = modules
 return self._builtinmodule_list
 
diff --git a/pypy/module/_lsprof/test/test_cprofile.py 
b/pypy/module/_lsprof/test/test_cprofile.py
--- a/pypy/module/_lsprof/test/test_cprofile.py
+++ b/pypy/module/_lsprof/test/test_cprofile.py
@@ -1,6 +1,6 @@
 class AppTestCProfile(object):
 spaceconfig = {
-usemodules: ['_lsprof', 'rctime'],
+usemodules: ['_lsprof', 'time'],
 }
 
 def setup_class(cls):
diff --git 

[pypy-commit] pypy py3k: merge default

2014-11-06 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r74357:03d54c00a4a8
Date: 2014-11-06 12:11 -0800
http://bitbucket.org/pypy/pypy/changeset/03d54c00a4a8/

Log:merge default

diff --git a/README.rst b/README.rst
--- a/README.rst
+++ b/README.rst
@@ -37,4 +37,4 @@
 to use virtualenv with the resulting pypy-c as the interpreter; you can
 find more details about various installation schemes here:
 
-http://doc.pypy.org/en/latest/getting-started.html#installing-pypy
+http://doc.pypy.org/en/latest/install.html
diff --git a/lib_pypy/grp.py b/lib_pypy/grp.py
--- a/lib_pypy/grp.py
+++ b/lib_pypy/grp.py
@@ -72,7 +72,7 @@
 raise TypeError(expected string)
 res = libc.getgrnam(os.fsencode(name))
 if not res:
-raise KeyError(name)
+raise KeyError('getgrnam(): name not found: %s' % name)
 return _group_from_gstruct(res)
 
 @builtinify
diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -88,9 +88,10 @@
 # itself needs the interp-level struct module
 # because 'P' is missing from the app-level one
 _rawffi: [(objspace.usemodules.struct, True)],
-cpyext: [(translation.secondaryentrypoints, cpyext,main),
-   (translation.shared, sys.platform == win32)],
+cpyext: [(translation.secondaryentrypoints, cpyext,main)],
 }
+if sys.platform == win32:
+module_suggests[cpyext].append((translation.shared, True))
 
 module_import_dependencies = {
 # no _rawffi if importing rpython.rlib.clibffi raises ImportError
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
@@ -39,3 +39,7 @@
 .. branch: kill-multimethod
 
 Kill multimethod machinery, all multimethods were removed earlier.
+
+.. branch nditer-external_loop
+
+Implement `external_loop` arguement to numpy's nditer
diff --git a/pypy/interpreter/executioncontext.py 
b/pypy/interpreter/executioncontext.py
--- a/pypy/interpreter/executioncontext.py
+++ b/pypy/interpreter/executioncontext.py
@@ -32,6 +32,17 @@
 self.compiler = space.createcompiler()
 self.profilefunc = None
 self.w_profilefuncarg = None
+self.thread_disappeared = False   # might be set to True after 
os.fork()
+
+@staticmethod
+def _mark_thread_disappeared(space):
+# Called in the child process after os.fork() by interp_posix.py.
+# Marks all ExecutionContexts except the current one
+# with 'thread_disappeared = True'.
+me = space.getexecutioncontext()
+for ec in space.threadlocals.getallvalues().values():
+if ec is not me:
+ec.thread_disappeared = True
 
 def gettopframe(self):
 return self.topframeref()
diff --git a/pypy/module/micronumpy/concrete.py 
b/pypy/module/micronumpy/concrete.py
--- a/pypy/module/micronumpy/concrete.py
+++ b/pypy/module/micronumpy/concrete.py
@@ -449,7 +449,7 @@
 strides.reverse()
 backstrides.reverse()
 new_shape.reverse()
-return SliceArray(self.start, strides, backstrides, new_shape,
+return self.__class__(self.start, strides, backstrides, new_shape,
   self, orig_array)
 new_strides = calc_new_strides(new_shape, self.get_shape(),
self.get_strides(),
@@ -460,10 +460,16 @@
 new_backstrides = [0] * len(new_shape)
 for nd in range(len(new_shape)):
 new_backstrides[nd] = (new_shape[nd] - 1) * new_strides[nd]
-return SliceArray(self.start, new_strides, new_backstrides, new_shape,
+return self.__class__(self.start, new_strides, new_backstrides, 
new_shape,
   self, orig_array)
 
 
+class NonWritableSliceArray(SliceArray):
+def descr_setitem(self, space, orig_array, w_index, w_value):
+raise OperationError(space.w_ValueError, space.wrap(
+assignment destination is read-only))
+
+
 class VoidBoxStorage(BaseConcreteArray):
 def __init__(self, size, dtype):
 self.storage = alloc_raw_storage(size)
diff --git a/pypy/module/micronumpy/iterators.py 
b/pypy/module/micronumpy/iterators.py
--- a/pypy/module/micronumpy/iterators.py
+++ b/pypy/module/micronumpy/iterators.py
@@ -8,8 +8,8 @@
 At which byte in x.data does the item x[3,4] begin?
 if x.strides==[1,5]:
 pData = x.pData + (x.start + 3*1 + 4*5)*sizeof(x.pData[0])
-pData = x.pData + (x.start + 24) * sizeof(x.pData[0])
-so the offset of the element is 24 elements after the first
+pData = x.pData + (x.start + 23) * sizeof(x.pData[0])
+so the offset of the element is 23 elements after the first
 
 What is the next element in x after coordinates [3,4]?
 if x.order =='C':
@@ -33,7 +33,7 @@
   which is x.strides[1] * (x.shape[1] - 1) + x.strides[0]
 so if we precalculate the overflow backstride as
 [x.strides[i] * 

[pypy-commit] pypy py3k: merge default

2014-10-31 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r74316:2f8363781b3f
Date: 2014-10-31 11:30 -0700
http://bitbucket.org/pypy/pypy/changeset/2f8363781b3f/

Log:merge default

diff --git a/pypy/objspace/std/formatting.py b/pypy/objspace/std/formatting.py
--- a/pypy/objspace/std/formatting.py
+++ b/pypy/objspace/std/formatting.py
@@ -1,15 +1,15 @@
-
-String formatting routines.
-
+String formatting routines
 import sys
-from pypy.interpreter.error import OperationError, oefmt
+
 from rpython.rlib import jit
-from rpython.rlib.rfloat import formatd, DTSF_ALT, isnan, isinf
+from rpython.rlib.rarithmetic import INT_MAX
+from rpython.rlib.rfloat import DTSF_ALT, formatd, isnan, isinf
 from rpython.rlib.rstring import StringBuilder, UnicodeBuilder
 from rpython.rlib.unroll import unrolling_iterable
-from rpython.rlib.rarithmetic import INT_MAX
 from rpython.tool.sourcetools import func_with_new_name
 
+from pypy.interpreter.error import OperationError, oefmt
+
 
 class BaseStringFormatter(object):
 def __init__(self, space, values_w, w_valuedict):
diff --git a/pypy/objspace/std/objectobject.py 
b/pypy/objspace/std/objectobject.py
--- a/pypy/objspace/std/objectobject.py
+++ b/pypy/objspace/std/objectobject.py
@@ -1,7 +1,10 @@
+The builtin object type implementation
+
 from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.error import OperationError, oefmt
 from pypy.interpreter.gateway import applevel, interp2app, unwrap_spec
-from pypy.interpreter.typedef import GetSetProperty, default_identity_hash, 
TypeDef
+from pypy.interpreter.typedef import (
+GetSetProperty, TypeDef, default_identity_hash)
 from pypy.objspace.descroperation import Object
 
 
@@ -46,15 +49,8 @@
 else:
 state = getstate()
 
-if isinstance(obj, list):
-listitems = iter(obj)
-else:
-listitems = None
-
-if isinstance(obj, dict):
-dictitems = iter(obj.items())
-else:
-dictitems = None
+listitems = iter(obj) if isinstance(obj, list) else None
+dictitems = iter(obj.items()) if isinstance(obj, dict) else None
 
 import copyreg
 newobj = copyreg.__newobj__
@@ -94,14 +90,13 @@
 # don't allow arguments if the default object.__init__() is about
 # to be called
 w_type = _precheck_for_new(space, w_type)
-w_parentinit, w_ignored = w_type.lookup_where('__init__')
+w_parentinit, _ = w_type.lookup_where('__init__')
 if w_parentinit is space.w_object:
 try:
 __args__.fixedunpack(0)
 except ValueError:
-raise OperationError(space.w_TypeError,
- space.wrap(default __new__ takes 
-no parameters))
+raise oefmt(space.w_TypeError,
+default __new__ takes no parameters)
 if w_type.is_abstract():
 _abstract_method_error(space, w_type)
 w_obj = space.allocate_instance(W_ObjectObject, w_type)
@@ -120,8 +115,8 @@
 try:
 __args__.fixedunpack(0)
 except ValueError:
-raise OperationError(space.w_TypeError,
-space.wrap(object.__init__() takes no parameters))
+raise oefmt(space.w_TypeError,
+object.__init__() takes no parameters)
 
 
 def descr_get___class__(space, w_obj):
@@ -135,11 +130,12 @@
 __class__ must be set to new-style class, not '%T' 
 object, w_newcls)
 if not w_newcls.is_heaptype():
-raise OperationError(space.w_TypeError,
- space.wrap(__class__ assignment: only for heap 
types))
+raise oefmt(space.w_TypeError,
+__class__ assignment: only for heap types)
 w_oldcls = space.type(w_obj)
 assert isinstance(w_oldcls, W_TypeObject)
-if w_oldcls.get_full_instance_layout() == 
w_newcls.get_full_instance_layout():
+if (w_oldcls.get_full_instance_layout() ==
+w_newcls.get_full_instance_layout()):
 w_obj.setclass(space, w_newcls)
 else:
 raise oefmt(space.w_TypeError,
@@ -167,8 +163,8 @@
 w_type = space.type(w_obj)
 w_impl = w_type.lookup(__repr__)
 if w_impl is None:
-raise OperationError(space.w_TypeError,  # can it really occur?
- space.wrap(operand does not support unary str))
+# can it really occur?
+raise oefmt(space.w_TypeError, operand does not support unary str)
 return space.get_and_call_function(w_impl, w_obj)
 
 
diff --git a/pypy/objspace/std/util.py b/pypy/objspace/std/util.py
--- a/pypy/objspace/std/util.py
+++ b/pypy/objspace/std/util.py
@@ -1,5 +1,6 @@
+from rpython.rlib.rstring import InvalidBaseError
+
 from pypy.interpreter.error import OperationError
-from rpython.rlib.rstring import InvalidBaseError
 
 
 IDTAG_INT = 1
diff --git a/rpython/annotator/description.py b/rpython/annotator/description.py
--- 

[pypy-commit] pypy py3k: merge default

2014-10-29 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r74293:6fa0200792f7
Date: 2014-10-29 17:47 -0700
http://bitbucket.org/pypy/pypy/changeset/6fa0200792f7/

Log:merge default

diff too long, truncating to 2000 out of 3708 lines

diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -248,10 +248,6 @@
 BoolOption(optimized_list_getitem,
special case the 'list[integer]' expressions,
default=False),
-BoolOption(builtinshortcut,
-   a shortcut for operations between built-in types. XXX: 
-   deprecated, not really a shortcut any more.,
-   default=False),
 BoolOption(getattributeshortcut,
track types that override __getattribute__,
default=False,
@@ -263,9 +259,6 @@
# weakrefs needed, because of get_subclasses()
requires=[(translation.rweakref, True)]),
 
-ChoiceOption(multimethods, the multimethod implementation to use,
- [doubledispatch, mrd],
- default=mrd),
 BoolOption(withidentitydict,
track types that override __hash__, __eq__ or __cmp__ and 
use a special dict strategy for those which do not,
default=False,
diff --git a/pypy/doc/config/objspace.std.builtinshortcut.txt 
b/pypy/doc/config/objspace.std.builtinshortcut.txt
deleted file mode 100644
--- a/pypy/doc/config/objspace.std.builtinshortcut.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-A shortcut speeding up primitive operations between built-in types.
-
-This is a space-time trade-off: at the moment, this option makes a
-translated pypy-c executable bigger by about 1.7 MB.  (This can probably
-be improved with careful analysis.)
diff --git a/pypy/doc/config/objspace.std.multimethods.txt 
b/pypy/doc/config/objspace.std.multimethods.txt
deleted file mode 100644
--- a/pypy/doc/config/objspace.std.multimethods.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-Choose the multimethod implementation.
-
-* ``doubledispatch`` turns
-  a multimethod call into a sequence of normal method calls.
-
-* ``mrd`` uses a technique known as Multiple Row Displacement
-  which precomputes a few compact tables of numbers and
-  function pointers.
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
@@ -35,3 +35,7 @@
 Split RPython documentation from PyPy documentation and clean up.  There now is
 a clearer separation between documentation for users, developers and people
 interested in background information.
+
+.. branch: kill-multimethod
+
+Kill multimethod machinery, all multimethods were removed earlier.
diff --git a/pypy/goal/targetpypystandalone.py 
b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -215,23 +215,6 @@
 from pypy.config.pypyoption import set_pypy_opt_level
 set_pypy_opt_level(config, translateconfig.opt)
 
-# as of revision 27081, multimethod.py uses the InstallerVersion1 by 
default
-# because it is much faster both to initialize and run on top of 
CPython.
-# The InstallerVersion2 is optimized for making a translator-friendly
-# structure for low level backends. However, InstallerVersion1 is still
-# preferable for high level backends, so we patch here.
-
-from pypy.objspace.std import multimethod
-if config.objspace.std.multimethods == 'mrd':
-assert multimethod.InstallerVersion1.instance_counter == 0,\
-   'The wrong Installer version has already been instatiated'
-multimethod.Installer = multimethod.InstallerVersion2
-elif config.objspace.std.multimethods == 'doubledispatch':
-# don't rely on the default, set again here
-assert multimethod.InstallerVersion2.instance_counter == 0,\
-   'The wrong Installer version has already been instatiated'
-multimethod.Installer = multimethod.InstallerVersion1
-
 def print_help(self, config):
 self.opt_parser(config).print_help()
 
diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -630,6 +630,7 @@
 from pypy.interpreter.nestedscope import Cell
 from pypy.interpreter.special import NotImplemented, Ellipsis
 
+
 def descr_get_dict(space, w_obj):
 w_dict = w_obj.getdict(space)
 if w_dict is None:
@@ -650,6 +651,11 @@
 return space.w_None
 return lifeline.get_any_weakref(space)
 
+dict_descr = GetSetProperty(descr_get_dict, descr_set_dict, descr_del_dict,
+doc=dictionary for instance variables (if 
defined))
+dict_descr.name = '__dict__'
+
+
 def generic_ne(space, w_obj1, w_obj2):
 if 

[pypy-commit] pypy py3k: merge default

2014-10-28 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r74267:a245775c1e36
Date: 2014-10-28 10:33 -0700
http://bitbucket.org/pypy/pypy/changeset/a245775c1e36/

Log:merge default

diff --git a/pypy/module/select/test/test_select.py 
b/pypy/module/select/test/test_select.py
--- a/pypy/module/select/test/test_select.py
+++ b/pypy/module/select/test/test_select.py
@@ -309,7 +309,6 @@
 import select
 class Foo(object):
 def fileno(self):
-print len(l)
 if len(l)  100:
 l.append(Foo())
 return 0
diff --git a/rpython/jit/backend/llsupport/assembler.py 
b/rpython/jit/backend/llsupport/assembler.py
--- a/rpython/jit/backend/llsupport/assembler.py
+++ b/rpython/jit/backend/llsupport/assembler.py
@@ -225,7 +225,8 @@
 raise AssertionError(kind)
 
 gcref = cast_instance_to_gcref(value)
-rgc._make_sure_does_not_move(gcref)
+if gcref:
+rgc._make_sure_does_not_move(gcref)
 value = rffi.cast(lltype.Signed, gcref)
 je_location = self._call_assembler_check_descr(value, tmploc)
 #
diff --git a/rpython/rlib/rgc.py b/rpython/rlib/rgc.py
--- a/rpython/rlib/rgc.py
+++ b/rpython/rlib/rgc.py
@@ -63,10 +63,13 @@
 Unpin 'obj', allowing it to move again.
 Must only be called after a call to pin(obj) returned True.
 
-for i in range(len(_pinned_objects)):
+i = 0
+while i  len(_pinned_objects):
 try:
 if _pinned_objects[i] == obj:
 del _pinned_objects[i]
+else:
+i += 1
 except TypeError:
 pass
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: merge default

2014-10-26 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r74242:f70579d34dff
Date: 2014-10-26 04:45 -0700
http://bitbucket.org/pypy/pypy/changeset/f70579d34dff/

Log:merge default

diff --git a/pypy/module/operator/tscmp.c b/pypy/module/operator/tscmp.c
--- a/pypy/module/operator/tscmp.c
+++ b/pypy/module/operator/tscmp.c
@@ -4,8 +4,9 @@
 #include stdlib.h
 #include wchar.h
 #include src/precommondefs.h
+#include tscmp.h
 
-RPY_EXPORTED_FOR_TESTS int
+int
 pypy_tscmp(const char *a, const char *b, long len_a, long len_b)
 {
 /* The volatile type declarations make sure that the compiler has no
diff --git a/pypy/module/operator/tscmp.h b/pypy/module/operator/tscmp.h
new file mode 100644
--- /dev/null
+++ b/pypy/module/operator/tscmp.h
@@ -0,0 +1,1 @@
+RPY_EXPORTED_FOR_TESTS int pypy_tscmp(const char *, const char *, long, long);
diff --git a/pypy/module/operator/tscmp.py b/pypy/module/operator/tscmp.py
--- a/pypy/module/operator/tscmp.py
+++ b/pypy/module/operator/tscmp.py
@@ -13,7 +13,8 @@
 
 cwd = py.path.local(__file__).dirpath()
 eci = ExternalCompilationInfo(
-include_dirs=[cdir],
+includes=[cwd.join('tscmp.h')],
+include_dirs=[str(cwd), cdir],
 separate_module_files=[cwd.join('tscmp.c')])
 
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: merge default

2014-10-25 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r74239:8d5158ea78d5
Date: 2014-10-25 12:31 -0700
http://bitbucket.org/pypy/pypy/changeset/8d5158ea78d5/

Log:merge default

diff --git a/pypy/config/test/test_pypyoption.py 
b/pypy/config/test/test_pypyoption.py
--- a/pypy/config/test/test_pypyoption.py
+++ b/pypy/config/test/test_pypyoption.py
@@ -64,7 +64,7 @@
 def check_file_exists(fn):
 assert configdocdir.join(fn).check()
 
-from pypy.doc.config.confrest import all_optiondescrs
+from pypy.doc.config.generate import all_optiondescrs
 configdocdir = thisdir.dirpath().dirpath().join(doc, config)
 for descr in all_optiondescrs:
 prefix = descr._name
diff --git a/pypy/doc/build.rst b/pypy/doc/build.rst
--- a/pypy/doc/build.rst
+++ b/pypy/doc/build.rst
@@ -119,6 +119,9 @@
 
 pypy rpython/bin/rpython --opt=2 pypy/goal/targetpypystandalone.py
 
+(You can use ``python`` instead of ``pypy`` here, which will take longer
+but works too.)
+
 If everything works correctly this will create an executable ``pypy-c`` in the
 current directory. The executable behaves mostly like a normal Python
 interpreter (see :doc:`cpython_differences`).
diff --git a/pypy/module/bz2/test/support.py b/pypy/module/bz2/test/support.py
--- a/pypy/module/bz2/test/support.py
+++ b/pypy/module/bz2/test/support.py
@@ -3,6 +3,11 @@
 from rpython.rtyper.lltypesystem import ll2ctypes
 import gc
 tries = 20
+# remove the GC strings from ll2ctypes
+for key, value in ll2ctypes.ALLOCATED.items():
+if value._TYPE._gckind == 'gc':
+del ll2ctypes.ALLOCATED[key]
+#
 while tries and ll2ctypes.ALLOCATED:
 gc.collect() # to make sure we disallocate buffers
 tries -= 1
diff --git a/pypy/module/operator/tscmp.c b/pypy/module/operator/tscmp.c
--- a/pypy/module/operator/tscmp.c
+++ b/pypy/module/operator/tscmp.c
@@ -1,9 +1,9 @@
 /* Derived from CPython 3.3.5's operator.c::_tscmp
  */
 
+#include stdlib.h
+#include wchar.h
 #include src/precommondefs.h
-#include stdlib.h
-#include tscmp.h
 
 RPY_EXPORTED_FOR_TESTS int
 pypy_tscmp(const char *a, const char *b, long len_a, long len_b)
diff --git a/pypy/module/operator/tscmp.h b/pypy/module/operator/tscmp.h
deleted file mode 100644
--- a/pypy/module/operator/tscmp.h
+++ /dev/null
@@ -1,1 +0,0 @@
-int pypy_tscmp(const char *, const char *, long, long);
diff --git a/pypy/module/operator/tscmp.py b/pypy/module/operator/tscmp.py
--- a/pypy/module/operator/tscmp.py
+++ b/pypy/module/operator/tscmp.py
@@ -13,8 +13,7 @@
 
 cwd = py.path.local(__file__).dirpath()
 eci = ExternalCompilationInfo(
-includes=[cwd.join('tscmp.h')],
-include_dirs=[str(cwd), cdir],
+include_dirs=[cdir],
 separate_module_files=[cwd.join('tscmp.c')])
 
 
diff --git a/pypy/module/pypyjit/test/test_jit_hook.py 
b/pypy/module/pypyjit/test/test_jit_hook.py
--- a/pypy/module/pypyjit/test/test_jit_hook.py
+++ b/pypy/module/pypyjit/test/test_jit_hook.py
@@ -11,7 +11,7 @@
 from rpython.rtyper.lltypesystem import lltype, llmemory
 from rpython.rtyper.rclass import OBJECT
 from pypy.module.pypyjit.interp_jit import pypyjitdriver
-from pypy.module.pypyjit.policy import pypy_hooks
+from pypy.module.pypyjit.hooks import pypy_hooks
 from rpython.jit.tool.oparser import parse
 from rpython.jit.metainterp.typesystem import llhelper
 from rpython.rlib.jit import JitDebugInfo, AsmInfo, Counters
diff --git a/pypy/module/test_lib_pypy/ctypes_tests/_ctypes_test.c 
b/pypy/module/test_lib_pypy/ctypes_tests/_ctypes_test.c
--- a/pypy/module/test_lib_pypy/ctypes_tests/_ctypes_test.c
+++ b/pypy/module/test_lib_pypy/ctypes_tests/_ctypes_test.c
@@ -1,13 +1,11 @@
+#include src/precommondefs.h
+
 #if defined(_MSC_VER) || defined(__CYGWIN__)
 #include windows.h
 #define MS_WIN32
 #endif
 
-#if defined(MS_WIN32)
-#define EXPORT(x) __declspec(dllexport) x
-#else
-#define EXPORT(x) x
-#endif
+#define EXPORT(x)  RPY_EXPORTED x
 
 #include stdlib.h
 #include math.h
diff --git a/pypy/module/test_lib_pypy/ctypes_tests/conftest.py 
b/pypy/module/test_lib_pypy/ctypes_tests/conftest.py
--- a/pypy/module/test_lib_pypy/ctypes_tests/conftest.py
+++ b/pypy/module/test_lib_pypy/ctypes_tests/conftest.py
@@ -8,6 +8,7 @@
 def compile_so_file():
 from rpython.translator.platform import platform
 from rpython.translator.tool.cbuild import ExternalCompilationInfo
+from rpython.translator import cdir
 udir = pytest.ensuretemp('_ctypes_test')
 cfile = py.path.local(__file__).dirpath().join(_ctypes_test.c)
 
@@ -15,7 +16,8 @@
 libraries = ['oleaut32']
 else:
 libraries = []
-eci = ExternalCompilationInfo(libraries=libraries)
+eci = ExternalCompilationInfo(libraries=libraries,
+  include_dirs=[cdir])
 
 return platform.compile([cfile], eci, str(udir.join('_ctypes_test')),
 standalone=False)
diff --git 

[pypy-commit] pypy py3k: merge default

2014-10-24 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r74145:ba8251a5c237
Date: 2014-10-23 16:26 -0700
http://bitbucket.org/pypy/pypy/changeset/ba8251a5c237/

Log:merge default

diff too long, truncating to 2000 out of 5202 lines

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
@@ -22,3 +22,6 @@
 
 .. branch: ClassRepr
 Refactor ClassRepr and make normalizecalls independent of the rtyper.
+
+.. branch: remove-remaining-smm
+Remove all remaining multimethods.
diff --git a/pypy/goal/targetpypystandalone.py 
b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -310,7 +310,8 @@
 return self.get_entry_point(config)
 
 def jitpolicy(self, driver):
-from pypy.module.pypyjit.policy import PyPyJitPolicy, pypy_hooks
+from pypy.module.pypyjit.policy import PyPyJitPolicy
+from pypy.module.pypyjit.hooks import pypy_hooks
 return PyPyJitPolicy(pypy_hooks)
 
 def get_entry_point(self, config):
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1899,5 +1899,4 @@
 'newdict',
 'newslice',
 'call_args',
-'marshal_w',
 ]
diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py
--- a/pypy/interpreter/gateway.py
+++ b/pypy/interpreter/gateway.py
@@ -644,6 +644,17 @@
 elif unwrap_spec == [ObjSpace, W_Root, Arguments]:
 self.__class__ = BuiltinCodePassThroughArguments1
 self.func__args__ = func
+elif unwrap_spec == [self_type, ObjSpace, Arguments]:
+self.__class__ = BuiltinCodePassThroughArguments1
+miniglobals = {'func': func, 'self_type': self_type}
+d = {}
+source = if 1:
+def _call(space, w_obj, args):
+self = space.descr_self_interp_w(self_type, w_obj)
+return func(self, space, args)
+\n
+exec compile2(source) in miniglobals, d
+self.func__args__ = d['_call']
 else:
 self.__class__ = globals()['BuiltinCode%d' % arity]
 setattr(self, 'fastfunc_%d' % arity, fastfunc)
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
@@ -906,11 +906,33 @@
 assert len(called) == 1
 assert isinstance(called[0], argument.Arguments)
 
+def test_pass_trough_arguments_method(self):
+space = self.space
+
+called = []
+
+class W_Something(W_Root):
+def f(self, space, __args__):
+called.append(__args__)
+a_w, _ = __args__.unpack()
+return space.newtuple([space.wrap('f')]+a_w)
+
+w_f = space.wrap(gateway.interp2app_temp(W_Something.f))
+
+w_self = space.wrap(W_Something())
+args = argument.Arguments(space, [space.wrap(7)])
+
+w_res = space.call_obj_args(w_f, w_self, args)
+assert space.is_true(space.eq(w_res, space.wrap(('f', 7
+
+# white-box check for opt
+assert called[0] is args
+
 
 class AppTestKeywordsToBuiltinSanity(object):
 def test_type(self):
 class X(object):
-def __init__(self, **kw):
+def __init__(myself, **kw):
 pass
 clash = type.__call__.__code__.co_varnames[0]
 
@@ -926,7 +948,6 @@
 X(**{clash: 33})
 object.__new__(X, **{clash: 33})
 
-
 def test_dict_new(self):
 clash = dict.__new__.__code__.co_varnames[0]
 
diff --git a/pypy/module/marshal/interp_marshal.py 
b/pypy/module/marshal/interp_marshal.py
--- a/pypy/module/marshal/interp_marshal.py
+++ b/pypy/module/marshal/interp_marshal.py
@@ -2,6 +2,7 @@
 from pypy.interpreter.gateway import WrappedDefault, unwrap_spec
 from rpython.rlib.rarithmetic import intmask
 from rpython.rlib import rstackovf
+from pypy.objspace.std.marshal_impl import get_unmarshallers
 
 
 Py_MARSHAL_VERSION = 2
@@ -139,6 +140,26 @@
 raise OperationError(space.w_ValueError, space.wrap(msg))
 
 class Marshaller(_Base):
+
+atomic types including typecode:
+
+atom(tc)puts single typecode
+atom_int(tc, int)   puts code and int
+atom_int64(tc, int64)   puts code and int64
+atom_str(tc, str)   puts code, len and string
+atom_strlist(tc, strlist)   puts code, len and list of strings
+
+building blocks for compound types:
+
+start(typecode) sets the type character
+put(s)  puts a string with fixed length
+put_short(int)  puts 

[pypy-commit] pypy py3k: merge default

2014-10-24 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r74197:134020dca51a
Date: 2014-10-24 16:10 -0700
http://bitbucket.org/pypy/pypy/changeset/134020dca51a/

Log:merge default

diff too long, truncating to 2000 out of 29307 lines

diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -89,6 +89,7 @@
 ^pypy/doc/image/lattice3\.png$
 ^pypy/doc/image/stackless_informal\.png$
 ^pypy/doc/image/parsing_example.+\.png$
+^rpython/doc/_build/.*$
 ^pypy/module/test_lib_pypy/ctypes_tests/_ctypes_test\.o$
 ^compiled
 ^.git/
diff --git a/README.rst b/README.rst
--- a/README.rst
+++ b/README.rst
@@ -23,6 +23,7 @@
 
 the pypy-dev team pypy-...@python.org
 
+
 Building
 
 
diff --git a/ctypes_configure/doc/configure.txt 
b/ctypes_configure/doc/configure.txt
--- a/ctypes_configure/doc/configure.txt
+++ b/ctypes_configure/doc/configure.txt
@@ -19,6 +19,4 @@
 usage
 =
 
-`sample.py`_ explains in details how to use it.
-
-.. _`sample.py`: 
http://codespeak.net/svn/pypy/dist/ctypes_configure/doc/sample.py
+:source:`sample.py ctypes_configure/doc/sample.py` explains in details how 
to use it.
diff --git a/pypy/doc/TODO b/pypy/doc/TODO
new file mode 100644
--- /dev/null
+++ b/pypy/doc/TODO
@@ -0,0 +1,40 @@
+Documentation TODO
+==
+
+General
+---
+
+* architecture documents don't really show the separation between PyPy and
+  RPython
+  * architecture.rst is duplicate (both pypy and rpython)
+* Consider moving information from pypy/doc/{build,windows}.rst to rpython/doc
+
+
+Cleanup
+~~~
+
+* remove documentation on removed features
+  * various object spaces
+* update / remove dead links
+
+
+Meta
+
+
+* work on configuration/options documentation generation
+
+
+PyPy
+
+
+* Update coding guide
+* Move links from project-documentation.rst to index.rst and consider killing
+  it.
+
+
+RPython
+---
+
+* make translation.rst a high-level overview and move details in their own
+  documents
+* redo various outdated pictures in translation.rst
diff --git a/pypy/doc/__pypy__-module.rst b/pypy/doc/__pypy__-module.rst
--- a/pypy/doc/__pypy__-module.rst
+++ b/pypy/doc/__pypy__-module.rst
@@ -1,20 +1,17 @@
-
 .. comment: this document is very incomplete, should we generate
 it automatically?
 
-===
 The ``__pypy__`` module
 ===
 
 The ``__pypy__`` module is the main entry point to special features provided
-by PyPy's standard interpreter. Its content depends on `configuration 
options`_ 
-which may add new functionality and functions whose existence or non-existence 
-indicates the presence of such features. 
+by PyPy's standard interpreter. Its content depends on :doc:`configuration 
options config/index`
+which may add new functionality and functions whose existence or non-existence
+indicates the presence of such features.
 
-.. _`configuration options`: config/index.html
 
 Generally available functionality
-=
+-
 
  - ``internal_repr(obj)``: return the interpreter-level representation of an
object.
@@ -22,28 +19,22 @@
It works like a simplified array of characters (actually, depending on the
configuration the ``array`` module internally uses this).
 
+
 Transparent Proxy Functionality
-===
+---
 
-If `transparent proxies`_ are enabled (with :config:`objspace.std.withtproxy`)
+If :ref:`transparent proxies tproxy` are enabled (with 
:config:`objspace.std.withtproxy`)
 the following functions are put into ``__pypy__``:
 
  - ``tproxy(typ, controller)``: Return something that looks like it is of type
typ. Its behaviour is completely controlled by the controller. See the docs
-   about `transparent proxies`_ for detail.
-
+   about :ref:`transparent proxies tproxy` for detail.
  - ``get_tproxy_controller(obj)``: If obj is really a transparent proxy, return
its controller. Otherwise return None.
 
-.. _`transparent proxies`: objspace-proxies.html#tproxy
-
 
 Functionality available on py.py (not after translation)
-
+
 
  - ``isfake(obj)``: returns True if ``obj`` is faked.
-
  - ``interp_pdb()``: start a pdb at interpreter-level.
-
-
-
diff --git a/pypy/doc/_ref.txt b/pypy/doc/_ref.txt
deleted file mode 100644
--- a/pypy/doc/_ref.txt
+++ /dev/null
@@ -1,114 +0,0 @@
-.. This file is generated automatically by makeref.py script,
-   which in turn is run manually.
-
-.. _`ctypes_configure/doc/sample.py`: 
https://bitbucket.org/pypy/pypy/src/default/ctypes_configure/doc/sample.py
-.. _`dotviewer/`: https://bitbucket.org/pypy/pypy/src/default/dotviewer/
-.. _`lib-python/`: https://bitbucket.org/pypy/pypy/src/default/lib-python/
-.. _`lib-python/2.7/dis.py`: 
https://bitbucket.org/pypy/pypy/src/default/lib-python/2.7/dis.py
-.. _`lib_pypy/`: 

[pypy-commit] pypy py3k: merge default

2014-10-17 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r74007:dfd4a9093328
Date: 2014-10-17 15:45 -0700
http://bitbucket.org/pypy/pypy/changeset/dfd4a9093328/

Log:merge default

diff too long, truncating to 2000 out of 3968 lines

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
@@ -19,3 +19,6 @@
 .. branch: var-in-Some
 Store annotations on the Variable objects, rather than in a big dict.
 Introduce a new framework for double-dispatched annotation implementations.
+
+.. branch: ClassRepr
+Refactor ClassRepr and make normalizecalls independent of the rtyper.
diff --git a/pypy/goal/targetpypystandalone.py 
b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -258,6 +258,7 @@
 enable_translationmodules(config)
 
 config.translation.suggest(check_str_without_nul=True)
+config.translation.suggest(shared=True)
 
 if config.translation.thread:
 config.objspace.usemodules.thread = True
diff --git a/pypy/module/pypyjit/interp_resop.py 
b/pypy/module/pypyjit/interp_resop.py
--- a/pypy/module/pypyjit/interp_resop.py
+++ b/pypy/module/pypyjit/interp_resop.py
@@ -7,7 +7,7 @@
 from pypy.interpreter.error import OperationError
 from rpython.rtyper.lltypesystem import lltype
 from rpython.rtyper.annlowlevel import cast_base_ptr_to_instance, hlstr
-from rpython.rtyper.lltypesystem.rclass import OBJECT
+from rpython.rtyper.rclass import OBJECT
 from rpython.jit.metainterp.resoperation import rop
 from rpython.rlib.nonconst import NonConstant
 from rpython.rlib import jit_hooks
diff --git a/pypy/module/pypyjit/test/test_jit_hook.py 
b/pypy/module/pypyjit/test/test_jit_hook.py
--- a/pypy/module/pypyjit/test/test_jit_hook.py
+++ b/pypy/module/pypyjit/test/test_jit_hook.py
@@ -9,7 +9,7 @@
 from rpython.rtyper.annlowlevel import (cast_instance_to_base_ptr,
   cast_base_ptr_to_instance)
 from rpython.rtyper.lltypesystem import lltype, llmemory
-from rpython.rtyper.lltypesystem.rclass import OBJECT
+from rpython.rtyper.rclass import OBJECT
 from pypy.module.pypyjit.interp_jit import pypyjitdriver
 from pypy.module.pypyjit.policy import pypy_hooks
 from rpython.jit.tool.oparser import parse
diff --git a/pypy/objspace/std/bytearrayobject.py 
b/pypy/objspace/std/bytearrayobject.py
--- a/pypy/objspace/std/bytearrayobject.py
+++ b/pypy/objspace/std/bytearrayobject.py
@@ -4,6 +4,7 @@
 import_from_mixin, newlist_hint, resizelist_hint, specialize)
 from rpython.rlib.buffer import Buffer
 from rpython.rlib.rstring import StringBuilder, ByteListBuilder
+from rpython.rlib.debug import check_list_of_chars
 
 from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.error import OperationError, oefmt
@@ -23,6 +24,7 @@
 import_from_mixin(StringMethods)
 
 def __init__(self, data):
+check_list_of_chars(data)
 self.data = data
 
 def __repr__(self):
diff --git a/rpython/annotator/annrpython.py b/rpython/annotator/annrpython.py
--- a/rpython/annotator/annrpython.py
+++ b/rpython/annotator/annrpython.py
@@ -249,10 +249,6 @@
 assert s_value.contains(s_old)
 arg.annotation = s_value
 
-def transfer_binding(self, v_target, v_source):
-assert v_source.annotation is not None
-v_target.annotation = v_source.annotation
-
 def warning(self, msg, pos=None):
 if pos is None:
 try:
@@ -579,7 +575,7 @@
 for arg in op.args:
 if isinstance(self.annotation(arg), annmodel.SomeImpossibleValue):
 raise BlockedInference(self, op, -1)
-resultcell = op.consider(self, *op.args)
+resultcell = op.consider(self)
 if resultcell is None:
 resultcell = annmodel.s_ImpossibleValue
 elif resultcell == annmodel.s_ImpossibleValue:
diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py
--- a/rpython/annotator/bookkeeper.py
+++ b/rpython/annotator/bookkeeper.py
@@ -559,10 +559,6 @@
 assert self.annotator.binding(op.args[pos]) == s_type
 return op
 
-def ondegenerated(self, what, s_value, where=None, called_from_graph=None):
-self.annotator.ondegenerated(what, s_value, where=where,
- called_from_graph=called_from_graph)
-
 def whereami(self):
 return self.annotator.whereami(self.position_key)
 
diff --git a/rpython/annotator/classdef.py b/rpython/annotator/classdef.py
--- a/rpython/annotator/classdef.py
+++ b/rpython/annotator/classdef.py
@@ -154,6 +154,8 @@
 self.subdefs = []
 self.attr_sources = {}   # {name: list-of-sources}
 self.read_locations_of__class__ = {}
+self.repr = None
+self.extra_access_sets = {}
 
 if classdesc.basedesc:
 self.basedef = 

[pypy-commit] pypy py3k: merge default

2014-10-13 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r73936:d971d572758b
Date: 2014-10-13 16:23 -0700
http://bitbucket.org/pypy/pypy/changeset/d971d572758b/

Log:merge default

diff too long, truncating to 2000 out of 13891 lines

diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -3,8 +3,8 @@
 
 Except when otherwise stated (look for LICENSE files in directories or
 information at the beginning of each file) all software and documentation in
-the 'rpython', 'pypy', 'ctype_configure', 'dotviewer', 'demo', and 'lib_pypy'
-directories is licensed as follows: 
+the 'rpython', 'pypy', 'ctype_configure', 'dotviewer', 'demo', 'lib_pypy',
+'py', and '_pytest' directories is licensed as follows: 
 
 The MIT License
 
@@ -367,3 +367,43 @@
 Detailed license information is contained in the NOTICE file in the
 directory.
 
+
+Licenses and Acknowledgements for Incorporated Software
+===
+
+This section is an incomplete, but growing list of licenses and
+acknowledgements for third-party software incorporated in the PyPy
+distribution.
+
+License for 'Tcl/Tk'
+
+
+This copy of PyPy contains library code that may, when used, result in
+the Tcl/Tk library to be loaded.  PyPy also includes code that may be
+regarded as being a copy of some parts of the Tcl/Tk header files.
+You may see a copy of the License for Tcl/Tk in the file
+`lib_pypy/_tkinter/license.terms` included here.
+
+License for 'bzip2'
+---
+
+This copy of PyPy may be linked (dynamically or statically) with the
+bzip2 library.  You may see a copy of the License for bzip2/libbzip2 at
+
+http://www.bzip.org/1.0.5/bzip2-manual-1.0.5.html
+
+License for 'openssl'
+-
+
+This copy of PyPy may be linked (dynamically or statically) with the
+openssl library.  You may see a copy of the License for OpenSSL at
+
+https://www.openssl.org/source/license.html
+
+License for '_gdbm'
+--
+
+The _gdbm module includes code from gdbm.h, which is distributed under
+the terms of the GPL license version 2 or any later version.  Thus the
+_gdbm module, provided in the file lib_pypy/_gdbm.py, is redistributed
+under the terms of the GPL license as well.
diff --git a/lib-python/2.7/test/test_select.py 
b/lib-python/2.7/test/test_select.py
--- a/lib-python/2.7/test/test_select.py
+++ b/lib-python/2.7/test/test_select.py
@@ -57,7 +57,17 @@
 del a[-1]
 return sys.__stdout__.fileno()
 a[:] = [F()] * 10
-self.assertEqual(select.select([], a, []), ([], a[:5], []))
+result = select.select([], a, [])
+# CPython: 'a' ends up with 5 items, because each fileno()
+# removes an item and at the middle the iteration stops.
+# PyPy: 'a' ends up empty, because the iteration is done on
+# a copy of the original list: fileno() is called 10 times.
+if test_support.check_impl_detail(cpython=True):
+self.assertEqual(len(result[1]), 5)
+self.assertEqual(len(a), 5)
+if test_support.check_impl_detail(pypy=True):
+self.assertEqual(len(result[1]), 10)
+self.assertEqual(len(a), 0)
 
 def test_main():
 test_support.run_unittest(SelectTestCase)
diff --git a/lib_pypy/_curses.py b/lib_pypy/_curses.py
--- a/lib_pypy/_curses.py
+++ b/lib_pypy/_curses.py
@@ -286,6 +286,13 @@
 
 
 lib = ffi.verify(
+#ifdef __APPLE__
+/* the following define is necessary for OS X 10.6+; without it, the
+   Apple-supplied ncurses.h sets NCURSES_OPAQUE to 1, and then Python
+   can't get at the WINDOW flags field. */
+#define NCURSES_OPAQUE 0
+#endif
+
 #include ncurses.h
 #include panel.h
 #include term.h
diff --git a/pypy/doc/how-to-release.rst b/pypy/doc/how-to-release.rst
--- a/pypy/doc/how-to-release.rst
+++ b/pypy/doc/how-to-release.rst
@@ -38,14 +38,16 @@
 no JIT: windows, linux, os/x
 sandbox: linux, os/x
 
+* repackage and upload source tar.bz2 to bitbucket and to cobra, as some 
packagers 
+  prefer a clearly labeled source package
 * write release announcement pypy/doc/release-x.y(.z).txt
   the release announcement should contain a direct link to the download page
 * update pypy.org (under extradoc/pypy.org), rebuild and commit
 
 * post announcement on morepypy.blogspot.com
-* send announcements to pypy-dev, python-list,
+* send announcements to twitter.com, pypy-dev, python-list,
   python-announce, python-dev ...
 
 * add a tag on the pypy/jitviewer repo that corresponds to pypy release
 * add a tag on the codespeed web site that corresponds to pypy release
-
+* revise versioning at https://readthedocs.org/projects/pypy
diff --git a/pypy/doc/release-2.4.0.rst b/pypy/doc/release-2.4.0.rst
--- a/pypy/doc/release-2.4.0.rst
+++ b/pypy/doc/release-2.4.0.rst
@@ -5,7 +5,7 @@
 We're pleased to announce PyPy 2.4, which contains significant performance
 enhancements and bug fixes. 
 
-You can already 

[pypy-commit] pypy py3k: merge default

2014-09-18 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r73603:45600f667251
Date: 2014-09-17 17:30 -0700
http://bitbucket.org/pypy/pypy/changeset/45600f667251/

Log:merge default

diff --git a/pypy/interpreter/pyparser/parsestring.py 
b/pypy/interpreter/pyparser/parsestring.py
--- a/pypy/interpreter/pyparser/parsestring.py
+++ b/pypy/interpreter/pyparser/parsestring.py
@@ -82,12 +82,6 @@
 v = PyString_DecodeEscape(space, substr, 'strict', encoding)
 return space.wrapbytes(v)
 
-def hexbyte(val):
-result = %x % val
-if len(result) == 1:
-result = 0 + result
-return result
-
 def decode_unicode_utf8(space, s, ps, q):
 # The Python 2.7 version, producing UTF-32 escapes
 # String is utf8-encoded, but 'unicode_escape' expects
@@ -107,15 +101,14 @@
 # instead.
 lis.append(u005c)
 if ord(s[ps])  0x80: # XXX inefficient
-w, ps = decode_utf8(space, s, ps, end, utf-32-be)
-rn = len(w)
-assert rn % 4 == 0
-for i in range(0, rn, 4):
-lis.append('\\U')
-lis.append(hexbyte(ord(w[i])))
-lis.append(hexbyte(ord(w[i+1])))
-lis.append(hexbyte(ord(w[i+2])))
-lis.append(hexbyte(ord(w[i+3])))
+w, ps = decode_utf8(space, s, ps, end)
+for c in w:
+# The equivalent of %08x, which is not supported by RPython.
+# 7 zeroes are enough for the unicode range, and the
+# result still fits in 32-bit.
+hexa = hex(ord(c) + 0x1000)
+lis.append('\\U0')
+lis.append(hexa[3:])  # Skip 0x and the leading 1
 else:
 lis.append(s[ps])
 ps += 1
@@ -135,7 +128,7 @@
 # note that the C code has a label here.
 # the logic is the same.
 if recode_encoding and ord(s[ps])  0x80:
-w, ps = decode_utf8(space, s, ps, end, recode_encoding)
+w, ps = decode_utf8_recode(space, s, ps, end, recode_encoding)
 # Append bytes to output buffer.
 builder.append(w)
 else:
@@ -222,14 +215,18 @@
 ch = 'A' and ch = 'F')
 
 
-def decode_utf8(space, s, ps, end, encoding):
+def decode_utf8(space, s, ps, end):
 assert ps = 0
 pt = ps
 # while (s  end  *s != '\\') s++; */ /* inefficient for u..
 while ps  end and ord(s[ps])  0x80:
 ps += 1
-w_u = space.wrap(unicodehelper.decode_utf8(space, s[pt:ps]))
-w_v = unicodehelper.encode(space, w_u, encoding)
+u = unicodehelper.decode_utf8(space, s[pt:ps])
+return u, ps
+
+def decode_utf8_recode(space, s, ps, end, recode_encoding):
+u, ps = decode_utf8(space, s, ps, end)
+w_v = unicodehelper.encode(space, space.wrap(u), recode_encoding)
 v = space.bytes_w(w_v)
 return v, ps
 
diff --git a/pypy/interpreter/pyparser/test/test_parsestring.py 
b/pypy/interpreter/pyparser/test/test_parsestring.py
--- a/pypy/interpreter/pyparser/test/test_parsestring.py
+++ b/pypy/interpreter/pyparser/test/test_parsestring.py
@@ -100,11 +100,11 @@
 
 def test_simple_enc_roundtrip(self):
 space = self.space
-s = '\x81'
+s = '\x81\\t'
 s = s.decode(koi8-u).encode(utf8)
 w_ret = parsestring.parsestr(self.space, 'koi8-u', s)
 ret = space.unwrap(w_ret)
-assert ret == eval(# -*- coding: koi8-u -*-\nu'\x81') 
+assert ret == eval(# -*- coding: koi8-u -*-\nu'\x81\\t') 
 
 def test_multiline_unicode_strings_with_backslash(self):
 space = self.space
diff --git a/pypy/interpreter/unicodehelper.py 
b/pypy/interpreter/unicodehelper.py
--- a/pypy/interpreter/unicodehelper.py
+++ b/pypy/interpreter/unicodehelper.py
@@ -13,6 +13,7 @@
 
 @specialize.memo()
 def decode_error_handler(space):
+# Fast version of the strict errors handler.
 def raise_unicode_exception_decode(errors, encoding, msg, s,
startingpos, endingpos):
 raise OperationError(space.w_UnicodeDecodeError,
@@ -25,6 +26,7 @@
 
 @specialize.memo()
 def encode_error_handler(space):
+# Fast version of the strict errors handler.
 def raise_unicode_exception_encode(errors, encoding, msg, u,
startingpos, endingpos):
 raise OperationError(space.w_UnicodeEncodeError,
diff --git a/pypy/module/_cffi_backend/ctypefunc.py 
b/pypy/module/_cffi_backend/ctypefunc.py
--- a/pypy/module/_cffi_backend/ctypefunc.py
+++ b/pypy/module/_cffi_backend/ctypefunc.py
@@ -8,6 +8,7 @@
 from rpython.rlib.jit_libffi import (CIF_DESCRIPTION, CIF_DESCRIPTION_P,
 FFI_TYPE, FFI_TYPE_P, FFI_TYPE_PP, SIZE_OF_FFI_ARG)
 from rpython.rlib.objectmodel import we_are_translated, instantiate
+from rpython.rlib.objectmodel import keepalive_until_here
 from rpython.rtyper.lltypesystem import lltype, llmemory, rffi
 
 

[pypy-commit] pypy py3k: merge default

2014-09-13 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r73529:201aee996695
Date: 2014-09-13 18:26 -0700
http://bitbucket.org/pypy/pypy/changeset/201aee996695/

Log:merge default

diff --git a/pypy/doc/windows.rst b/pypy/doc/windows.rst
--- a/pypy/doc/windows.rst
+++ b/pypy/doc/windows.rst
@@ -85,10 +85,13 @@
 
 Abridged method (for -Ojit builds using Visual Studio 2008)
 ~~~
-Download the versions of all the external packages
-from 
+Download the versions of all the external packages from 
+https://bitbucket.org/pypy/pypy/downloads/local_2.4.zip
+(for 2.4 release and later) or
 https://bitbucket.org/pypy/pypy/downloads/local.zip
-Then expand it into the base directory (base_dir) and modify your environment 
to reflect this::
+(for pre-2.4 versions)
+Then expand it into the base directory (base_dir) and modify your environment
+to reflect this::
 
 set PATH=base_dir\bin;base_dir\tcltk\bin;%PATH%
 set INCLUDE=base_dir\include;base_dir\tcltk\include;%INCLUDE%
diff --git a/pypy/interpreter/pycode.py b/pypy/interpreter/pycode.py
--- a/pypy/interpreter/pycode.py
+++ b/pypy/interpreter/pycode.py
@@ -45,6 +45,7 @@
 def cpython_code_signature(code):
 ([list-of-arg-names], vararg-name-or-None, kwarg-name-or-None).
 argcount = code.co_argcount
+varnames = code.co_varnames
 if we_are_translated():
 kwonlyargcount = code.co_kwonlyargcount
 else:
@@ -52,18 +53,14 @@
 kwonlyargcount = getattr(code, 'co_kwonlyargcount', 0)
 assert argcount = 0 # annotator hint
 assert kwonlyargcount = 0
-argnames = list(code.co_varnames[:argcount])
-kwonlyargs = list(code.co_varnames[argcount:argcount + kwonlyargcount])
+argnames = list(varnames[:argcount])
+kwonlyargs = list(varnames[argcount:argcount + kwonlyargcount])
 if code.co_flags  CO_VARARGS:
-varargname = code.co_varnames[argcount]
+varargname = varnames[argcount]
 argcount += 1
 else:
 varargname = None
-if code.co_flags  CO_VARKEYWORDS:
-kwargname = code.co_varnames[argcount]
-argcount += 1
-else:
-kwargname = None
+kwargname = varnames[argcount] if code.co_flags  CO_VARKEYWORDS else None
 return Signature(argnames, varargname, kwargname, kwonlyargs)
 
 
diff --git a/pypy/interpreter/test/test_app_main.py 
b/pypy/interpreter/test/test_app_main.py
--- a/pypy/interpreter/test/test_app_main.py
+++ b/pypy/interpreter/test/test_app_main.py
@@ -1064,7 +1064,7 @@
 prefix = udir.join('pathtest').ensure(dir=1)
 fake_exe = 'bin/pypy-c'
 if sys.platform == 'win32':
-fake_exe += '.exe'
+fake_exe = 'pypy-c.exe'
 fake_exe = prefix.join(fake_exe).ensure(file=1)
 expected_path = [str(prefix.join(subdir).ensure(dir=1))
  for subdir in ('lib_pypy',
@@ -1104,8 +1104,10 @@
 assert sys.path == old_sys_path + [self.goal_dir]
 
 app_main.setup_bootstrap_path(self.fake_exe)
-assert sys.executable == ''  # not executable!
-assert sys.path == old_sys_path + [self.goal_dir]
+if not sys.platform == 'win32':
+# an existing file is always 'executable' on windows
+assert sys.executable == ''  # not executable!
+assert sys.path == old_sys_path + [self.goal_dir]
 
 os.chmod(self.fake_exe, 0o755)
 app_main.setup_bootstrap_path(self.fake_exe)
diff --git a/rpython/translator/platform/test/test_makefile.py 
b/rpython/translator/platform/test/test_makefile.py
--- a/rpython/translator/platform/test/test_makefile.py
+++ b/rpython/translator/platform/test/test_makefile.py
@@ -44,6 +44,7 @@
 assert res.returncode == 0
 
 def test_900_files(self):
+tmpdir = udir.join('test_900_files').ensure(dir=1)
 txt = '#include stdio.h\n'
 for i in range(900):
 txt += 'int func%03d();\n' % i
@@ -52,11 +53,11 @@
 txt += 'j += func%03d();\n' % i
 txt += 'printf(%d\\n, j);\n'
 txt += 'return 0;};\n'
-cfile = udir.join('test_900_files.c')
+cfile = tmpdir.join('test_900_files.c')
 cfile.write(txt)
 cfiles = [cfile]
 for i in range(900):
-cfile2 = udir.join('implement%03d.c' %i)
+cfile2 = tmpdir.join('implement%03d.c' %i)
 cfile2.write('''
 int func%03d()
 {
@@ -64,10 +65,10 @@
 }
 ''' % (i, i))
 cfiles.append(cfile2)
-mk = self.platform.gen_makefile(cfiles, ExternalCompilationInfo(), 
path=udir)
+mk = self.platform.gen_makefile(cfiles, ExternalCompilationInfo(), 
path=tmpdir)
 mk.write()
 self.platform.execute_makefile(mk)
-res = self.platform.execute(udir.join('test_900_files'))
+res = 

[pypy-commit] pypy py3k: merge default

2014-09-11 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r73481:1568c757e7cb
Date: 2014-09-11 13:47 -0700
http://bitbucket.org/pypy/pypy/changeset/1568c757e7cb/

Log:merge default

diff too long, truncating to 2000 out of 6687 lines

diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -35,280 +35,290 @@
 the beginning of each file) the files in the 'pypy' directory are each
 copyrighted by one or more of the following people and organizations:
 
-Armin Rigo
-Maciej Fijalkowski
-Carl Friedrich Bolz
-Antonio Cuni
-Amaury Forgeot d'Arc
-Samuele Pedroni
-Alex Gaynor
-Michael Hudson
-David Schneider
-Matti Picus
-Brian Kearns
-Philip Jenvey
-Holger Krekel
-Christian Tismer
-Hakan Ardo
-Benjamin Peterson
-Manuel Jacob
-Anders Chrigstrom
-Eric van Riet Paap
-Wim Lavrijsen
-Ronan Lamy
-Richard Emslie
-Alexander Schremmer
-Dan Villiom Podlaski Christiansen
-Lukas Diekmann
-Sven Hager
-Anders Lehmann
-Aurelien Campeas
-Niklaus Haldimann
-Camillo Bruni
-Laura Creighton
-Toon Verwaest
-Remi Meier
-Leonardo Santagada
-Seo Sanghyeon
-Romain Guillebert
-Justin Peel
-Ronny Pfannschmidt
-David Edelsohn
-Anders Hammarquist
-Jakub Gustak
-Guido Wesdorp
-Lawrence Oluyede
-Bartosz Skowron
-Daniel Roberts
-Niko Matsakis
-Adrien Di Mascio
-Alexander Hesse
-Ludovic Aubry
-Jacob Hallen
-Jason Creighton
-Alex Martelli
-Michal Bendowski
-Jan de Mooij
-stian
-Michael Foord
-Stephan Diehl
-Stefan Schwarzer
-Valentino Volonghi
-Tomek Meka
-Patrick Maupin
-Bob Ippolito
-Bruno Gola
-Jean-Paul Calderone
-Timo Paulssen
-Squeaky
-Alexandre Fayolle
-Simon Burton
-Marius Gedminas
-John Witulski
-Konstantin Lopuhin
-Greg Price
-Dario Bertini
-Mark Pearse
-Simon Cross
-Andreas St#252;hrk
-Jean-Philippe St. Pierre
-Guido van Rossum
-Pavel Vinogradov
-Pawe#322; Piotr Przeradowski
-Paul deGrandis
-Ilya Osadchiy
-Tobias Oberstein
-Adrian Kuhn
-Boris Feigin
-Stefano Rivera
-tav
-Taavi Burns
-Georg Brandl
-Bert Freudenberg
-Stian Andreassen
-Laurence Tratt
-Wanja Saatkamp
-Ivan Sichmann Freitas
-Gerald Klix
-Mike Blume
-Oscar Nierstrasz
-Stefan H. Muller
-Jeremy Thurgood
-Gregor Wegberg
-Rami Chowdhury
-Tobias Pape
-Edd Barrett
-David Malcolm
-Eugene Oden
-Henry Mason
-Preston Timmons
-Jeff Terrace
-David Ripton
-Dusty Phillips
-Lukas Renggli
-Guenter Jantzen
-Ned Batchelder
-Amit Regmi
-Ben Young
-Nicolas Chauvat
-Andrew Durdin
-Andrew Chambers
-Michael Schneider
-Nicholas Riley
-Jason Chu
-Igor Trindade Oliveira
-Rocco Moretti
-Gintautas Miliauskas
-Michael Twomey
-Lucian Branescu Mihaila
-Tim Felgentreff
-Tyler Wade
-Gabriel Lavoie
-Olivier Dormond
-Jared Grubb
-Karl Bartel
-Brian Dorsey
-Victor Stinner
-Andrews Medina
-Stuart Williams
-Jasper Schulz
-Christian Hudon
-Toby Watson
-Antoine Pitrou
-Aaron Iles
-Michael Cheng
-Justas Sadzevicius
-Mikael Sch#246;nenberg
-Gasper Zejn
-Neil Shepperd
-Elmo M#228;ntynen
-Jonathan David Riehl
-Stanislaw Halik
-Anders Qvist
-Chirag Jadwani
-Beatrice During
-Alex Perry
-Vincent Legoll
-Alan McIntyre
-Alexander Sedov
-Corbin Simpson
-Christopher Pope
-wenzhuman
-Christian Tismer 
-Marc Abramowitz
-Dan Stromberg
-Stefano Parmesan
-Alexis Daboville
-Jens-Uwe Mager
-Carl Meyer
-Karl Ramm
-Pieter Zieschang
-Gabriel
-Lukas Vacek
-Andrew Dalke
-Sylvain Thenault
-Nathan Taylor
-Vladimir Kryachko
-Jacek Generowicz
-Alejandro J. Cura
-Jacob Oscarson
-Travis Francis Athougies
-Ryan Gonzalez
-Kristjan Valur Jonsson
-Sebastian Pawlu#347;
-Neil Blakey-Milner
-anatoly techtonik
-Lutz Paelike
-Lucio Torre
-Lars Wassermann
-Henrik Vendelbo
-Dan Buch
-Miguel de Val Borro
-Artur Lisiecki
-Sergey Kishchenko
-Ignas Mikalajunas
-Christoph Gerum
-Martin Blais
-Lene Wagner
-Tomo Cocoa
-roberto@goyle
-Yury V. Zaytsev
-Anna Katrina Dominguez
-William Leslie
-Bobby Impollonia
-t...@eistee.fritz.box
-Andrew Thompson
-Ben Darnell
-Roberto De Ioris
-Juan Francisco Cantero Hurtado
-Godefroid Chappelle
-Joshua Gilbert
-Dan Colish
-Christopher Armstrong
-Michael Hudson-Doyle
-Anders Sigfridsson
-Yasir Suhail
-rafalgalczyn...@gmail.com
-Floris Bruynooghe
-Laurens Van Houtven
-Akira Li
-Gustavo Niemeyer
-Stephan Busemann
-Rafa#322; Ga#322;czy#324;ski

[pypy-commit] pypy py3k: merge default

2014-09-11 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r73492:8fbe4a728f3e
Date: 2014-09-11 15:57 -0700
http://bitbucket.org/pypy/pypy/changeset/8fbe4a728f3e/

Log:merge default

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
@@ -923,7 +923,7 @@
 else:
 r, w, e = rpoll.select([sock_fd], [], [], sock_timeout)
 ready = r
-except SelectError, e:
+except rpoll.SelectError as e:
 message = e.get_msg()
 raise ssl_error(space, message, e.errno)
 if ready:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: merge default

2014-08-28 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r73127:986e16e0e1fc
Date: 2014-08-28 15:47 -0700
http://bitbucket.org/pypy/pypy/changeset/986e16e0e1fc/

Log:merge default

diff too long, truncating to 2000 out of 34965 lines

diff --git a/lib-python/2.7/CGIHTTPServer.py b/lib-python/2.7/CGIHTTPServer.py
--- a/lib-python/2.7/CGIHTTPServer.py
+++ b/lib-python/2.7/CGIHTTPServer.py
@@ -84,7 +84,7 @@
 path begins with one of the strings in self.cgi_directories
 (and the next character is a '/' or the end of the string).
 
-collapsed_path = _url_collapse_path(self.path)
+collapsed_path = _url_collapse_path(urllib.unquote(self.path))
 dir_sep = collapsed_path.find('/', 1)
 head, tail = collapsed_path[:dir_sep], collapsed_path[dir_sep+1:]
 if head in self.cgi_directories:
diff --git a/lib-python/2.7/Cookie.py b/lib-python/2.7/Cookie.py
--- a/lib-python/2.7/Cookie.py
+++ b/lib-python/2.7/Cookie.py
@@ -1,6 +1,3 @@
-#!/usr/bin/env python
-#
-
 
 # Copyright 2000 by Timothy O'Malley t...@alum.mit.edu
 #
diff --git a/lib-python/2.7/HTMLParser.py b/lib-python/2.7/HTMLParser.py
--- a/lib-python/2.7/HTMLParser.py
+++ b/lib-python/2.7/HTMLParser.py
@@ -22,9 +22,12 @@
 starttagopen = re.compile('[a-zA-Z]')
 piclose = re.compile('')
 commentclose = re.compile(r'--\s*')
-tagfind = re.compile('([a-zA-Z][-.a-zA-Z0-9:_]*)(?:\s|/(?!))*')
+
 # see http://www.w3.org/TR/html5/tokenization.html#tag-open-state
 # and http://www.w3.org/TR/html5/tokenization.html#tag-name-state
+# note: if you change tagfind/attrfind remember to update locatestarttagend too
+tagfind = re.compile('([a-zA-Z][^\t\n\r\f /\x00]*)(?:\s|/(?!))*')
+# this regex is currently unused, but left for backward compatibility
 tagfind_tolerant = re.compile('[a-zA-Z][^\t\n\r\f /\x00]*')
 
 attrfind = re.compile(
@@ -32,7 +35,7 @@
 r'(\'[^\']*\'|[^]*|(?![\'])[^\s]*))?(?:\s|/(?!))*')
 
 locatestarttagend = re.compile(r
-  [a-zA-Z][-.a-zA-Z0-9:_]*  # tag name
+  [a-zA-Z][^\t\n\r\f /\x00]*   # tag name
   (?:[\s/]*  # optional whitespace before attribute 
name
 (?:(?=['\s/])[^\s/][^\s/=]*  # attribute name
   (?:\s*=+\s*# value indicator
@@ -192,9 +195,9 @@
 i = self.updatepos(i, k)
 continue
 else:
-if ; in rawdata[i:]: #bail by consuming #
-self.handle_data(rawdata[0:2])
-i = self.updatepos(i, 2)
+if ; in rawdata[i:]:  # bail by consuming '#'
+self.handle_data(rawdata[i:i+2])
+i = self.updatepos(i, i+2)
 break
 elif startswith('', i):
 match = entityref.match(rawdata, i)
@@ -373,14 +376,14 @@
 self.handle_data(rawdata[i:gtpos])
 return gtpos
 # find the name: w3.org/TR/html5/tokenization.html#tag-name-state
-namematch = tagfind_tolerant.match(rawdata, i+2)
+namematch = tagfind.match(rawdata, i+2)
 if not namematch:
 # w3.org/TR/html5/tokenization.html#end-tag-open-state
 if rawdata[i:i+3] == '/':
 return i+3
 else:
 return self.parse_bogus_comment(i)
-tagname = namematch.group().lower()
+tagname = namematch.group(1).lower()
 # consume and ignore other stuff between the name and the 
 # Note: this is not 100% correct, since we might have things like
 # /tag attr=, but looking for  after tha name should cover
diff --git a/lib-python/2.7/SimpleHTTPServer.py 
b/lib-python/2.7/SimpleHTTPServer.py
--- a/lib-python/2.7/SimpleHTTPServer.py
+++ b/lib-python/2.7/SimpleHTTPServer.py
@@ -43,8 +43,10 @@
 Serve a GET request.
 f = self.send_head()
 if f:
-self.copyfile(f, self.wfile)
-f.close()
+try:
+self.copyfile(f, self.wfile)
+finally:
+f.close()
 
 def do_HEAD(self):
 Serve a HEAD request.
@@ -88,13 +90,17 @@
 except IOError:
 self.send_error(404, File not found)
 return None
-self.send_response(200)
-self.send_header(Content-type, ctype)
-fs = os.fstat(f.fileno())
-self.send_header(Content-Length, str(fs[6]))
-self.send_header(Last-Modified, self.date_time_string(fs.st_mtime))
-self.end_headers()
-return f
+try:
+self.send_response(200)
+self.send_header(Content-type, ctype)
+fs = os.fstat(f.fileno())
+self.send_header(Content-Length, str(fs[6]))
+self.send_header(Last-Modified, 
self.date_time_string(fs.st_mtime))
+self.end_headers()
+return f
+except:
+

[pypy-commit] pypy py3k: merge default (bf3e8fa831fd)

2014-08-26 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r73066:9310ca287cdd
Date: 2014-08-24 15:54 -0700
http://bitbucket.org/pypy/pypy/changeset/9310ca287cdd/

Log:merge default (bf3e8fa831fd)

diff too long, truncating to 2000 out of 5869 lines

diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -354,6 +354,6 @@
 See the License for the specific language governing permissions and
 limitations under the License.
 
-Detailled license information is contained in the NOTICE file in the
+Detailed license information is contained in the NOTICE file in the
 directory.
 
diff --git a/lib_pypy/pyrepl/reader.py b/lib_pypy/pyrepl/reader.py
--- a/lib_pypy/pyrepl/reader.py
+++ b/lib_pypy/pyrepl/reader.py
@@ -101,7 +101,7 @@
 st = {}
 for c in map(unichr, range(256)):
 st[c] = SYNTAX_SYMBOL
-for c in [a for a in map(unichr, range(256)) if a.isalpha()]:
+for c in [a for a in map(unichr, range(256)) if a.isalnum()]:
 st[c] = SYNTAX_WORD
 st[unicode('\n')] = st[unicode(' ')] = SYNTAX_WHITESPACE
 return st
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
@@ -54,3 +54,6 @@
 .. branch: pytest-25
 Update our copies of py.test and pylib to versions 2.5.2 and 1.4.20, 
 respectively.
+
+.. branch: split-ast-classes
+Classes in the ast module are now distinct from structures used by the 
compiler.
diff --git a/pypy/doc/windows.rst b/pypy/doc/windows.rst
--- a/pypy/doc/windows.rst
+++ b/pypy/doc/windows.rst
@@ -37,7 +37,7 @@
 using a 32 bit Python and vice versa. By default pypy is built using the 
 Multi-threaded DLL (/MD) runtime environment.
 
-**Note:** PyPy is currently not supported for 64 bit Windows, and translation
+**Note:** PyPy is currently not supported for 64 bit Python, and translation
 will fail in this case.
 
 Python and a C compiler are all you need to build pypy, but it will miss some
@@ -136,7 +136,7 @@
 
 cd zlib-1.2.3
 nmake -f win32\Makefile.msc
-copy zlib1.lib somewhere in LIB
+copy zlib.lib somewhere in LIB
 copy zlib.h zconf.h somewhere in INCLUDE
 
 The bz2 compression library
@@ -165,27 +165,29 @@
 directory.  Version 2.1.0 is known to pass tests. Then open the project 
 file ``expat.dsw`` with Visual
 Studio; follow the instruction for converting the project files,
-switch to the Release configuration, reconfigure the runtime for 
-Multi-threaded DLL (/MD) and build the solution (the ``expat`` project 
-is actually enough for pypy).
+switch to the Release configuration, use the ``expat_static`` project,
+reconfigure the runtime for Multi-threaded DLL (/MD) and build.
 
-Then, copy the file ``win32\bin\release\libexpat.dll`` somewhere in
-your PATH, ``win32\bin\release\libexpat.lib`` somewhere in LIB, and
-both ``lib\expat.h`` and ``lib\expat_external.h`` somewhere in INCLUDE.
+Then, copy the file ``win32\bin\release\libexpat.lib`` somewhere in
+somewhere in LIB, and both ``lib\expat.h`` and ``lib\expat_external.h``
+somewhere in INCLUDE.
 
 The OpenSSL library
 ~~~
 
 OpenSSL needs a Perl interpreter to configure its makefile.  You may
-use the one distributed by ActiveState, or the one from cygwin.  In
-both case the perl interpreter must be found on the PATH.
+use the one distributed by ActiveState, or the one from cygwin.::
 
-svn export http://svn.python.org/projects/external/openssl-0.9.8y
-cd openssl-0.9.8y
-perl Configure VC-WIN32
+svn export http://svn.python.org/projects/external/openssl-1.0.1i
+cd openssl-1.0.1i
+perl Configure VC-WIN32 no-idea no-mdc2
 ms\do_ms.bat
 nmake -f ms\nt.mak install
 
+Then, copy the files ``out32\*.lib`` somewhere in
+somewhere in LIB, and the entire ``include\openssl`` directory as-is somewhere
+in INCLUDE.
+
 TkInter module support
 ~~
 
diff --git a/pypy/interpreter/astcompiler/ast.py 
b/pypy/interpreter/astcompiler/ast.py
--- a/pypy/interpreter/astcompiler/ast.py
+++ b/pypy/interpreter/astcompiler/ast.py
@@ -1,5 +1,4 @@
 # Generated by tools/asdl_py.py
-from rpython.rlib.unroll import unrolling_iterable
 from rpython.tool.pairtype import extendabletype
 from rpython.tool.sourcetools import func_with_new_name
 
@@ -21,11 +20,15 @@
 'AST string must be of type str or unicode'))
 return w_obj
 
-
-class AST(W_Root):
-
-w_dict = None
-
+def get_field(space, w_node, name, optional):
+w_obj = w_node.getdictvalue(space, name)
+if w_obj is None and not optional:
+raise oefmt(space.w_TypeError,
+required field \%s\ missing from %T, name, w_node)
+return w_obj
+
+
+class AST(object):
 __metaclass__ = extendabletype
 
 def walkabout(self, visitor):
@@ -34,8 +37,23 @@
 def mutate_over(self, visitor):
 raise AssertionError(mutate_over() implementation not provided)
 
-def sync_app_attrs(self, space):
-raise NotImplementedError
+
+class 

[pypy-commit] pypy py3k: merge default

2014-08-26 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r73071:e15d0862520d
Date: 2014-08-26 10:57 -0700
http://bitbucket.org/pypy/pypy/changeset/e15d0862520d/

Log:merge default

diff --git a/rpython/jit/backend/x86/callbuilder.py 
b/rpython/jit/backend/x86/callbuilder.py
--- a/rpython/jit/backend/x86/callbuilder.py
+++ b/rpython/jit/backend/x86/callbuilder.py
@@ -1,7 +1,6 @@
 import sys
 from rpython.rlib.clibffi import FFI_DEFAULT_ABI
 from rpython.rlib.objectmodel import we_are_translated
-from rpython.rtyper.lltypesystem import lltype, rffi
 from rpython.jit.metainterp.history import INT, FLOAT
 from rpython.jit.backend.x86.arch import (WORD, IS_X86_64, IS_X86_32,
   PASS_ON_MY_FRAME, FRAME_FIXED_SIZE)
@@ -22,8 +21,6 @@
 def align_stack_words(words):
 return (words + CALL_ALIGN - 1)  ~(CALL_ALIGN-1)
 
-NO_ARG_FUNC_PTR = lltype.Ptr(lltype.FuncType([], lltype.Void))
-
 
 class CallBuilderX86(AbstractCallBuilder):
 
@@ -94,30 +91,9 @@
 gcrootmap = self.asm.cpu.gc_ll_descr.gcrootmap
 if gcrootmap:
 if gcrootmap.is_shadow_stack and self.is_call_release_gil:
-from rpython.jit.backend.x86.assembler import heap
-from rpython.jit.backend.x86 import rx86
-from rpython.rtyper.lltypesystem.lloperation import llop
-#
-# When doing a call_release_gil with shadowstack, there
-# is the risk that the 'rpy_fastgil' was free but the
-# current shadowstack can be the one of a different
-# thread.  So here we check if the shadowstack pointer
-# is still the same as before we released the GIL (saved
-# in 'ebx'), and if not, we call 'thread_run'.
-rst = gcrootmap.get_root_stack_top_addr()
-mc = self.mc
-mc.CMP(ebx, heap(rst))
-mc.J_il8(rx86.Conditions['E'], 0)
-je_location = mc.get_relative_pos()
-# call 'thread_run'
-t_run = llop.gc_thread_run_ptr(NO_ARG_FUNC_PTR)
-mc.CALL(imm(rffi.cast(lltype.Signed, t_run)))
-# patch the JE above
-offset = mc.get_relative_pos() - je_location
-assert 0  offset = 127
-mc.overwrite(je_location-1, chr(offset))
+# in this mode, 'ebx' happens to contain the shadowstack
+# top at this point, so reuse it instead of loading it again
 ssreg = ebx
-#
 self.asm._reload_frame_if_necessary(self.mc, shadowstack_reg=ssreg)
 if self.change_extra_stack_depth:
 self.asm.set_extra_stack_depth(self.mc, 0)
@@ -206,8 +182,35 @@
 mc.MOV_ri(X86_64_SCRATCH_REG.value, fastgil)
 mc.XCHG_rm(old_value.value, (X86_64_SCRATCH_REG.value, 0))
 mc.CMP(old_value, css_value)
-mc.J_il8(rx86.Conditions['E'], 0)
-je_location = mc.get_relative_pos()
+#
+gcrootmap = self.asm.cpu.gc_ll_descr.gcrootmap
+if bool(gcrootmap) and gcrootmap.is_shadow_stack:
+from rpython.jit.backend.x86.assembler import heap
+#
+# When doing a call_release_gil with shadowstack, there
+# is the risk that the 'rpy_fastgil' was free but the
+# current shadowstack can be the one of a different
+# thread.  So here we check if the shadowstack pointer
+# is still the same as before we released the GIL (saved
+# in 'ebx'), and if not, we fall back to 'reacqgil_addr'.
+mc.J_il8(rx86.Conditions['NE'], 0)
+jne_location = mc.get_relative_pos()
+# here, ecx is zero (so rpy_fastgil was not acquired)
+rst = gcrootmap.get_root_stack_top_addr()
+mc = self.mc
+mc.CMP(ebx, heap(rst))
+mc.J_il8(rx86.Conditions['E'], 0)
+je_location = mc.get_relative_pos()
+# revert the rpy_fastgil acquired above, so that the
+# general 'reacqgil_addr' below can acquire it again...
+mc.MOV(heap(fastgil), ecx)
+# patch the JNE above
+offset = mc.get_relative_pos() - jne_location
+assert 0  offset = 127
+mc.overwrite(jne_location-1, chr(offset))
+else:
+mc.J_il8(rx86.Conditions['E'], 0)
+je_location = mc.get_relative_pos()
 #
 # Yes, we need to call the reacqgil() function
 self.save_result_value_reacq()
diff --git a/rpython/memory/gctransform/framework.py 
b/rpython/memory/gctransform/framework.py
--- a/rpython/memory/gctransform/framework.py
+++ b/rpython/memory/gctransform/framework.py
@@ -977,12 +977,6 @@
 hop.genop(direct_call, [self.root_walker.thread_run_ptr])
 self.pop_roots(hop, livevars)
 
-def gct_gc_thread_run_ptr(self, hop):
-

[pypy-commit] pypy py3k: merge default

2014-08-15 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r72821:57f83c7b11fc
Date: 2014-08-15 17:58 -0700
http://bitbucket.org/pypy/pypy/changeset/57f83c7b11fc/

Log:merge default

diff --git a/pypy/doc/faq.rst b/pypy/doc/faq.rst
--- a/pypy/doc/faq.rst
+++ b/pypy/doc/faq.rst
@@ -147,12 +147,25 @@
 programmer).
 
 Instead, since 2012, there is work going on on a still very experimental
-Software Transactional Memory (STM) version of PyPy.  This should give
-an alternative PyPy which internally has no GIL, while at the same time
+`Software Transactional Memory`_ (STM) version of PyPy.  This should give
+an alternative PyPy which works without a GIL, while at the same time
 continuing to give the Python programmer the complete illusion of having
-one.  It would in fact push forward *more* GIL-ish behavior, like
-declaring that some sections of the code should run without releasing
-the GIL in the middle (these are called *atomic sections* in STM).
+one.
+
+.. _`Software Transactional Memory`: stm.html
+
+--
+Is PyPy more clever than CPython about Tail Calls?
+--
+
+No.  PyPy follows the Python language design, including the built-in
+debugger features.  This prevents tail calls, as summarized by Guido
+van Rossum in two__ blog__ posts.  Moreover, neither the JIT nor
+Stackless__ change anything to that.
+
+.. __: http://neopythonic.blogspot.com/2009/04/tail-recursion-elimination.html
+.. __: http://neopythonic.blogspot.com/2009/04/final-words-on-tail-calls.html
+.. __: stackless.html
 
 --
 How do I write extension modules for PyPy?
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
@@ -309,9 +309,9 @@
 yield 5
 raise# should raise no active exception to re-raise
 gen = f()
-gen.next()  # -- 5
+next(gen)  # -- 5
 try:
-gen.next()
+next(gen)
 except TypeError:
 pass
 
diff --git a/rpython/jit/backend/llsupport/test/zrpy_gc_test.py 
b/rpython/jit/backend/llsupport/test/zrpy_gc_test.py
--- a/rpython/jit/backend/llsupport/test/zrpy_gc_test.py
+++ b/rpython/jit/backend/llsupport/test/zrpy_gc_test.py
@@ -633,9 +633,9 @@
 return n, x, x0, x1, x2, x3, x4, x5, x6, x7, l, s
 
 def after(n, x, x0, x1, x2, x3, x4, x5, x6, x7, l, s):
-check(x.x == 1800 * 2 + 1850 * 2 + 200 - 150)
+check(x.x == 1800 * 2 + 150 * 2 + 200 - 1850)
 
-return before, f, None
+return before, f, after
 
 def test_compile_framework_external_exception_handling(self):
 self.run('compile_framework_external_exception_handling')
diff --git a/rpython/rtyper/normalizecalls.py b/rpython/rtyper/normalizecalls.py
--- a/rpython/rtyper/normalizecalls.py
+++ b/rpython/rtyper/normalizecalls.py
@@ -62,6 +62,8 @@
 msg.append(the following functions:)
 msg.append(%s % (\n.join(pfg), ))
 msg.append(are called with inconsistent numbers of arguments)
+msg.append((and/or the argument names are different, which is
+not supported in this case))
 if shape1[0] != shape2[0]:
 msg.append(sometimes with %s arguments, sometimes with %s % 
(shape1[0], shape2[0]))
 else:
diff --git a/rpython/rtyper/test/test_normalizecalls.py 
b/rpython/rtyper/test/test_normalizecalls.py
--- a/rpython/rtyper/test/test_normalizecalls.py
+++ b/rpython/rtyper/test/test_normalizecalls.py
@@ -185,6 +185,7 @@
 .+Sub1.fn
 .+Sub2.fn
 are called with inconsistent numbers of arguments
+\(and/or the argument names are different, which is not supported in this 
case\)
 sometimes with \d arguments, sometimes with \d
 the callers of these functions are:
 .+otherfunc
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: merge default

2014-08-12 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r72781:92b4b658ae4b
Date: 2014-08-12 16:43 -0700
http://bitbucket.org/pypy/pypy/changeset/92b4b658ae4b/

Log:merge default

diff --git a/lib_pypy/_tkinter/__init__.py b/lib_pypy/_tkinter/__init__.py
--- a/lib_pypy/_tkinter/__init__.py
+++ b/lib_pypy/_tkinter/__init__.py
@@ -30,6 +30,10 @@
 return TkApp(screenName, className,
  interactive, wantobjects, wantTk, sync, use)
 
+def dooneevent(flags=0):
+return tklib.Tcl_DoOneEvent(flags)
+
+
 def _flatten(item):
 def _flatten1(output, item, depth):
 if depth  1000:
diff --git a/rpython/jit/backend/x86/callbuilder.py 
b/rpython/jit/backend/x86/callbuilder.py
--- a/rpython/jit/backend/x86/callbuilder.py
+++ b/rpython/jit/backend/x86/callbuilder.py
@@ -1,8 +1,9 @@
+import sys
 from rpython.rlib.clibffi import FFI_DEFAULT_ABI
 from rpython.rlib.objectmodel import we_are_translated
 from rpython.jit.metainterp.history import INT, FLOAT
 from rpython.jit.backend.x86.arch import (WORD, IS_X86_64, IS_X86_32,
-  PASS_ON_MY_FRAME)
+  PASS_ON_MY_FRAME, FRAME_FIXED_SIZE)
 from rpython.jit.backend.x86.regloc import (eax, ecx, edx, ebx, esp, ebp, esi,
 xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, r8, r9, r10, r11, edi,
 r12, r13, r14, r15, X86_64_SCRATCH_REG, X86_64_XMM_SCRATCH_REG,
@@ -15,6 +16,8 @@
 # Same for gcc 4.5.0, better safe than sorry
 CALL_ALIGN = 16 // WORD
 
+stdcall_or_cdecl = sys.platform == win32
+
 def align_stack_words(words):
 return (words + CALL_ALIGN - 1)  ~(CALL_ALIGN-1)
 
@@ -44,11 +47,6 @@
 self.stack_max = PASS_ON_MY_FRAME - asmgcroot.JIT_USE_WORDS
 assert self.stack_max = 3
 
-def emit_raw_call(self):
-self.mc.CALL(self.fnloc)
-if self.callconv != FFI_DEFAULT_ABI:
-self.current_esp += self._fix_stdcall(self.callconv)
-
 def subtract_esp_aligned(self, count):
 if count  0:
 align = align_stack_words(count)
@@ -246,6 +244,28 @@
 self.fnloc = RawEspLoc(p - WORD, INT)
 
 
+def emit_raw_call(self):
+if stdcall_or_cdecl and self.is_call_release_gil:
+# Dynamically accept both stdcall and cdecl functions.
+# We could try to detect from pyjitpl which calling
+# convention this particular function takes, which would
+# avoid these two extra MOVs... but later.  The ebp register
+# is unused here: it will be reloaded from the shadowstack.
+# (This doesn't work during testing, though. Hack hack hack.)
+save_ebp = not self.asm.cpu.gc_ll_descr.is_shadow_stack()
+ofs = WORD * (FRAME_FIXED_SIZE - 1)
+if save_ebp:# only for testing (or with Boehm)
+self.mc.MOV_sr(ofs, ebp.value)
+self.mc.MOV(ebp, esp)
+self.mc.CALL(self.fnloc)
+self.mc.MOV(esp, ebp)
+if save_ebp:# only for testing (or with Boehm)
+self.mc.MOV_rs(ebp.value, ofs)
+else:
+self.mc.CALL(self.fnloc)
+if self.callconv != FFI_DEFAULT_ABI:
+self.current_esp += self._fix_stdcall(self.callconv)
+
 def _fix_stdcall(self, callconv):
 from rpython.rlib.clibffi import FFI_STDCALL
 assert callconv == FFI_STDCALL
@@ -417,8 +437,9 @@
 remap_frame_layout(self.asm, src_locs, dst_locs, X86_64_SCRATCH_REG)
 
 
-def _fix_stdcall(self, callconv):
-assert 0 # should not occur on 64-bit
+def emit_raw_call(self):
+assert self.callconv == FFI_DEFAULT_ABI
+self.mc.CALL(self.fnloc)
 
 def load_result(self):
 if self.restype == 'S':
diff --git a/rpython/jit/backend/x86/test/test_runner.py 
b/rpython/jit/backend/x86/test/test_runner.py
--- a/rpython/jit/backend/x86/test/test_runner.py
+++ b/rpython/jit/backend/x86/test/test_runner.py
@@ -438,20 +438,26 @@
 if WORD != 4:
 py.test.skip(32-bit only test)
 from rpython.jit.backend.x86.regloc import eax, edx
-from rpython.jit.backend.x86 import codebuf
+from rpython.jit.backend.x86 import codebuf, callbuilder
 from rpython.jit.codewriter.effectinfo import EffectInfo
 from rpython.rlib.libffi import types, clibffi
 had_stdcall = hasattr(clibffi, 'FFI_STDCALL')
 if not had_stdcall:# not running on Windows, but we can still test
 monkeypatch.setattr(clibffi, 'FFI_STDCALL', 12345, raising=False)
+monkeypatch.setattr(callbuilder, 'stdcall_or_cdecl', True)
+else:
+assert callbuilder.stdcall_or_cdecl
 #
-for ffi in [clibffi.FFI_DEFAULT_ABI, clibffi.FFI_STDCALL]:
+for real_ffi, reported_ffi in [
+   (clibffi.FFI_DEFAULT_ABI, clibffi.FFI_DEFAULT_ABI),
+   (clibffi.FFI_STDCALL, clibffi.FFI_DEFAULT_ABI),
+

[pypy-commit] pypy py3k: merge default

2014-08-11 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r72756:87910b468690
Date: 2014-08-11 17:12 -0700
http://bitbucket.org/pypy/pypy/changeset/87910b468690/

Log:merge default

diff too long, truncating to 2000 out of 10648 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.2.4.dev2'
+__version__ = '2.5.2'
diff --git a/_pytest/_argcomplete.py b/_pytest/_argcomplete.py
new file mode 100644
--- /dev/null
+++ b/_pytest/_argcomplete.py
@@ -0,0 +1,104 @@
+
+allow bash-completion for argparse with argcomplete if installed
+needs argcomplete=0.5.6 for python 3.2/3.3 (older versions fail
+to find the magic string, so _ARGCOMPLETE env. var is never set, and
+this does not need special code.
+
+argcomplete does not support python 2.5 (although the changes for that
+are minor).
+
+Function try_argcomplete(parser) should be called directly before
+the call to ArgumentParser.parse_args().
+
+The filescompleter is what you normally would use on the positional
+arguments specification, in order to get dirname/ after dirnTAB
+instead of the default dirname :
+
+   optparser.add_argument(Config._file_or_dir, nargs='*'
+   ).completer=filescompleter
+
+Other, application specific, completers should go in the file
+doing the add_argument calls as they need to be specified as .completer
+attributes as well. (If argcomplete is not installed, the function the
+attribute points to will not be used).
+
+SPEEDUP
+===
+The generic argcomplete script for bash-completion
+(/etc/bash_completion.d/python-argcomplete.sh )
+uses a python program to determine startup script generated by pip.
+You can speed up completion somewhat by changing this script to include
+  # PYTHON_ARGCOMPLETE_OK
+so the the python-argcomplete-check-easy-install-script does not
+need to be called to find the entry point of the code and see if that is
+marked  with PYTHON_ARGCOMPLETE_OK
+
+INSTALL/DEBUGGING
+=
+To include this support in another application that has setup.py generated
+scripts:
+- add the line:
+# PYTHON_ARGCOMPLETE_OK
+  near the top of the main python entry point
+- include in the file calling parse_args():
+from _argcomplete import try_argcomplete, filescompleter
+   , call try_argcomplete just before parse_args(), and optionally add
+   filescompleter to the positional arguments' add_argument()
+If things do not work right away:
+- switch on argcomplete debugging with (also helpful when doing custom
+  completers):
+export _ARC_DEBUG=1
+- run:
+python-argcomplete-check-easy-install-script $(which appname)
+echo $?
+  will echo 0 if the magic line has been found, 1 if not
+- sometimes it helps to find early on errors using:
+_ARGCOMPLETE=1 _ARC_DEBUG=1 appname
+  which should throw a KeyError: 'COMPLINE' (which is properly set by the
+  global argcomplete script).
+
+
+import sys
+import os
+from glob import glob
+
+class FastFilesCompleter:
+'Fast file completer class'
+def __init__(self, directories=True):
+self.directories = directories
+
+def __call__(self, prefix, **kwargs):
+only called on non option completions
+if os.path.sep in prefix[1:]: #
+prefix_dir = len(os.path.dirname(prefix) + os.path.sep)
+else:
+prefix_dir = 0
+completion = []
+globbed = []
+if '*' not in prefix and '?' not in prefix:
+if prefix[-1] == os.path.sep:  # we are on unix, otherwise no bash
+globbed.extend(glob(prefix + '.*'))
+prefix += '*'
+globbed.extend(glob(prefix))
+for x in sorted(globbed):
+if os.path.isdir(x):
+x += '/'
+# append stripping the prefix (like bash, not like compgen)
+completion.append(x[prefix_dir:])
+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:
+sys.exit(-1)
+filescompleter = FastFilesCompleter()
+
+def try_argcomplete(parser):
+argcomplete.autocomplete(parser)
+else:
+def try_argcomplete(parser): pass
+filescompleter = None
diff --git a/_pytest/assertion/__init__.py b/_pytest/assertion/__init__.py
--- a/_pytest/assertion/__init__.py
+++ b/_pytest/assertion/__init__.py
@@ -3,7 +3,6 @@
 
 import py
 import sys
-import pytest
 from _pytest.monkeypatch import monkeypatch
 from _pytest.assertion import util
 
@@ -19,8 +18,8 @@
 to provide assert expression information. )
 group.addoption('--no-assert', action=store_true, default=False,
 dest=noassert, help=DEPRECATED equivalent to --assert=plain)
-group.addoption('--nomagic', action=store_true, default=False,
-dest=nomagic, 

[pypy-commit] pypy py3k: merge default

2014-08-11 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r72757:2ccf30804e12
Date: 2014-08-11 17:13 -0700
http://bitbucket.org/pypy/pypy/changeset/2ccf30804e12/

Log:merge default

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
@@ -3,9 +3,8 @@
 It uses 'pypy/goal/pypy-c' and parts of the rest of the working
 copy.  Usage:
 
-package.py [--options]
+package.py [--options] pypy-VER-PLATFORM
 
-Usually you would do:   package.py --version-name pypy-VER-PLATFORM
 The output is found in the directory from --builddir,
 by default /tmp/usession-YOURNAME/build/.
 
@@ -52,13 +51,18 @@
 
 sep_template = \nThis copy of PyPy includes a copy of %s, which is licensed 
under the following terms:\n\n
 
-def generate_license_linux(basedir, options):
+def generate_license(basedir, options):
 base_file = str(basedir.join('LICENSE'))
 with open(base_file) as fid:
 txt = fid.read()
-searches = [(bzip2,libbz2-*, copyright, '-'),
-(openssl, openssl*, copyright, 'LICENSE ISSUES'),
-   ]
+if sys.platform == 'win32':
+# shutil.copyfileobj(open(crtlicense.txt), out) # We do not ship
+#   msvc runtime files, but otherwise we'd need this on Windows
+searches = [(bzip2,bzip2-*, LICENSE, ''),
+(openssl, openssl-*, LICENSE, '')]
+else:
+searches = [(bzip2,libbz2-*dev, copyright, '-'),
+(openssl, openssl*, copyright, 'LICENSE ISSUES')]
 if not options.no_tk:
 name = 'Tcl/Tk'
 txt += License for '%s' %name
@@ -73,9 +77,9 @@
 txt += sep_template % name
 dirs = glob.glob(options.license_base + / +pat)
 if not dirs:
-raise ValueError, Could not find + options.license_base + / + 
pat
-if len(dirs)  2:
-raise ValueError, Multiple copies of +pat
+raise ValueError, Could not find %s/%s % (options.license_base, 
pat)
+if len(dirs)  1:
+raise ValueError, Multiple copies of %r: %r % (pat, dirs)
 dir = dirs[0]
 with open(os.path.join(dir, fname)) as fid:
 # Read up to the line dividing the packaging header from the 
actual copyright
@@ -92,43 +96,6 @@
 txt += gdbm_bit
 return txt
 
-def generate_license_windows(basedir, options):
-base_file = str(basedir.join('LICENSE'))
-with open(base_file) as fid:
-txt = fid.read()
-# shutil.copyfileobj(open(crtlicense.txt), out) # We do not ship msvc 
runtime files
-if not options.no_tk:
-name = 'Tcl/Tk'
-txt += License for '%s' %name
-txt += '\n' + =*(14 + len(name)) + '\n'
-txt += sep_template % name
-base_file = str(basedir.join('lib_pypy/_tkinter/license.terms'))
-with open(base_file, 'r') as fid:
-txt += fid.read()
-for name, pat, file in ((bzip2,bzip2-*, LICENSE),
-  (openssl, openssl-*, LICENSE)):
-txt += sep_template % name
-dirs = glob.glob(options.license_base + / +pat)
-if not dirs:
-raise ValueError, Could not find + options.license_base + / + 
pat
-if len(dirs)  2:
-raise ValueError, Multiple copies of +pat
-dir = dirs[0]
-with open(os.path.join(dir, file)) as fid:
-txt += fid.read()
-return txt
-
-def generate_license_darwin(basedir, options):
-# where are copyright files on macos?
-return generate_license_linux(basedir, options)
-
-if sys.platform == 'win32':
-generate_license = generate_license_windows
-elif sys.platform == 'darwin':
-generate_license = generate_license_darwin
-else:
-generate_license = generate_license_linux
-
 def create_cffi_import_libraries(pypy_c, options):
 modules = ['_sqlite3']
 subprocess.check_call([str(pypy_c), '-c', 'import _sqlite3'])
@@ -406,7 +373,9 @@
 
 
 The _gdbm module includes code from gdbm.h, which is distributed under the 
terms
-of the GPL license version 2 or any later version.
+of the GPL license version 2 or any later version.  Thus the _gdbm module, 
provided in
+the file lib_pypy/_gdbm.py, is redistributed under the terms of the GPL 
license as
+well.
 '''
 
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: merge default

2014-08-03 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r72671:8afd884adfe3
Date: 2014-08-03 10:49 -0700
http://bitbucket.org/pypy/pypy/changeset/8afd884adfe3/

Log:merge default

diff --git a/pypy/module/__builtin__/app_inspect.py 
b/pypy/module/__builtin__/app_inspect.py
--- a/pypy/module/__builtin__/app_inspect.py
+++ b/pypy/module/__builtin__/app_inspect.py
@@ -78,22 +78,13 @@
 recursively.
 
 names = set()
-try:
-names.update(klass.__dict__)
-except AttributeError:
-pass
-try:
-# XXX - Use of .__mro__ would be suggested, if the existance of
-# that attribute could be guarranted.
-bases = klass.__bases__
-except AttributeError:
-pass
-else:
-try:
-# Note that since we are only interested in the keys, the
-# order we merge classes is unimportant
-for base in bases:
-names.update(_classdir(base))
-except TypeError:
-pass
+ns = getattr(klass, '__dict__', None)
+if ns is not None:
+names.update(ns)
+bases = getattr(klass, '__bases__', None)
+if bases is not None:
+# Note that since we are only interested in the keys, the order
+# we merge classes is unimportant
+for base in bases:
+names.update(_classdir(base))
 return names
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: merge default

2014-08-01 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r72637:33d48832dcfd
Date: 2014-08-01 15:21 -0700
http://bitbucket.org/pypy/pypy/changeset/33d48832dcfd/

Log:merge default

diff --git a/pypy/doc/coding-guide.rst b/pypy/doc/coding-guide.rst
--- a/pypy/doc/coding-guide.rst
+++ b/pypy/doc/coding-guide.rst
@@ -740,7 +740,7 @@
 
 Adding an entry under pypy/module (e.g. mymodule) entails automatic
 creation of a new config option (such as --withmod-mymodule and
---withoutmod-mymodule (the later being the default)) for py.py and
+--withoutmod-mymodule (the latter being the default)) for py.py and
 translate.py.
 
 Testing modules in ``lib_pypy/``
@@ -931,7 +931,7 @@
 assert self.result == 2 ** 6
 
 which executes the code string function with the given arguments at app level.
-Note the use of ``w_result`` in ``setup_class`` but self.result in the test 
+Note the use of ``w_result`` in ``setup_class`` but self.result in the test.
 Here is how to define an app level class  in ``setup_class`` that can be used
 in subsequent tests::
 
diff --git a/pypy/doc/cpython_differences.rst b/pypy/doc/cpython_differences.rst
--- a/pypy/doc/cpython_differences.rst
+++ b/pypy/doc/cpython_differences.rst
@@ -328,7 +328,7 @@
 * directly calling the internal magic methods of a few built-in types
   with invalid arguments may have a slightly different result.  For
   example, ``[].__add__(None)`` and ``(2).__add__(None)`` both return
-  ``NotImplemented`` on PyPy; on CPython, only the later does, and the
+  ``NotImplemented`` on PyPy; on CPython, only the latter does, and the
   former raises ``TypeError``.  (Of course, ``[]+None`` and ``2+None``
   both raise ``TypeError`` everywhere.)  This difference is an
   implementation detail that shows up because of internal C-level slots
diff --git a/pypy/interpreter/pycompiler.py b/pypy/interpreter/pycompiler.py
--- a/pypy/interpreter/pycompiler.py
+++ b/pypy/interpreter/pycompiler.py
@@ -96,7 +96,7 @@
 
 XXX: This class should override the baseclass implementation of
  compile_command() in order to optimize it, especially in case
- of incomplete inputs (e.g. we shouldn't re-compile from sracth
+ of incomplete inputs (e.g. we shouldn't re-compile from scratch
  the whole source after having only added a new '\n')
 
 def __init__(self, space, override_version=None):
diff --git a/pypy/interpreter/test/test_typedef.py 
b/pypy/interpreter/test/test_typedef.py
--- a/pypy/interpreter/test/test_typedef.py
+++ b/pypy/interpreter/test/test_typedef.py
@@ -394,6 +394,13 @@
 # differs from .im_class in case the method is
 # defined in some parent class of l's actual class
 
+def test_classmethod_im_class(self):
+class Foo(object):
+@classmethod
+def bar(cls):
+pass
+assert Foo.bar.im_class is type
+
 def test_func_closure(self):
 x = 2
 def f():
diff --git a/rpython/flowspace/test/test_model.py 
b/rpython/flowspace/test/test_model.py
--- a/rpython/flowspace/test/test_model.py
+++ b/rpython/flowspace/test/test_model.py
@@ -13,7 +13,7 @@
 class pieces:
  The manually-built graph corresponding to the sample_function().
 
-i = Variable(i)
+i0 = Variable(i0)
 i1 = Variable(i1)
 i2 = Variable(i2)
 i3 = Variable(i3)
@@ -25,12 +25,12 @@
 conditionop = SpaceOperation(gt, [i1, Constant(0)], conditionres)
 addop = SpaceOperation(add, [sum2, i2], sum3)
 decop = SpaceOperation(sub, [i2, Constant(1)], i3)
-startblock = Block([i])
+startblock = Block([i0])
 headerblock = Block([i1, sum1])
 whileblock = Block([i2, sum2])
 
 graph = FunctionGraph(f, startblock)
-startblock.closeblock(Link([i, Constant(0)], headerblock))
+startblock.closeblock(Link([i0, Constant(0)], headerblock))
 headerblock.operations.append(conditionop)
 headerblock.exitswitch = conditionres
 headerblock.closeblock(Link([sum1], graph.returnblock, False),
@@ -55,7 +55,7 @@
 def test_graphattributes():
 assert graph.startblock is pieces.startblock
 assert graph.returnblock is pieces.headerblock.exits[0].target
-assert graph.getargs() == [pieces.i]
+assert graph.getargs() == [pieces.i0]
 assert [graph.getreturnvar()] == graph.returnblock.inputargs
 assert graph.source == inspect.getsource(sample_function)
 
diff --git a/rpython/jit/backend/llsupport/test/ztranslation_test.py 
b/rpython/jit/backend/llsupport/test/ztranslation_test.py
--- a/rpython/jit/backend/llsupport/test/ztranslation_test.py
+++ b/rpython/jit/backend/llsupport/test/ztranslation_test.py
@@ -21,7 +21,7 @@
 # this is a basic test that tries to hit a number of features and their
 # translation:
 # - jitting of loops and bridges
-# - virtualizables
+# - two virtualizable types
 # - set_param interface
 # - profiler
 # - full optimizer
@@ -79,22 

[pypy-commit] pypy py3k: merge default

2014-08-01 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r72652:20b6589f4314
Date: 2014-08-01 18:05 -0700
http://bitbucket.org/pypy/pypy/changeset/20b6589f4314/

Log:merge default

diff --git a/pypy/module/__builtin__/app_inspect.py 
b/pypy/module/__builtin__/app_inspect.py
--- a/pypy/module/__builtin__/app_inspect.py
+++ b/pypy/module/__builtin__/app_inspect.py
@@ -7,8 +7,8 @@
 
 from __pypy__ import lookup_special
 
-def _caller_locals(): 
-return sys._getframe(0).f_locals 
+def _caller_locals():
+return sys._getframe(0).f_locals
 
 def vars(*obj):
 Return a dictionary of all the attributes currently bound in obj.  If
@@ -18,11 +18,10 @@
 return _caller_locals()
 elif len(obj) != 1:
 raise TypeError(vars() takes at most 1 argument.)
-else:
-try:
-return obj[0].__dict__
-except AttributeError:
-raise TypeError(vars() argument must have __dict__ attribute)
+try:
+return obj[0].__dict__
+except AttributeError:
+raise TypeError(vars() argument must have __dict__ attribute)
 
 def dir(*args):
 dir([object]) - list of strings
@@ -38,77 +37,74 @@
 attributes of its class's base classes.
 
 if len(args)  1:
-raise TypeError(dir expected at most 1 arguments, got %d
-% len(args))
+raise TypeError(dir expected at most 1 arguments, got %d % len(args))
 if len(args) == 0:
 local_names = list(_caller_locals().keys()) # 2 stackframes away
 local_names.sort()
 return local_names
 
 import types
-
 obj = args[0]
-
 dir_meth = lookup_special(obj, __dir__)
 if dir_meth is not None:
-result = dir_meth()
-if not isinstance(result, list):
+names = dir_meth()
+if not isinstance(names, list):
 raise TypeError(__dir__() must return a list, not %r % (
-type(result),))
-result.sort()
-return result
+type(names),))
+names.sort()
+return names
 elif isinstance(obj, types.ModuleType):
 try:
-result = list(obj.__dict__)
-result.sort()
-return result
+return sorted(obj.__dict__)
 except AttributeError:
 return []
+elif isinstance(obj, type):
+# Don't look at __class__, as metaclass methods would be confusing.
+return sorted(_classdir(obj))
+else:
+names = set()
+ns = getattr(obj, '__dict__', None)
+if isinstance(ns, dict):
+names.update(ns)
+klass = getattr(obj, '__class__', None)
+if klass is not None:
+names.update(_classdir(klass))
 
-elif isinstance(obj, type):
-#Don't look at __class__, as metaclass methods would be confusing.
-result = list(_classdir(obj).keys())
-result.sort()
-return result
+## Comment from object.c:
+## /* Merge in __members__ and __methods__ (if any).
+## XXX Would like this to go away someday; for now, it's
+## XXX needed to get at im_self etc of method objects. */
+for attr in '__members__', '__methods__':
+l = getattr(obj, attr, None)
+if not isinstance(l, list):
+continue
+names.extend(item for item in l if isinstance(item, str))
 
-else: #(regular item)
-Dict = {}
-try:
-if isinstance(obj.__dict__, dict):
-Dict.update(obj.__dict__)
-except AttributeError:
-pass
-try:
-Dict.update(_classdir(obj.__class__))
-except AttributeError:
-pass
-result = list(Dict.keys())
-result.sort()
-return result
+return sorted(names)
 
 def _classdir(klass):
-Return a dict of the accessible attributes of class/type klass.
+Return a set of the accessible attributes of class/type klass.
 
-This includes all attributes of klass and all of the
-base classes recursively.
-
-The values of this dict have no meaning - only the keys have
-meaning.  
+This includes all attributes of klass and all of the base classes
+recursively.
 
-Dict = {}
+names = set()
 try:
-Dict.update(klass.__dict__)
-except AttributeError: pass 
+names.update(klass.__dict__)
+except AttributeError:
+pass
 try:
-# XXX - Use of .__mro__ would be suggested, if the existance
-#   of that attribute could be guarranted.
+# XXX - Use of .__mro__ would be suggested, if the existance of
+# that attribute could be guarranted.
 bases = klass.__bases__
-except AttributeError: pass
+except AttributeError:
+pass
 else:
 try:
-#Note that since we are only interested in the keys,
-#  the order we merge classes is unimportant
+# Note that 

[pypy-commit] pypy py3k: merge default

2014-07-27 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r72586:02100350c9f0
Date: 2014-07-27 16:49 -0700
http://bitbucket.org/pypy/pypy/changeset/02100350c9f0/

Log:merge default

diff --git a/lib_pypy/_curses.py b/lib_pypy/_curses.py
--- a/lib_pypy/_curses.py
+++ b/lib_pypy/_curses.py
@@ -309,11 +309,9 @@
 #endif
 
 int _m_ispad(WINDOW *win) {
-#if defined WINDOW_HAS_FLAGS
+// curses.h may not have _flags (and possibly _ISPAD),
+// but for now let's assume that ncurses.h always has it
 return (win-_flags  _ISPAD);
-#else
-return 0;
-#endif
 }
 
 void _m_getsyx(int *yx) {
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -204,7 +204,7 @@
 elif opcode == opcodedesc.BREAK_LOOP.index:
 next_instr = self.BREAK_LOOP(oparg, next_instr)
 elif opcode == opcodedesc.CONTINUE_LOOP.index:
-next_instr = self.CONTINUE_LOOP(oparg, next_instr)
+return self.CONTINUE_LOOP(oparg, next_instr)
 elif opcode == opcodedesc.FOR_ITER.index:
 next_instr = self.FOR_ITER(oparg, next_instr)
 elif opcode == opcodedesc.JUMP_FORWARD.index:
diff --git a/pypy/objspace/std/iterobject.py b/pypy/objspace/std/iterobject.py
--- a/pypy/objspace/std/iterobject.py
+++ b/pypy/objspace/std/iterobject.py
@@ -30,10 +30,6 @@
 raise NotImplementedError
 
 def descr_reduce(self, space):
-
-XXX to do: remove this __reduce__ method and do
-a registration with copy_reg, instead.
-
 from pypy.interpreter.mixedmodule import MixedModule
 w_mod = space.getbuiltinmodule('_pickle_support')
 mod = space.interp_w(MixedModule, w_mod)
@@ -125,10 +121,6 @@
 self.index = space.int_w(self.w_len) + index
 
 def descr_reduce(self, space):
-
-XXX to do: remove this __reduce__ method and do
-a registration with copy_reg, instead.
-
 from pypy.interpreter.mixedmodule import MixedModule
 w_mod = space.getbuiltinmodule('_pickle_support')
 mod = space.interp_w(MixedModule, w_mod)
diff --git a/rpython/jit/metainterp/test/test_virtualref.py 
b/rpython/jit/metainterp/test/test_virtualref.py
--- a/rpython/jit/metainterp/test/test_virtualref.py
+++ b/rpython/jit/metainterp/test/test_virtualref.py
@@ -34,7 +34,7 @@
 #
 def check_call(op, fname):
 assert op.opname == 'direct_call'
-assert op.args[0].value._obj._name == fname
+assert op.args[0].value._obj._name.startswith(fname)
 #
 ops = [op for block, op in graph.iterblockops()]
 check_call(ops[-3], 'virtual_ref')
diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py
--- a/rpython/rlib/jit.py
+++ b/rpython/rlib/jit.py
@@ -340,6 +340,7 @@
 # 
 # VRefs
 
+@specialize.argtype(0)
 def virtual_ref(x):
 Creates a 'vref' object that contains a reference to 'x'.  Calls
 to virtual_ref/virtual_ref_finish must be properly nested.  The idea
@@ -351,6 +352,7 @@
 return DirectJitVRef(x)
 virtual_ref.oopspec = 'virtual_ref(x)'
 
+@specialize.argtype(1)
 def virtual_ref_finish(vref, x):
 See docstring in virtual_ref(x)
 keepalive_until_here(x)   # otherwise the whole function call is removed
diff --git a/rpython/translator/platform/windows.py 
b/rpython/translator/platform/windows.py
--- a/rpython/translator/platform/windows.py
+++ b/rpython/translator/platform/windows.py
@@ -375,21 +375,28 @@
 for rule in rules:
 m.rule(*rule)
 
+if len(headers_to_precompile)0 and self.version = 80:
+# at least from VS2013 onwards we need to include PCH
+# objects in the final link command
+linkobjs = 'stdafx.obj @\n$(OBJECTS)\n'
+else:
+linkobjs = '@\n$(OBJECTS)\n'
+
 if self.version  80:
 m.rule('$(TARGET)', '$(OBJECTS)',
 [ '$(CC_LINK) /nologo $(LDFLAGS) $(LDFLAGSEXTRA) /out:$@' 
+\
-  ' $(LIBDIRS) $(LIBS) @\n$(OBJECTS)\n',
+  ' $(LIBDIRS) $(LIBS) ' + linkobjs,
])
 else:
 m.rule('$(TARGET)', '$(OBJECTS)',
 [ '$(CC_LINK) /nologo $(LDFLAGS) $(LDFLAGSEXTRA)' + \
   ' $(LINKFILES) /out:$@ $(LIBDIRS) $(LIBS) /MANIFEST' + \
-  ' /MANIFESTFILE:$*.manifest @\n$(OBJECTS)\n',
+  ' /MANIFESTFILE:$*.manifest ' + linkobjs,
 'mt.exe -nologo -manifest $*.manifest 
-outputresource:$@;1',
 ])
 m.rule('debugmode_$(TARGET)', '$(OBJECTS)',
 [ '$(CC_LINK) /nologo /DEBUG $(LDFLAGS) $(LDFLAGSEXTRA)' + \
-  ' $(LINKFILES) /out:$@ $(LIBDIRS) $(LIBS) 
@\n$(OBJECTS)\n',
+  ' $(LINKFILES) 

[pypy-commit] pypy py3k: merge default

2014-07-19 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r72475:8064c75eb975
Date: 2014-07-19 11:35 -0700
http://bitbucket.org/pypy/pypy/changeset/8064c75eb975/

Log:merge default

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
@@ -307,13 +307,13 @@
 w_co = space.appexec([], '''():
 def g(x):
 yield x + 5
-return g.func_code
+return g.__code__
 ''')
 assert should_not_inline(w_co) == False
 w_co = space.appexec([], '''():
 def g(x):
 yield x + 5
 yield x + 6
-return g.func_code
+return g.__code__
 ''')
 assert should_not_inline(w_co) == True
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: merge default

2014-07-16 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r72461:cd0604d4ee65
Date: 2014-07-16 14:05 -0700
http://bitbucket.org/pypy/pypy/changeset/cd0604d4ee65/

Log:merge default

diff --git a/lib-python/2.7/xml/sax/saxutils.py 
b/lib-python/2.7/xml/sax/saxutils.py
--- a/lib-python/2.7/xml/sax/saxutils.py
+++ b/lib-python/2.7/xml/sax/saxutils.py
@@ -98,13 +98,14 @@
 except AttributeError:
 pass
 # wrap a binary writer with TextIOWrapper
-class UnbufferedTextIOWrapper(io.TextIOWrapper):
-def write(self, s):
-super(UnbufferedTextIOWrapper, self).write(s)
-self.flush()
-return UnbufferedTextIOWrapper(buffer, encoding=encoding,
+return _UnbufferedTextIOWrapper(buffer, encoding=encoding,
errors='xmlcharrefreplace',
newline='\n')
+# PyPy: moved this class outside the function above
+class _UnbufferedTextIOWrapper(io.TextIOWrapper):
+def write(self, s):
+super(_UnbufferedTextIOWrapper, self).write(s)
+self.flush()
 
 class XMLGenerator(handler.ContentHandler):
 
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1459,9 +1459,7 @@
 return buf.as_str()
 
 def str_or_None_w(self, w_obj):
-if self.is_w(w_obj, self.w_None):
-return None
-return self.str_w(w_obj)
+return None if self.is_none(w_obj) else self.str_w(w_obj)
 
 def str_w(self, w_obj):
 
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
@@ -1,17 +1,16 @@
-from __future__ import with_statement
-from rpython.rtyper.lltypesystem import rffi, lltype
-from pypy.interpreter.error import OperationError, oefmt, wrap_oserror
-from pypy.interpreter.baseobjspace import W_Root
-from pypy.interpreter.typedef import TypeDef, GetSetProperty
-from pypy.interpreter.gateway import interp2app, unwrap_spec
+import weakref
 
+from rpython.rlib import rpoll, rsocket
 from rpython.rlib.rarithmetic import intmask
-from rpython.rlib import rpoll, rsocket
 from rpython.rlib.ropenssl import *
 from rpython.rlib.rposix import get_errno, set_errno
+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 GetSetProperty, TypeDef
 from pypy.module._socket import interp_socket
-import weakref
 
 
 ## user defined constants
@@ -296,19 +295,15 @@
 
 Mix string into the OpenSSL PRNG state.  entropy (a float) is a lower
 bound on the entropy contained in string.
-
-buf = rffi.str2charp(string)
-try:
+with rffi.scoped_str2charp(string) as buf:
 libssl_RAND_add(buf, len(string), entropy)
-finally:
-rffi.free_charp(buf)
 
 def RAND_status(space):
 RAND_status() - 0 or 1
 
-Returns 1 if the OpenSSL PRNG has been seeded with enough data and 0 
if not.
-It is necessary to seed the PRNG with RAND_add() on some platforms 
before
-using the ssl() function.
+Returns 1 if the OpenSSL PRNG has been seeded with enough data
+and 0 if not.  It is necessary to seed the PRNG with RAND_add()
+on some platforms before using the ssl() function.
 
 res = libssl_RAND_status()
 return space.wrap(res)
@@ -320,16 +315,12 @@
 Queries the entropy gather daemon (EGD) on socket path.  Returns number
 of bytes read.  Raises socket.sslerror if connection to EGD fails or
 if it does provide enough data to seed PRNG.
-
-socket_path = rffi.str2charp(path)
-try:
+with rffi.scoped_str2charp(path) as socket_path:
 bytes = libssl_RAND_egd(socket_path)
-finally:
-rffi.free_charp(socket_path)
 if bytes == -1:
-msg = EGD connection failed or EGD did not return
-msg +=  enough data to seed the PRNG
-raise ssl_error(space, msg)
+raise ssl_error(space,
+EGD connection failed or EGD did not return 
+enough data to seed the PRNG)
 return space.wrap(bytes)
 
 
@@ -354,7 +345,7 @@
 of bytes written.
 w_socket = self._get_socket(space)
 
-sockstate = check_socket_and_wait_for_timeout(space, w_socket, True)
+sockstate = checkwait(space, w_socket, True)
 if sockstate == SOCKET_HAS_TIMED_OUT:
 raise ssl_error(space, The write operation timed out)
 elif sockstate == SOCKET_HAS_BEEN_CLOSED:
@@ -370,11 +361,9 @@
 err = libssl_SSL_get_error(self.ssl, num_bytes)
 

[pypy-commit] pypy py3k: merge default

2014-07-15 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r72451:6934ff2f69be
Date: 2014-07-15 22:57 -0700
http://bitbucket.org/pypy/pypy/changeset/6934ff2f69be/

Log:merge default

diff --git a/pypy/module/micronumpy/boxes.py b/pypy/module/micronumpy/boxes.py
--- a/pypy/module/micronumpy/boxes.py
+++ b/pypy/module/micronumpy/boxes.py
@@ -153,12 +153,10 @@
 raise OperationError(space.w_IndexError, space.wrap(
 invalid index to scalar variable))
 
-'''
 def descr_iter(self, space):
 # Making numpy scalar non-iterable with a valid __getitem__ method
 raise oefmt(space.w_TypeError,
 '%T' object is not iterable, self)
-'''
 
 def descr_str(self, space):
 return space.wrap(self.get_dtype(space).itemtype.str_format(self))
@@ -501,6 +499,9 @@
 return space.wrap(dtype.itemtype.to_str(read_val))
 return read_val
 
+def descr_iter(self, space):
+return space.newseqiter(self)
+
 def descr_setitem(self, space, w_item, w_value):
 if (space.isinstance_w(w_item, space.w_bytes) or
 space.isinstance_w(w_item, space.w_unicode)):
@@ -551,7 +552,7 @@
 __new__ = interp2app(W_GenericBox.descr__new__.im_func),
 
 __getitem__ = interp2app(W_GenericBox.descr_getitem),
-#__iter__ = interp2app(W_GenericBox.descr_iter),
+__iter__ = interp2app(W_GenericBox.descr_iter),
 __str__ = interp2app(W_GenericBox.descr_str),
 __repr__ = interp2app(W_GenericBox.descr_str),
 __format__ = interp2app(W_GenericBox.descr_format),
@@ -772,6 +773,7 @@
 __new__ = interp2app(W_VoidBox.descr__new__.im_func),
 __getitem__ = interp2app(W_VoidBox.descr_getitem),
 __setitem__ = interp2app(W_VoidBox.descr_setitem),
+__iter__ = interp2app(W_VoidBox.descr_iter),
 )
 
 W_CharacterBox.typedef = TypeDef(numpy.character, W_FlexibleBox.typedef,
diff --git a/pypy/module/micronumpy/descriptor.py 
b/pypy/module/micronumpy/descriptor.py
--- a/pypy/module/micronumpy/descriptor.py
+++ b/pypy/module/micronumpy/descriptor.py
@@ -6,7 +6,7 @@
 from pypy.interpreter.typedef import (TypeDef, GetSetProperty,
   interp_attrproperty, 
interp_attrproperty_w)
 from rpython.rlib import jit
-from rpython.rlib.objectmodel import specialize
+from rpython.rlib.objectmodel import specialize, compute_hash
 from rpython.rlib.rarithmetic import r_longlong, r_ulonglong
 from pypy.module.micronumpy import types, boxes, base, support, constants as 
NPY
 from pypy.module.micronumpy.appbridge import get_appbridge_cache
@@ -73,7 +73,7 @@
 self.base = subdtype.base
 
 def __repr__(self):
-if self.fields is not None:
+if self.fields:
 return 'DType %r' % self.fields
 return 'DType %r' % self.itemtype
 
@@ -254,8 +254,38 @@
 def descr_ne(self, space, w_other):
 return space.wrap(not self.eq(space, w_other))
 
+def _compute_hash(self, space, x):
+from rpython.rlib.rarithmetic import intmask
+if not self.fields and self.subdtype is None:
+endian = self.byteorder
+if endian == NPY.NATIVE:
+endian = NPY.NATBYTE
+flags = 0
+y = 0x345678
+y = intmask((103 * y) ^ ord(self.kind[0]))
+y = intmask((103 * y) ^ ord(endian[0]))
+y = intmask((103 * y) ^ flags)
+y = intmask((103 * y) ^ self.elsize)
+if self.is_flexible():
+y = intmask((103 * y) ^ self.alignment)
+return intmask((103 * x) ^ y)
+if self.fields:
+for name, (offset, subdtype) in self.fields.iteritems():
+assert isinstance(subdtype, W_Dtype)
+y = intmask(103 * (0x345678 ^ compute_hash(name)))
+y = intmask(103 * (y ^ compute_hash(offset)))
+y = intmask(103 * (y ^ subdtype._compute_hash(space,
+ 0x345678)))
+x = intmask(x ^ y)
+if self.subdtype is not None:
+for s in self.shape:
+x = intmask((103 * x) ^ compute_hash(s))
+x = self.base._compute_hash(space, x)
+return x
+
 def descr_hash(self, space):
-return space.hash(self.descr_reduce(space))
+return space.wrap(self._compute_hash(space, 0x345678))
+
 
 def descr_str(self, space):
 if self.fields:
diff --git a/pypy/module/micronumpy/test/test_dtypes.py 
b/pypy/module/micronumpy/test/test_dtypes.py
--- a/pypy/module/micronumpy/test/test_dtypes.py
+++ b/pypy/module/micronumpy/test/test_dtypes.py
@@ -367,15 +367,30 @@
 d5 = numpy.dtype([('f0', 'i4'), ('f1', d2)])
 d6 = numpy.dtype([('f0', 'i4'), ('f1', d3)])
 import sys
-if '__pypy__' not in sys.builtin_module_names:
-assert hash(d1) == hash(d2)
-assert 

[pypy-commit] pypy py3k: merge default

2014-05-06 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r71355:f7d70d54b9d9
Date: 2014-05-06 16:58 -0700
http://bitbucket.org/pypy/pypy/changeset/f7d70d54b9d9/

Log:merge default

diff --git a/lib_pypy/_pypy_interact.py b/lib_pypy/_pypy_interact.py
--- a/lib_pypy/_pypy_interact.py
+++ b/lib_pypy/_pypy_interact.py
@@ -3,6 +3,8 @@
 import sys
 import os
 
+irc_header = And now for something completely different
+
 
 def interactive_console(mainmodule=None, quiet=False):
 # set sys.{ps1,ps2} just before invoking the interactive interpreter. This
@@ -15,8 +17,7 @@
 if not quiet:
 try:
 from _pypy_irc_topic import some_topic
-text = And now for something completely different: ``%s'' % (
-some_topic(),)
+text = %s: ``%s'' % ( irc_header, some_topic())
 while len(text) = 80:
 i = text[:80].rfind(' ')
 print(text[:i])
diff --git a/pypy/doc/cpython_differences.rst b/pypy/doc/cpython_differences.rst
--- a/pypy/doc/cpython_differences.rst
+++ b/pypy/doc/cpython_differences.rst
@@ -348,4 +348,9 @@
   type and vice versa. For builtin types, a dictionary will be returned that
   cannot be changed (but still looks and behaves like a normal dictionary).
 
+* PyPy prints a random line from past #pypy IRC topics at startup in
+  interactive mode. In a released version, this behaviour is supressed, but
+  setting the environment variable PYPY_IRC_TOPIC will bring it back. Note that
+  downstream package providers have been known to totally disable this feature.
+
 .. include:: _ref.txt
diff --git a/pypy/doc/how-to-release.rst b/pypy/doc/how-to-release.rst
--- a/pypy/doc/how-to-release.rst
+++ b/pypy/doc/how-to-release.rst
@@ -28,7 +28,10 @@
   pypy/doc/tool/makecontributor.py generates the list of contributors
 * rename pypy/doc/whatsnew_head.rst to whatsnew_VERSION.rst
   and create a fresh whatsnew_head.rst after the release
-* update README
+* merge PYPY_IRC_TOPIC environment variable handling from previous release
+  in pypy/doc/getting-started-dev.rst, pypy/doc/man/pypy.1.rst, and
+  pypy/interpreter/app_main.py so release versions will not print a random
+  IRC topic by default.
 * change the tracker to have a new release tag to file bugs against
 * go to pypy/tool/release and run:
   force-builds.py release branch
diff --git a/pypy/doc/release-2.3.0.rst b/pypy/doc/release-2.3.0.rst
--- a/pypy/doc/release-2.3.0.rst
+++ b/pypy/doc/release-2.3.0.rst
@@ -1,5 +1,5 @@
 ===
-PyPy 2.3 - Easier Than Ever
+PyPy 2.3 - Terrestrial Arthropod Trap
 ===
 
 We're pleased to announce PyPy 2.3, which targets version 2.7.6 of the Python
diff --git a/pypy/interpreter/test/test_app_main.py 
b/pypy/interpreter/test/test_app_main.py
--- a/pypy/interpreter/test/test_app_main.py
+++ b/pypy/interpreter/test/test_app_main.py
@@ -7,6 +7,11 @@
 from rpython.tool.udir import udir
 from contextlib import contextmanager
 from pypy.conftest import pypydir
+from pypy.module.sys.version import PYPY_VERSION
+from lib_pypy._pypy_interact import irc_header
+
+is_release = PYPY_VERSION[3] == final
+
 
 python3 = os.environ.get(PYTHON3, python3)
 
@@ -250,6 +255,10 @@
 child = self.spawn([])
 child.expect('Python ')   # banner
 child.expect(' ')  # prompt
+if is_release:
+assert irc_header not in child.before
+else:
+assert irc_header in child.before
 child.sendline('[6*7]')
 child.expect(re.escape('[42]'))
 child.sendline('def f(x):')
diff --git a/pypy/module/operator/test/test_operator.py 
b/pypy/module/operator/test/test_operator.py
--- a/pypy/module/operator/test/test_operator.py
+++ b/pypy/module/operator/test/test_operator.py
@@ -179,6 +179,8 @@
 assert operator.index(42) == 42
 assert operator.__index__(42) == 42
 raises(TypeError, operator.index, abc)
+exc = raises(TypeError, operator.index, abc)
+assert str(exc.value) == 'str' object cannot be interpreted as an 
index
 
 def test_indexOf(self):
 import operator
diff --git a/pypy/module/pypyjit/test_pypy_c/test_struct.py 
b/pypy/module/pypyjit/test_pypy_c/test_struct.py
--- a/pypy/module/pypyjit/test_pypy_c/test_struct.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_struct.py
@@ -1,6 +1,18 @@
+import sys
 from pypy.module.pypyjit.test_pypy_c.test_00_model import BaseTestPyPyC
 
 
+if sys.maxsize == 2 ** 63 - 1:
+extra = 
+i8 = int_ge(i4, -2147483648)
+guard_true(i8, descr=...)
+i9 = int_le(i4, 2147483647)
+guard_true(i9, descr=...)
+
+else:
+extra = 
+
+
 class TestStruct(BaseTestPyPyC):
 def test_struct_function(self):
 def main(n):
@@ -20,10 +32,7 @@
 assert loop.match_by_id(struct, 
 guard_not_invalidated(descr=...)
 # struct.pack
-i8 = int_ge(i4, -2147483648)
- 

[pypy-commit] pypy py3k: merge default

2014-05-05 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r71299:d8096ef0c138
Date: 2014-05-05 18:38 -0700
http://bitbucket.org/pypy/pypy/changeset/d8096ef0c138/

Log:merge default

diff --git a/pypy/doc/release-2.3.0.rst b/pypy/doc/release-2.3.0.rst
--- a/pypy/doc/release-2.3.0.rst
+++ b/pypy/doc/release-2.3.0.rst
@@ -84,7 +84,7 @@
 
 * Fix issues with reimporting builtin modules
 
-* Fix a RPython bug with loop-unrolling that appeared in the `HippyVM`_ PHP 
port
+* Fix an RPython bug with loop-unrolling that appeared in the `HippyVM`_ PHP 
port
 
 * Support for corner cases on objects with __int__ and __float__ methods
 
@@ -125,7 +125,7 @@
   and scalars were corrected. We are slowly approaching our goal of passing
   the NumPy test suite. We still do not support object or unicode ndarrays.
 
-* speed of iteration in dot() is now within 1.5x of the NumPy c 
+* Speed of iteration in dot() is now within 1.5x of the NumPy c 
   implementation (without BLAS acceleration). Since the same array
   iterator is used throughout the ``_numpy`` module, speed increases should
   be apparent in all NumPy functionality.
@@ -135,7 +135,7 @@
 * A cffi-based ``numpy.random`` module is available as a branch;
   it will be merged soon after this release.
 
-* enhancements to the PyPy JIT were made to support virtualizing the 
raw_store/raw_load 
+* Enhancements to the PyPy JIT were made to support virtualizing the 
raw_store/raw_load 
   memory operations used in NumPy arrays. Further work remains here in 
virtualizing the 
   alloc_raw_storage when possible. This will allow scalars to have storages 
but still be 
   virtualized when possible in loops.
diff --git a/pypy/module/_io/interp_bytesio.py 
b/pypy/module/_io/interp_bytesio.py
--- a/pypy/module/_io/interp_bytesio.py
+++ b/pypy/module/_io/interp_bytesio.py
@@ -199,8 +199,7 @@
 space.call_method(self.getdict(space), update, w_dict)
 
 W_BytesIO.typedef = TypeDef(
-'BytesIO', W_BufferedIOBase.typedef,
-__module__ = _io,
+'_io.BytesIO', W_BufferedIOBase.typedef,
 __new__  = interp2app(W_BytesIO.descr_new.im_func),
 __init__  = interp2app(W_BytesIO.descr_init),
 
diff --git a/pypy/module/_io/interp_fileio.py b/pypy/module/_io/interp_fileio.py
--- a/pypy/module/_io/interp_fileio.py
+++ b/pypy/module/_io/interp_fileio.py
@@ -436,8 +436,7 @@
 return w_size
 
 W_FileIO.typedef = TypeDef(
-'FileIO', W_RawIOBase.typedef,
-__module__ = _io,
+'_io.FileIO', W_RawIOBase.typedef,
 __new__  = interp2app(W_FileIO.descr_new.im_func),
 __init__  = interp2app(W_FileIO.descr_init),
 __repr__ = interp2app(W_FileIO.repr_w),
diff --git a/pypy/module/_io/interp_io.py b/pypy/module/_io/interp_io.py
--- a/pypy/module/_io/interp_io.py
+++ b/pypy/module/_io/interp_io.py
@@ -27,10 +27,9 @@
 self.written = written
 
 W_BlockingIOError.typedef = TypeDef(
-'BlockingIOError', W_IOError.typedef,
-__module__ = 'io',
-__doc__ = (Exception raised when I/O would block 
-   on a non-blocking I/O stream),
+'_io.BlockingIOError', W_IOError.typedef,
+__doc__ = (Exception raised when I/O would block on a non-blocking 
+   I/O stream),
 __new__  = generic_new_descr(W_BlockingIOError),
 __init__ = interp2app(W_BlockingIOError.descr_init),
 characters_written = interp_attrproperty('written', W_BlockingIOError),
diff --git a/pypy/module/_io/interp_iobase.py b/pypy/module/_io/interp_iobase.py
--- a/pypy/module/_io/interp_iobase.py
+++ b/pypy/module/_io/interp_iobase.py
@@ -299,8 +299,7 @@
 break
 
 W_IOBase.typedef = TypeDef(
-'_IOBase',
-__module__ = _io,
+'_io._IOBase',
 __new__ = generic_new_descr(W_IOBase),
 __enter__ = interp2app(W_IOBase.enter_w),
 __exit__ = interp2app(W_IOBase.exit_w),
@@ -372,8 +371,7 @@
 return space.wrapbytes(builder.build())
 
 W_RawIOBase.typedef = TypeDef(
-'_RawIOBase', W_IOBase.typedef,
-__module__ = _io,
+'_io._RawIOBase', W_IOBase.typedef,
 __new__ = generic_new_descr(W_RawIOBase),
 
 read = interp2app(W_RawIOBase.read_w),
diff --git a/pypy/module/_io/interp_textio.py b/pypy/module/_io/interp_textio.py
--- a/pypy/module/_io/interp_textio.py
+++ b/pypy/module/_io/interp_textio.py
@@ -178,8 +178,7 @@
 space.call_method(self.w_decoder, setstate, w_state)
 
 W_IncrementalNewlineDecoder.typedef = TypeDef(
-'IncrementalNewlineDecoder',
-__module__ = _io,
+'_io.IncrementalNewlineDecoder',
 __new__ = generic_new_descr(W_IncrementalNewlineDecoder),
 __init__  = interp2app(W_IncrementalNewlineDecoder.descr_init),
 
@@ -256,8 +255,7 @@
 
 
 W_TextIOBase.typedef = TypeDef(
-'_TextIOBase', W_IOBase.typedef,
-__module__ = _io,
+'_io._TextIOBase', W_IOBase.typedef,
 __new__ = generic_new_descr(W_TextIOBase),
 
 read = interp2app(W_TextIOBase.read_w),
diff --git a/pypy/module/_io/test/test_io.py b/pypy/module/_io/test/test_io.py
--- 

[pypy-commit] pypy py3k: merge default

2014-05-05 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r71300:9c2e85c01eb9
Date: 2014-05-05 18:43 -0700
http://bitbucket.org/pypy/pypy/changeset/9c2e85c01eb9/

Log:merge default

diff --git a/pypy/module/_cffi_backend/cdataobj.py 
b/pypy/module/_cffi_backend/cdataobj.py
--- a/pypy/module/_cffi_backend/cdataobj.py
+++ b/pypy/module/_cffi_backend/cdataobj.py
@@ -442,7 +442,6 @@
 
 W_CData.typedef = TypeDef(
 '_cffi_backend.CData',
-__module__ = '_cffi_backend',
 __name__ = 'cdata',
 __repr__ = interp2app(W_CData.repr),
 __bool__ = interp2app(W_CData.bool),
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: merge default

2014-05-05 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: py3k
Changeset: r71312:9401f74194b9
Date: 2014-05-05 22:43 -0400
http://bitbucket.org/pypy/pypy/changeset/9401f74194b9/

Log:merge default

diff --git a/pypy/module/_cffi_backend/cdataobj.py 
b/pypy/module/_cffi_backend/cdataobj.py
--- a/pypy/module/_cffi_backend/cdataobj.py
+++ b/pypy/module/_cffi_backend/cdataobj.py
@@ -442,6 +442,7 @@
 
 W_CData.typedef = TypeDef(
 '_cffi_backend.CData',
+__module__ = '_cffi_backend',
 __name__ = 'cdata',
 __repr__ = interp2app(W_CData.repr),
 __bool__ = interp2app(W_CData.bool),
diff --git a/pypy/module/_io/interp_io.py b/pypy/module/_io/interp_io.py
--- a/pypy/module/_io/interp_io.py
+++ b/pypy/module/_io/interp_io.py
@@ -27,7 +27,7 @@
 self.written = written
 
 W_BlockingIOError.typedef = TypeDef(
-'_io.BlockingIOError', W_IOError.typedef,
+'BlockingIOError', W_IOError.typedef,
 __doc__ = (Exception raised when I/O would block on a non-blocking 
I/O stream),
 __new__  = generic_new_descr(W_BlockingIOError),
diff --git a/pypy/module/_io/test/test_io.py b/pypy/module/_io/test/test_io.py
--- a/pypy/module/_io/test/test_io.py
+++ b/pypy/module/_io/test/test_io.py
@@ -383,4 +383,10 @@
 import _io
 typemods = dict((t, t.__module__) for t in vars(_io).values()
 if isinstance(t, type))
-assert all(mod in ('io', '_io') for mod in typemods.values()), typemods
+for t, mod in typemods.items():
+if t is _io.BlockingIOError:
+assert mod == '__builtin__'
+elif t is _io.UnsupportedOperation:
+assert mod == 'io'
+else:
+assert mod == '_io'
diff --git a/pypy/module/_io/test/test_stringio.py 
b/pypy/module/_io/test/test_stringio.py
--- a/pypy/module/_io/test/test_stringio.py
+++ b/pypy/module/_io/test/test_stringio.py
@@ -142,11 +142,6 @@
 exc_info = raises(TypeError, sio.write, 3)
 assert int in exc_info.value.args[0]
 
-def test_module(self):
-import io
-
-assert io.StringIO.__module__ == _io
-
 def test_newline_none(self):
 import io
 
diff --git a/pypy/module/pypyjit/test_pypy_c/test_buffers.py 
b/pypy/module/pypyjit/test_pypy_c/test_buffers.py
--- a/pypy/module/pypyjit/test_pypy_c/test_buffers.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_buffers.py
@@ -56,7 +56,7 @@
 guard_false(i99, descr=...)
 i100 = int_lshift(i98, 24)
 i101 = int_or(i97, i100)
-i102 = getfield_raw(50657056, descr=FieldS 
pypysig_long_struct.c_value 0)
+i102 = getfield_raw(\d+, descr=FieldS pypysig_long_struct.c_value 
0)
 i103 = int_lt(i102, 0)
 guard_false(i103, descr=...)
 )
diff --git a/pypy/module/pypyjit/test_pypy_c/test_misc.py 
b/pypy/module/pypyjit/test_pypy_c/test_misc.py
--- a/pypy/module/pypyjit/test_pypy_c/test_misc.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_misc.py
@@ -348,51 +348,6 @@
 loop, = log.loops_by_id(globalread, is_entry_bridge=True)
 assert len(loop.ops_by_id(globalread)) == 0
 
-def test_struct_module(self):
-def main():
-import struct
-i = 1
-while i  1000:
-x = struct.unpack(i, struct.pack(i, i))[0] # ID: struct
-i += x / i
-return i
-
-log = self.run(main)
-assert log.result == main()
-
-loop, = log.loops_by_id(struct)
-if sys.maxint == 2 ** 63 - 1:
-extra = 
-i8 = int_ge(i4, -2147483648)
-guard_true(i8, descr=...)
-
-else:
-extra = 
-# This could, of course stand some improvement, to remove all these
-# arithmatic ops, but we've removed all the core overhead.
-assert loop.match_by_id(struct, 
-guard_not_invalidated(descr=...)
-# struct.pack
-%(32_bit_only)s
-i11 = int_and(i4, 255)
-i13 = int_rshift(i4, 8)
-i14 = int_and(i13, 255)
-i16 = int_rshift(i13, 8)
-i17 = int_and(i16, 255)
-i19 = int_rshift(i16, 8)
-i20 = int_and(i19, 255)
-
-# struct.unpack
-i22 = int_lshift(i14, 8)
-i23 = int_or(i11, i22)
-i25 = int_lshift(i17, 16)
-i26 = int_or(i23, i25)
-i28 = int_ge(i20, 128)
-guard_false(i28, descr=...)
-i30 = int_lshift(i20, 24)
-i31 = int_or(i26, i30)
- % {32_bit_only: extra})
-
 def test_eval(self):
 def main():
 i = 1
diff --git a/pypy/module/pypyjit/test_pypy_c/test_struct.py 
b/pypy/module/pypyjit/test_pypy_c/test_struct.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/pypyjit/test_pypy_c/test_struct.py
@@ -0,0 +1,84 @@
+from pypy.module.pypyjit.test_pypy_c.test_00_model import BaseTestPyPyC
+
+

[pypy-commit] pypy py3k: merge default

2014-05-03 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r71241:2f47b24c4692
Date: 2014-05-02 11:37 -0700
http://bitbucket.org/pypy/pypy/changeset/2f47b24c4692/

Log:merge default

diff --git a/pypy/doc/release-2.3.0.rst b/pypy/doc/release-2.3.0.rst
--- a/pypy/doc/release-2.3.0.rst
+++ b/pypy/doc/release-2.3.0.rst
@@ -18,17 +18,18 @@
 http://pypy.org/download.html
 
 We would like to thank our donors for the continued support of the PyPy
-project. We showed quite a bit of progress on all three projects (see below)
-and we're slowly running out of funds.
-Please consider donating more so we can finish those projects!  The three
-projects are:
+project, and for those who donate to our three sub-projects.
+We showed quite a bit of progress 
+but we're slowly running out of funds.
+Please consider donating more, or even better convince your employer to donate,
+so we can finish those projects!  The three sub-projects are:
 
 * `Py3k`_ (supporting Python 3.x): the release PyPy3 2.2 is imminent.
 
 * `STM`_ (software transactional memory): a preview will be released very soon,
   once we fix a few bugs
 
-* `NumPy`_ the work done is included in the PyPy 2.2 release. More details 
below.
+* `NumPy`_ which is included in the PyPy 2.3 release. More details below.
 
 .. _`Py3k`: http://pypy.org/py3donate.html
 .. _`STM`: http://pypy.org/tmdonate2.html
@@ -44,8 +45,8 @@
 =
 
 PyPy is a very compliant Python interpreter, almost a drop-in replacement for
-CPython 2.7. It's fast (`pypy 2.2 and cpython 2.7.2`_ performance comparison;
-note that the latest cpython is not faster than cpython 2.7.2)
+CPython 2.7. It's fast (`pypy 2.3 and cpython 2.7.x`_ performance comparison;
+note that cpython's speed has not changed since 2.7.2)
 due to its integrated tracing JIT compiler.
 
 This release supports x86 machines running Linux 32/64, Mac OS X 64, Windows,
@@ -56,13 +57,13 @@
 bit python is still stalling, we would welcome a volunteer
 to `handle that`_.
 
-.. _`pypy 2.2 and cpython 2.7.2`: http://speed.pypy.org
+.. _`pypy 2.3 and cpython 2.7.x`: http://speed.pypy.org
 .. _`handle that`: 
http://doc.pypy.org/en/latest/windows.html#what-is-missing-for-a-full-64-bit-translation
 
 Highlights
 ==
 
-Bugfixes
+Bugfixes 
 
 
 Many issues were cleaned up after being reported by users to 
https://bugs.pypy.org (ignore the bad SSL certificate) or on IRC at #pypy. Note 
that we consider
@@ -71,7 +72,7 @@
 * The ARM port no longer crashes on unaligned memory access to floats and 
doubles,
   and singlefloats are supported in the JIT.
 
-* Generators are faster since they now skip unecessary cleanup
+* Generators are faster since they now skip unnecessary cleanup
 
 * A first time contributor simplified JIT traces by adding integer bound
   propagation in indexing and logical operations.
@@ -84,6 +85,8 @@
 
 * Fix a rpython bug with loop-unrolling that appeared in the `HippyVM`_ PHP 
port
 
+* Support for corner cases on objects with __int__ and __float__ methods
+
 .. _`HippyVM`: http://www.hippyvm.com
 
 New Platforms and Features
@@ -97,8 +100,6 @@
 
 * Support for precompiled headers in the build process for MSVC
 
-* Support for objects with __int__ and __float__ methods
-
 * Tweak support of errno in cpyext (the PyPy implemenation of the capi)
 
 
@@ -127,8 +128,12 @@
 * A cffi-based ``numpy.random`` module is available as a branch in the numpy
   repository, it will be merged soon after this release.
 
-* enhancements to the PyPy JIT were made to support virtualizing the 
raw_store/raw_load memory operations used in numpy arrays. Further work remains 
here in virtualizing the alloc_raw_storage when possible. This will allow 
scalars to have storages but still be virtualized when possible in loops.
+* enhancements to the PyPy JIT were made to support virtualizing the 
raw_store/raw_load 
+  memory operations used in numpy arrays. Further work remains here in 
virtualizing the 
+  alloc_raw_storage when possible. This will allow scalars to have storages 
but still be 
+  virtualized when possible in loops.
 
 Cheers
+
 The PyPy Team
 
diff --git a/pypy/doc/whatsnew-2.3.0.rst b/pypy/doc/whatsnew-2.3.0.rst
--- a/pypy/doc/whatsnew-2.3.0.rst
+++ b/pypy/doc/whatsnew-2.3.0.rst
@@ -161,3 +161,7 @@
 
 .. branch: refactor-buffer-api
 Properly implement old/new buffer API for objects and start work on replacing 
bufferstr usage
+
+.. branch: issue1430
+Add a lock for unsafe calls to gethostbyname and gethostbyaddr
+
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
@@ -3,6 +3,5 @@
 ===
 
 .. this is a revision shortly after release-2.3.x
-.. startrev: 0524dae88c75
+.. startrev: 0f75ad4d14ce
 
-.. branch: reflex-support
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -705,23 

[pypy-commit] pypy py3k: merge default (ea86924e88fb)

2014-04-24 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r70952:e0ce5503a026
Date: 2014-04-24 16:58 -0700
http://bitbucket.org/pypy/pypy/changeset/e0ce5503a026/

Log:merge default (ea86924e88fb)

diff --git a/lib-python/2.7/test/test_itertools.py 
b/lib-python/2.7/test/test_itertools.py
--- a/lib-python/2.7/test/test_itertools.py
+++ b/lib-python/2.7/test/test_itertools.py
@@ -139,7 +139,6 @@
 
 @test_support.impl_detail(tuple reuse is specific to CPython)
 def test_combinations_tuple_reuse(self):
-# Test implementation detail:  tuple re-use
 self.assertEqual(len(set(map(id, combinations('abcde', 3, 1)
 self.assertNotEqual(len(set(map(id, list(combinations('abcde', 3), 
1)
 
@@ -211,7 +210,6 @@
 
 @test_support.impl_detail(tuple reuse is specific to CPython)
 def test_combinations_with_replacement_tuple_reuse(self):
-# Test implementation detail:  tuple re-use
 cwr = combinations_with_replacement
 self.assertEqual(len(set(map(id, cwr('abcde', 3, 1)
 self.assertNotEqual(len(set(map(id, list(cwr('abcde', 3), 1)
@@ -278,7 +276,6 @@
 
 @test_support.impl_detail(tuple reuse is specific to CPython)
 def test_permutations_tuple_reuse(self):
-# Test implementation detail:  tuple re-use
 self.assertEqual(len(set(map(id, permutations('abcde', 3, 1)
 self.assertNotEqual(len(set(map(id, list(permutations('abcde', 3), 
1)
 
diff --git a/pypy/doc/cppyy.rst b/pypy/doc/cppyy.rst
--- a/pypy/doc/cppyy.rst
+++ b/pypy/doc/cppyy.rst
@@ -560,6 +560,12 @@
   Fixing these bootstrap problems is on the TODO list.
   The global namespace is ``cppyy.gbl``.
 
+* **NULL**: Is represented as ``cppyy.gbl.nullptr``.
+  In C++11, the keyword ``nullptr`` is used to represent ``NULL``.
+  For clarity of intent, it is recommended to use this instead of ``None``
+  (or the integer ``0``, which can serve in some cases), as ``None`` is better
+  understood as ``void`` in C++.
+
 * **operator conversions**: If defined in the C++ class and a python
   equivalent exists (i.e. all builtin integer and floating point types, as well
   as ``bool``), it will map onto that python conversion.
diff --git a/pypy/doc/extending.rst b/pypy/doc/extending.rst
--- a/pypy/doc/extending.rst
+++ b/pypy/doc/extending.rst
@@ -66,58 +66,26 @@
 Reflex
 ==
 
-This method is still experimental.  It adds the `cppyy`_ module.
-The method works by using the `Reflex package`_ to provide reflection
-information of the C++ code, which is then used to automatically generate
-bindings at runtime.
-From a python standpoint, there is no difference between generating bindings
-at runtime, or having them statically generated and available in scripts
-or compiled into extension modules: python classes and functions are always
-runtime structures, created when a script or module loads.
+The builtin `cppyy`_ module uses reflection information, provided by
+`Reflex`_ (which needs to be `installed separately`_), of C/C++ code to
+automatically generate bindings at runtime.
+In Python, classes and functions are always runtime structures, so when they
+are generated matters not for performance.
 However, if the backend itself is capable of dynamic behavior, it is a much
-better functional match to python, allowing tighter integration and more
-natural language mappings.
-Full details are `available here`_.
+better functional match, allowing tighter integration and more natural
+language mappings.
+
+The `cppyy`_ module is written in RPython, thus PyPy's JIT is able to remove
+most cross-language call overhead.
+
+`Full details`_ are `available here`_.
 
 .. _`cppyy`: cppyy.html
-.. _`reflex-support`: cppyy.html
-.. _`Reflex package`: http://root.cern.ch/drupal/content/reflex
+.. _`installed separately`: http://cern.ch/wlav/reflex-2013-08-14.tar.bz2
+.. _`Reflex`: http://root.cern.ch/drupal/content/reflex
+.. _`Full details`: cppyy.html
 .. _`available here`: cppyy.html
 
-Pros
-
-
-The cppyy module is written in RPython, which makes it possible to keep the
-code execution visible to the JIT all the way to the actual point of call into
-C++, thus allowing for a very fast interface.
-Reflex is currently in use in large software environments in High Energy
-Physics (HEP), across many different projects and packages, and its use can be
-virtually completely automated in a production environment.
-One of its uses in HEP is in providing language bindings for CPython.
-Thus, it is possible to use Reflex to have bound code work on both CPython and
-on PyPy.
-In the medium-term, Reflex will be replaced by `cling`_, which is based on
-`llvm`_.
-This will affect the backend only; the python-side interface is expected to
-remain the same, except that cling adds a lot of dynamic behavior to C++,
-enabling further language integration.
-
-.. _`cling`: http://root.cern.ch/drupal/content/cling
-.. _`llvm`: http://llvm.org/
-
-Cons
-
-
-C++ is a large 

[pypy-commit] pypy py3k: merge default

2014-04-17 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r70734:f10a4d4b1837
Date: 2014-04-17 16:53 -0700
http://bitbucket.org/pypy/pypy/changeset/f10a4d4b1837/

Log:merge default

diff --git a/pypy/objspace/std/test/test_celldict.py 
b/pypy/objspace/std/test/test_celldict.py
--- a/pypy/objspace/std/test/test_celldict.py
+++ b/pypy/objspace/std/test/test_celldict.py
@@ -1,42 +1,47 @@
 import py
+
+from pypy.objspace.std.celldict import ModuleDictStrategy
 from pypy.objspace.std.dictmultiobject import W_DictMultiObject
-from pypy.objspace.std.celldict import ModuleCell, ModuleDictStrategy
-from pypy.objspace.std.test.test_dictmultiobject import FakeSpace, \
-BaseTestRDictImplementation, BaseTestDevolvedDictImplementation
-from pypy.interpreter import gateway
+from pypy.objspace.std.test.test_dictmultiobject import (
+BaseTestRDictImplementation, BaseTestDevolvedDictImplementation, FakeSpace,
+FakeString)
 
 space = FakeSpace()
 
 class TestCellDict(object):
+FakeString = FakeString
+
 def test_basic_property_cells(self):
 strategy = ModuleDictStrategy(space)
 storage = strategy.get_empty_storage()
 d = W_DictMultiObject(space, strategy, storage)
 
 v1 = strategy.version
-d.setitem(a, 1)
+key = a
+w_key = self.FakeString(key)
+d.setitem(w_key, 1)
 v2 = strategy.version
 assert v1 is not v2
-assert d.getitem(a) == 1
-assert d.strategy.getdictvalue_no_unwrapping(d, a) == 1
+assert d.getitem(w_key) == 1
+assert d.strategy.getdictvalue_no_unwrapping(d, key) == 1
 
-d.setitem(a, 2)
+d.setitem(w_key, 2)
 v3 = strategy.version
 assert v2 is not v3
-assert d.getitem(a) == 2
-assert d.strategy.getdictvalue_no_unwrapping(d, a).w_value == 2
+assert d.getitem(w_key) == 2
+assert d.strategy.getdictvalue_no_unwrapping(d, key).w_value == 2
 
-d.setitem(a, 3)
+d.setitem(w_key, 3)
 v4 = strategy.version
 assert v3 is v4
-assert d.getitem(a) == 3
-assert d.strategy.getdictvalue_no_unwrapping(d, a).w_value == 3
+assert d.getitem(w_key) == 3
+assert d.strategy.getdictvalue_no_unwrapping(d, key).w_value == 3
 
-d.delitem(a)
+d.delitem(w_key)
 v5 = strategy.version
 assert v5 is not v4
-assert d.getitem(a) is None
-assert d.strategy.getdictvalue_no_unwrapping(d, a) is None
+assert d.getitem(w_key) is None
+assert d.strategy.getdictvalue_no_unwrapping(d, key) is None
 
 def test_same_key_set_twice(self):
 strategy = ModuleDictStrategy(space)
diff --git a/pypy/objspace/std/test/test_dictmultiobject.py 
b/pypy/objspace/std/test/test_dictmultiobject.py
--- a/pypy/objspace/std/test/test_dictmultiobject.py
+++ b/pypy/objspace/std/test/test_dictmultiobject.py
@@ -1274,12 +1274,13 @@
 return other == s
 
 d = self.get_impl()
-d.setitem(s, 12)
-assert d.getitem(s) == 12
-assert d.getitem(F()) == d.getitem(s)
+w_key = FakeString(s)
+d.setitem(w_key, 12)
+assert d.getitem(w_key) == 12
+assert d.getitem(F()) == d.getitem(w_key)
 
 d = self.get_impl()
-x = d.setdefault(s, 12)
+x = d.setdefault(w_key, 12)
 assert x == 12
 x = d.setdefault(F(), 12)
 assert x == 12
@@ -1289,10 +1290,10 @@
 assert x == 12
 
 d = self.get_impl()
-d.setitem(s, 12)
+d.setitem(w_key, 12)
 d.delitem(F())
 
-assert s not in d.w_keys()
+assert w_key not in d.w_keys()
 assert F() not in d.w_keys()
 
 class TestBytesDictImplementation(BaseTestRDictImplementation):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: merge default

2014-04-11 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r70597:fe69dee13c0f
Date: 2014-04-11 17:10 -0700
http://bitbucket.org/pypy/pypy/changeset/fe69dee13c0f/

Log:merge default

diff --git a/pypy/doc/_ref.txt b/pypy/doc/_ref.txt
--- a/pypy/doc/_ref.txt
+++ b/pypy/doc/_ref.txt
@@ -1,3 +1,6 @@
+.. This file is generated automatically by makeref.py script,
+   which in turn is run manually.
+
 .. _`ctypes_configure/doc/sample.py`: 
https://bitbucket.org/pypy/pypy/src/default/ctypes_configure/doc/sample.py
 .. _`dotviewer/`: https://bitbucket.org/pypy/pypy/src/default/dotviewer/
 .. _`lib-python/`: https://bitbucket.org/pypy/pypy/src/default/lib-python/
diff --git a/pypy/doc/cpython_differences.rst b/pypy/doc/cpython_differences.rst
--- a/pypy/doc/cpython_differences.rst
+++ b/pypy/doc/cpython_differences.rst
@@ -106,23 +106,43 @@
 Differences related to garbage collection strategies
 
 
-Most of the garbage collectors used or implemented by PyPy are not based on
+The garbage collectors used or implemented by PyPy are not based on
 reference counting, so the objects are not freed instantly when they are no
 longer reachable.  The most obvious effect of this is that files are not
 promptly closed when they go out of scope.  For files that are opened for
 writing, data can be left sitting in their output buffers for a while, making
-the on-disk file appear empty or truncated.
+the on-disk file appear empty or truncated.  Moreover, you might reach your
+OS's limit on the number of concurrently opened files.
 
-Fixing this is essentially not possible without forcing a
+Fixing this is essentially impossible without forcing a
 reference-counting approach to garbage collection.  The effect that you
 get in CPython has clearly been described as a side-effect of the
 implementation and not a language design decision: programs relying on
 this are basically bogus.  It would anyway be insane to try to enforce
 CPython's behavior in a language spec, given that it has no chance to be
 adopted by Jython or IronPython (or any other port of Python to Java or
-.NET, like PyPy itself).
+.NET).
 
-This affects the precise time at which ``__del__`` methods are called, which
+Even the naive idea of forcing a full GC when we're getting dangerously
+close to the OS's limit can be very bad in some cases.  If your program
+leaks open files heavily, then it would work, but force a complete GC
+cycle every n'th leaked file.  The value of n is a constant, but the
+program can take an arbitrary amount of memory, which makes a complete
+GC cycle arbitrarily long.  The end result is that PyPy would spend an
+arbitrarily large fraction of its run time in the GC --- slowing down
+the actual execution, not by 10% nor 100% nor 1000% but by essentially
+any factor.
+
+To the best of our knowledge this problem has no better solution than
+fixing the programs.  If it occurs in 3rd-party code, this means going
+to the authors and explaining the problem to them: they need to close
+their open files in order to run on any non-CPython-based implementation
+of Python.
+
+-
+
+Here are some more technical details.  This issue affects the precise
+time at which ``__del__`` methods are called, which
 is not reliable in PyPy (nor Jython nor IronPython).  It also means that
 weak references may stay alive for a bit longer than expected.  This
 makes weak proxies (as returned by ``weakref.proxy()``) somewhat less
diff --git a/pypy/doc/jit/_ref.txt b/pypy/doc/jit/_ref.txt
--- a/pypy/doc/jit/_ref.txt
+++ b/pypy/doc/jit/_ref.txt
@@ -0,0 +1,4 @@
+.. This file is generated automatically by makeref.py script,
+   which in turn is run manually.
+
+
diff --git a/pypy/doc/jit/pyjitpl5.rst b/pypy/doc/jit/pyjitpl5.rst
--- a/pypy/doc/jit/pyjitpl5.rst
+++ b/pypy/doc/jit/pyjitpl5.rst
@@ -177,6 +177,12 @@
 
 .. __: 
https://bitbucket.org/pypy/extradoc/src/tip/talk/icooolps2009/bolz-tracing-jit-final.pdf
 
-as well as the `blog posts with the JIT tag.`__
+Chapters 5 and 6 of `Antonio Cuni's PhD thesis`__ contain an overview of how
+Tracing JITs work in general and more informations about the concrete case of
+PyPy's JIT.
+
+.. __: http://antocuni.eu/download/antocuni-phd-thesis.pdf
+
+The `blog posts with the JIT tag`__ might also contain additional information.
 
 .. __: http://morepypy.blogspot.com/search/label/jit
diff --git a/pypy/doc/stm.rst b/pypy/doc/stm.rst
--- a/pypy/doc/stm.rst
+++ b/pypy/doc/stm.rst
@@ -26,8 +26,8 @@
 
 
 ``pypy-stm`` is a variant of the regular PyPy interpreter.  With caveats
-listed below, it should be in theory within 25%-50% of the speed of a
-regular PyPy, comparing the JITting version in both cases.  It is called
+listed below, it should be in theory within 25%-50% slower than a
+regular PyPy, comparing the JIT version in both cases.  It is called
 STM for Software Transactional Memory, which is the internal technique
 used 

[pypy-commit] pypy py3k: merge default

2014-04-10 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r70541:ec295dbad48a
Date: 2014-04-10 11:35 -0700
http://bitbucket.org/pypy/pypy/changeset/ec295dbad48a/

Log:merge default

diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -215,7 +215,7 @@
make instances really small but slow without the JIT,
default=False,
requires=[(objspace.std.getattributeshortcut, True),
- (objspace.std.withmethodcache, True),
+ (objspace.std.withtypeversion, True),
]),
 
 BoolOption(withliststrategies,
diff --git a/pypy/doc/cpython_differences.rst b/pypy/doc/cpython_differences.rst
--- a/pypy/doc/cpython_differences.rst
+++ b/pypy/doc/cpython_differences.rst
@@ -315,6 +315,15 @@
   implementation detail that shows up because of internal C-level slots
   that PyPy does not have.
 
+* on CPython, ``[].__add__`` is a ``method-wrapper``, and
+  ``list.__add__`` is a ``slot wrapper``.  On PyPy these are normal
+  bound or unbound method objects.  This can occasionally confuse some
+  tools that inspect built-in types.  For example, the standard
+  library ``inspect`` module has a function ``ismethod()`` that returns
+  True on unbound method objects but False on method-wrappers or slot
+  wrappers.  On PyPy we can't tell the difference, so
+  ``ismethod([].__add__) == ismethod(list.__add__) == True``.
+
 * the ``__dict__`` attribute of new-style classes returns a normal dict, as
   opposed to a dict proxy like in CPython. Mutating the dict will change the
   type and vice versa. For builtin types, a dictionary will be returned that
diff --git a/pypy/objspace/std/dictmultiobject.py 
b/pypy/objspace/std/dictmultiobject.py
--- a/pypy/objspace/std/dictmultiobject.py
+++ b/pypy/objspace/std/dictmultiobject.py
@@ -586,6 +586,10 @@
 return self.len - self.pos
 return 0
 
+def _cleanup_(self):
+raise Exception(seeing a prebuilt %r object % (
+self.__class__,))
+
 class BaseKeyIterator(BaseIteratorImplementation):
 next_key = _new_next('key')
 
@@ -1099,6 +1103,10 @@
 w_ret = space.newtuple([new_inst, space.newtuple([w_res])])
 return w_ret
 
+def _cleanup_(self):
+raise Exception(seeing a prebuilt %r object % (
+self.__class__,))
+
 
 class W_DictMultiIterKeysObject(W_BaseDictMultiIterObject):
 def descr_next(self, space):
diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -871,8 +871,7 @@
 name = space.str_w(w_name)
 # We need to care for obscure cases in which the w_descr is
 # a TypeCell, which may change without changing the version_tag
-assert space.config.objspace.std.withmethodcache
-_, w_descr = w_type._pure_lookup_where_with_method_cache(
+_, w_descr = w_type._pure_lookup_where_possibly_with_method_cache(
 name, version_tag)
 #
 selector = (, INVALID)
@@ -930,9 +929,8 @@
 # in the class, this time taking care of the result: it can be either a
 # quasi-constant class attribute, or actually a TypeCell --- which we
 # must not cache.  (It should not be None here, but you never know...)
-assert space.config.objspace.std.withmethodcache
-_, w_method = w_type._pure_lookup_where_with_method_cache(name,
-  version_tag)
+_, w_method = w_type._pure_lookup_where_possibly_with_method_cache(
+name, version_tag)
 if w_method is None or isinstance(w_method, TypeCell):
 return
 _fill_cache(pycode, nameindex, map, version_tag, -1, w_method)
diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -369,6 +369,12 @@
 w_class, w_value = w_self._pure_lookup_where_with_method_cache(name, 
version_tag)
 return w_class, unwrap_cell(space, w_value)
 
+def _pure_lookup_where_possibly_with_method_cache(w_self, name, 
version_tag):
+if w_self.space.config.objspace.std.withmethodcache:
+return w_self._pure_lookup_where_with_method_cache(name, 
version_tag)
+else:
+return w_self._lookup_where_all_typeobjects(name)
+
 @elidable
 def _pure_lookup_where_with_method_cache(w_self, name, version_tag):
 space = w_self.space
diff --git a/rpython/jit/backend/x86/support.py 
b/rpython/jit/backend/x86/support.py
--- a/rpython/jit/backend/x86/support.py
+++ b/rpython/jit/backend/x86/support.py
@@ -7,11 +7,12 @@
 extra = ['-DPYPY_X86_CHECK_SSE2']
 if sys.platform != 'win32':
 extra += ['-msse2', '-mfpmath=sse']
+else:
+extra += 

[pypy-commit] pypy py3k: merge default

2014-04-09 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r70502:b7063430977e
Date: 2014-04-09 11:32 -0700
http://bitbucket.org/pypy/pypy/changeset/b7063430977e/

Log:merge default

diff --git a/pypy/doc/faq.rst b/pypy/doc/faq.rst
--- a/pypy/doc/faq.rst
+++ b/pypy/doc/faq.rst
@@ -459,6 +459,19 @@
 
 .. _`getting-started`: getting-started-python.html
 
+--
+Compiling PyPy swaps or runs out of memory
+--
+
+This is documented (here__ and here__).  It needs 4 GB of RAM to run
+rpython targetpypystandalone on top of PyPy, a bit more when running
+on CPython.  If you have less than 4 GB it will just swap forever (or
+fail if you don't have enough swap).  On 32-bit, divide the numbers by
+two.
+
+.. __: http://pypy.org/download.html#building-from-source
+.. __: 
https://pypy.readthedocs.org/en/latest/getting-started-python.html#translating-the-pypy-python-interpreter
+
 .. _`how do I compile my own interpreters`:
 
 -
diff --git a/pypy/doc/stm.rst b/pypy/doc/stm.rst
--- a/pypy/doc/stm.rst
+++ b/pypy/doc/stm.rst
@@ -15,11 +15,11 @@
 user, describes work in progress, and finally gives references to more
 implementation details.
 
-This work was done by Remi Meier and Armin Rigo.  Thanks to all donors
-for crowd-funding the work so far!  Please have a look at the 2nd call
-for donation (*not ready yet*)
+This work was done mostly by Remi Meier and Armin Rigo.  Thanks to all
+donors for crowd-funding the work so far!  Please have a look at the
+`2nd call for donation`_.
 
-.. .. _`2nd call for donation`: http://pypy.org/tmdonate2.html
+.. _`2nd call for donation`: http://pypy.org/tmdonate2.html
 
 
 Introduction
diff --git a/pypy/module/sys/initpath.py b/pypy/module/sys/initpath.py
--- a/pypy/module/sys/initpath.py
+++ b/pypy/module/sys/initpath.py
@@ -2,27 +2,31 @@
 Logic to find sys.executable and the initial sys.path containing the stdlib
 
 
-import sys
+import errno
 import os
 import stat
-import errno
+import sys
+
 from rpython.rlib import rpath
 from rpython.rlib.objectmodel import we_are_translated
+
 from pypy.interpreter.gateway import unwrap_spec
 from pypy.module.sys.state import get as get_state
 
-platform = sys.platform
 IS_WINDOWS = sys.platform == 'win32'
 
+
 def find_executable(executable):
 
-Return the absolute path of the executable, by looking into PATH and the
-current directory.  If it cannot be found, return ''.
+Return the absolute path of the executable, by looking into PATH and
+the current directory.  If it cannot be found, return ''.
 
-if we_are_translated() and IS_WINDOWS and not 
executable.lower().endswith('.exe'):
+if (we_are_translated() and IS_WINDOWS and
+not executable.lower().endswith('.exe')):
 executable += '.exe'
 if os.sep in executable or (IS_WINDOWS and ':' in executable):
-pass# the path is already more than just an executable name
+# the path is already more than just an executable name
+pass
 else:
 path = os.environ.get('PATH')
 if path:
@@ -35,15 +39,15 @@
 
 # 'sys.executable' should not end up being an non-existing file;
 # just use '' in this case. (CPython issue #7774)
-if not os.path.isfile(executable):
-executable = ''
-return executable
+return executable if os.path.isfile(executable) else ''
+
 
 def _readlink_maybe(filename):
 if not IS_WINDOWS:
 return os.readlink(filename)
 raise NotImplementedError
 
+
 def resolvedirof(filename):
 filename = rpath.rabspath(filename)
 dirname = rpath.rabspath(os.path.join(filename, '..'))
@@ -56,36 +60,37 @@
 return resolvedirof(os.path.join(dirname, link))
 return dirname
 
+
 def find_stdlib(state, executable):
 
 Find and compute the stdlib path, starting from the directory where
-``executable`` is and going one level up until we find it.  Return a tuple
-(path, prefix), where ``prefix`` is the root directory which contains the
-stdlib.
-If it cannot be found, return (None, None).
+``executable`` is and going one level up until we find it.  Return a
+tuple (path, prefix), where ``prefix`` is the root directory which
+contains the stdlib.  If it cannot be found, return (None, None).
 
-if executable == '':
-executable = 'pypy-c'
-search = executable
+search = 'pypy-c' if executable == '' else executable
 while True:
 dirname = resolvedirof(search)
 if dirname == search:
-return None, None # not found :-(
+return None, None  # not found :-(
 newpath = compute_stdlib_path_maybe(state, dirname)
 if newpath is not None:
 return newpath, dirname
 search = dirname# walk to the parent directory
 
+
 def _checkdir(path):
 st = os.stat(path)
 if not stat.S_ISDIR(st[0]):
 

[pypy-commit] pypy py3k: merge default

2014-04-09 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r70519:7eafa2968379
Date: 2014-04-09 11:58 -0700
http://bitbucket.org/pypy/pypy/changeset/7eafa2968379/

Log:merge default

diff --git a/pypy/module/posix/test/test_posix2.py 
b/pypy/module/posix/test/test_posix2.py
--- a/pypy/module/posix/test/test_posix2.py
+++ b/pypy/module/posix/test/test_posix2.py
@@ -333,7 +333,6 @@
 if sys.platform != win32:
 assert not posix.access(pdir, posix.X_OK)
 
-
 def test_times(self):
 
 posix.times() should return a five-tuple giving float-representations
@@ -1099,8 +1098,8 @@
 res = os.system(cmd)
 assert res == 0
 
+
 class AppTestPosixUnicode:
-
 def setup_class(cls):
 cls.space = space
 cls.w_posix = space.appexec([], GET_POSIX)
@@ -1141,6 +1140,7 @@
 except OSError:
 pass
 
+
 class AppTestUnicodeFilename:
 def setup_class(cls):
 ufilename = (unicode(udir.join('test_unicode_filename_')) +
diff --git a/pypy/module/sys/initpath.py b/pypy/module/sys/initpath.py
--- a/pypy/module/sys/initpath.py
+++ b/pypy/module/sys/initpath.py
@@ -13,7 +13,9 @@
 from pypy.interpreter.gateway import unwrap_spec
 from pypy.module.sys.state import get as get_state
 
-IS_WINDOWS = sys.platform == 'win32'
+PLATFORM = sys.platform
+_MACOSX = sys.platform == 'darwin'
+_WIN32 = sys.platform == 'win32'
 
 
 def find_executable(executable):
@@ -21,10 +23,10 @@
 Return the absolute path of the executable, by looking into PATH and
 the current directory.  If it cannot be found, return ''.
 
-if (we_are_translated() and IS_WINDOWS and
+if (we_are_translated() and _WIN32 and
 not executable.lower().endswith('.exe')):
 executable += '.exe'
-if os.sep in executable or (IS_WINDOWS and ':' in executable):
+if os.sep in executable or (_WIN32 and ':' in executable):
 # the path is already more than just an executable name
 pass
 else:
@@ -43,7 +45,7 @@
 
 
 def _readlink_maybe(filename):
-if not IS_WINDOWS:
+if not _WIN32:
 return os.readlink(filename)
 raise NotImplementedError
 
@@ -115,9 +117,9 @@
 importlist.append(lib_tk)
 
 # List here the extra platform-specific paths.
-if not IS_WINDOWS:
-importlist.append(os.path.join(python_std_lib, 'plat-' + sys.platform))
-if sys.platform == 'darwin':
+if not _WIN32:
+importlist.append(os.path.join(python_std_lib, 'plat-' + PLATFORM))
+if _MACOSX:
 platmac = os.path.join(python_std_lib, 'plat-mac')
 importlist.append(platmac)
 importlist.append(os.path.join(platmac, 'lib-scriptpackages'))
@@ -150,7 +152,7 @@
 path, prefix = find_stdlib(get_state(space), executable)
 if path is None:
 return space.w_None
-space.setitem(space.sys.w_dict, space.wrap('prefix'), space.wrap(prefix))
-space.setitem(space.sys.w_dict, space.wrap('exec_prefix'),
-  space.wrap(prefix))
+w_prefix = space.wrap(prefix)
+space.setitem(space.sys.w_dict, space.wrap('prefix'), w_prefix)
+space.setitem(space.sys.w_dict, space.wrap('exec_prefix'), w_prefix)
 return space.newlist([space.wrap(p) for p in path])
diff --git a/pypy/module/sys/test/test_initpath.py 
b/pypy/module/sys/test/test_initpath.py
--- a/pypy/module/sys/test/test_initpath.py
+++ b/pypy/module/sys/test/test_initpath.py
@@ -84,7 +84,7 @@
 assert find_executable('pypy') == a.join('pypy')
 #
 monkeypatch.setattr(initpath, 'we_are_translated', lambda: True)
-monkeypatch.setattr(initpath, 'IS_WINDOWS', True)
+monkeypatch.setattr(initpath, '_WIN32', True)
 monkeypatch.setenv('PATH', str(a))
 a.join('pypy.exe').ensure(file=True)
 assert find_executable('pypy') == a.join('pypy.exe')
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: merge default

2014-04-02 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r70403:10edbabbaae9
Date: 2014-04-02 11:22 -0700
http://bitbucket.org/pypy/pypy/changeset/10edbabbaae9/

Log:merge default

diff --git a/lib-python/2.7/test/test_argparse.py 
b/lib-python/2.7/test/test_argparse.py
--- a/lib-python/2.7/test/test_argparse.py
+++ b/lib-python/2.7/test/test_argparse.py
@@ -10,6 +10,7 @@
 import tempfile
 import unittest
 import argparse
+import gc
 
 from StringIO import StringIO
 
@@ -47,7 +48,11 @@
 
 def tearDown(self):
 os.chdir(self.old_dir)
-shutil.rmtree(self.temp_dir, True)
+gc.collect()
+for root, dirs, files in os.walk(self.temp_dir, topdown=False):
+for name in files:
+os.chmod(os.path.join(self.temp_dir, name), stat.S_IWRITE)
+shutil.rmtree(self.temp_dir, True)
 
 def create_readonly_file(self, filename):
 file_path = os.path.join(self.temp_dir, filename)
diff --git a/pypy/doc/faq.rst b/pypy/doc/faq.rst
--- a/pypy/doc/faq.rst
+++ b/pypy/doc/faq.rst
@@ -429,12 +429,27 @@
 Could we use LLVM?
 --
 
-There is a (static) translation backend using LLVM in the branch
-``llvm-translation-backend``.  It can translate PyPy with or without the JIT on
-Linux.
+In theory yes.  But we tried to use it 5 or 6 times already, as a
+translation backend or as a JIT backend --- and failed each time.
 
-Using LLVM as our JIT backend looks interesting as well -- we made an attempt,
-but it failed: LLVM has no way to patch the generated machine code.
+In more details: using LLVM as a (static) translation backend is
+pointless nowadays because you can generate C code and compile it with
+clang.  (Note that compiling PyPy with clang gives a result that is not
+faster than compiling it with gcc.)  We might in theory get extra
+benefits from LLVM's GC integration, but this requires more work on the
+LLVM side before it would be remotely useful.  Anyway, it could be
+interfaced via a custom primitive in the C code.  (The latest such
+experimental backend is in the branch ``llvm-translation-backend``,
+which can translate PyPy with or without the JIT on Linux.)
+
+On the other hand, using LLVM as our JIT backend looks interesting as
+well --- but again we made an attempt, and it failed: LLVM has no way to
+patch the generated machine code.
+
+So the position of the core PyPy developers is that if anyone wants to
+make an N+1'th attempt with LLVM, they are welcome, and will be happy to
+provide help in the IRC channel, but they are left with the burden of proof
+that (a) it works and (b) it gives important benefits.
 
 --
 How do I compile PyPy?
diff --git a/pypy/doc/stm.rst b/pypy/doc/stm.rst
new file mode 100644
--- /dev/null
+++ b/pypy/doc/stm.rst
@@ -0,0 +1,244 @@
+==
+Transactional Memory
+==
+
+.. contents::
+
+
+This page is about ``pypy-stm``, a special in-development version of
+PyPy which can run multiple independent CPU-hungry threads in the same
+process in parallel.  It is side-stepping what is known in the Python
+world as the global interpreter lock (GIL) problem.
+
+STM stands for Software Transactional Memory, the technique used
+internally.  This page describes ``pypy-stm`` from the perspective of a
+user, describes work in progress, and finally gives references to more
+implementation details.
+
+This work was done by Remi Meier and Armin Rigo.
+
+
+Introduction and current status
+===
+
+``pypy-stm`` is a variant of the regular PyPy interpreter.  With caveats
+listed below, it should be in theory within 25%-50% of the speed of
+PyPy, comparing the JITting version in both cases.  It is called STM for
+Software Transactional Memory, which is the internal technique used (see
+`Reference to implementation details`_).
+
+**pypy-stm requires 64-bit Linux for now.**
+
+Development is done in the branch `stmgc-c7`_.  If you are only
+interested in trying it out, you can download a Ubuntu 12.04 binary
+here__.  The current version supports four segments, which means that
+it will run up to four threads in parallel (in other words, you get a
+GIL effect again, but only if trying to execute more than 4 threads).
+
+To build a version from sources, you first need to compile a custom
+version of clang; we recommend downloading `llvm and clang like
+described here`__, but at revision 201645 (use ``svn co -r 201645 ...``
+for all checkouts).  Then apply all the patches in `this directory`__:
+they are fixes for the very extensive usage that pypy-stm does of a
+clang-only feature (without them, you get crashes of clang).  Then get
+the branch `stmgc-c7`_ of PyPy and run::
+
+   rpython/bin/rpython -Ojit --stm pypy/goal/targetpypystandalone.py
+
+.. _`stmgc-c7`: https://bitbucket.org/pypy/pypy/src/stmgc-c7/
+.. __: http://buildbot.pypy.org/nightly/stmgc-c7/
+.. __: http://clang.llvm.org/get_started.html
+.. __: 

[pypy-commit] pypy py3k: merge default

2014-03-28 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r70321:170a3218cb26
Date: 2014-03-27 16:17 -0700
http://bitbucket.org/pypy/pypy/changeset/170a3218cb26/

Log:merge default

diff --git a/pypy/doc/stackless.rst b/pypy/doc/stackless.rst
--- a/pypy/doc/stackless.rst
+++ b/pypy/doc/stackless.rst
@@ -211,6 +211,9 @@
 
 .. __: `recursion depth limit`_
 
+We also do not include any of the recent API additions to Stackless
+Python, like ``set_atomic()``.  Contributions welcome.
+
 
 Recursion depth limit
 +
diff --git a/pypy/module/cpyext/test/test_cpyext.py 
b/pypy/module/cpyext/test/test_cpyext.py
--- a/pypy/module/cpyext/test/test_cpyext.py
+++ b/pypy/module/cpyext/test/test_cpyext.py
@@ -64,6 +64,8 @@
 kwds[libraries] = [api_library]
 # '%s' undefined; assuming extern returning int
 kwds[compile_extra] = [/we4013]
+# tests are not strictly ansi C compliant, compile as C++
+kwds[compile_extra].append(/TP)
 # prevent linking with PythonXX.lib
 w_maj, w_min = space.fixedview(space.sys.get('version_info'), 5)[:2]
 kwds[link_extra] = [/NODEFAULTLIB:Python%d%d.lib %
@@ -642,30 +644,30 @@
 body = 
 static PyObject* foo_pi(PyObject* self, PyObject *args)
 {
-PyObject *true = Py_True;
-int refcnt = true-ob_refcnt;
+PyObject *true_obj = Py_True;
+int refcnt = true_obj-ob_refcnt;
 int refcnt_after;
-Py_INCREF(true);
-Py_INCREF(true);
-PyBool_Check(true);
-refcnt_after = true-ob_refcnt;
-Py_DECREF(true);
-Py_DECREF(true);
+Py_INCREF(true_obj);
+Py_INCREF(true_obj);
+PyBool_Check(true_obj);
+refcnt_after = true_obj-ob_refcnt;
+Py_DECREF(true_obj);
+Py_DECREF(true_obj);
 fprintf(stderr, REFCNT %i %i\\n, refcnt, refcnt_after);
 return PyBool_FromLong(refcnt_after == refcnt+2  refcnt  3);
 }
 static PyObject* foo_bar(PyObject* self, PyObject *args)
 {
-PyObject *true = Py_True;
+PyObject *true_obj = Py_True;
 PyObject *tup = NULL;
-int refcnt = true-ob_refcnt;
+int refcnt = true_obj-ob_refcnt;
 int refcnt_after;
 
 tup = PyTuple_New(1);
-Py_INCREF(true);
-if (PyTuple_SetItem(tup, 0, true)  0)
+Py_INCREF(true_obj);
+if (PyTuple_SetItem(tup, 0, true_obj)  0)
 return NULL;
-refcnt_after = true-ob_refcnt;
+refcnt_after = true_obj-ob_refcnt;
 Py_DECREF(tup);
 fprintf(stderr, REFCNT2 %i %i\\n, refcnt, refcnt_after);
 return PyBool_FromLong(refcnt_after == refcnt);
diff --git a/pypy/module/cpyext/test/test_intobject.py 
b/pypy/module/cpyext/test/test_intobject.py
--- a/pypy/module/cpyext/test/test_intobject.py
+++ b/pypy/module/cpyext/test/test_intobject.py
@@ -110,10 +110,10 @@
 } EnumObject;
 
 static void
-enum_dealloc(EnumObject *op)
+enum_dealloc(PyObject *op)
 {
-Py_DECREF(op-ob_name);
-Py_TYPE(op)-tp_free((PyObject *)op);
+Py_DECREF(((EnumObject *)op)-ob_name);
+Py_TYPE(op)-tp_free(op);
 }
 
 static PyMemberDef enum_members[] = {
diff --git a/pypy/module/micronumpy/boxes.py b/pypy/module/micronumpy/boxes.py
--- a/pypy/module/micronumpy/boxes.py
+++ b/pypy/module/micronumpy/boxes.py
@@ -161,15 +161,18 @@
 return space.index(self.item(space))
 
 def descr_int(self, space):
-if isinstance(self, W_UnsignedIntegerBox):
-box = self.convert_to(space, W_UInt64Box._get_dtype(space))
+if isinstance(self, W_ComplexFloatingBox):
+box = self.descr_get_real(space)
 else:
-box = self.convert_to(space, W_Int64Box._get_dtype(space))
-return space.int(box.item(space))
+box = self
+return space.call_function(space.w_int, box.item(space))
 
 def descr_float(self, space):
-box = self.convert_to(space, W_Float64Box._get_dtype(space))
-return space.float(box.item(space))
+if isinstance(self, W_ComplexFloatingBox):
+box = self.descr_get_real(space)
+else:
+box = self
+return space.call_function(space.w_float, box.item(space))
 
 def descr_oct(self, space):
 return space.call_method(space.builtin, 'oct', self.descr_int(space))
@@ -178,8 +181,7 @@
 return space.call_method(space.builtin, 'hex', self.descr_int(space))
 
 def descr_nonzero(self, space):
-dtype = self.get_dtype(space)
-return space.wrap(dtype.itemtype.bool(self))
+return space.wrap(self.get_dtype(space).itemtype.bool(self))
 
 def 

[pypy-commit] pypy py3k: merge default

2014-03-25 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r70292:e1951a6821db
Date: 2014-03-25 16:53 -0700
http://bitbucket.org/pypy/pypy/changeset/e1951a6821db/

Log:merge default

diff --git a/lib-python/2.7/test/test_genericpath.py 
b/lib-python/2.7/test/test_genericpath.py
--- a/lib-python/2.7/test/test_genericpath.py
+++ b/lib-python/2.7/test/test_genericpath.py
@@ -231,9 +231,14 @@
 unicwd = u'\xe7w\xf0'
 try:
 fsencoding = test_support.TESTFN_ENCODING or ascii
-unicwd.encode(fsencoding)
+asciival = unicwd.encode(fsencoding)
+if fsencoding == mbcs:
+# http://bugs.python.org/issue850997
+v = asciival.find('?')
+if v = 0:
+raise UnicodeEncodeError(fsencoding, unicwd, v, v, 
asciival)
 except (AttributeError, UnicodeEncodeError):
-# FS encoding is probably ASCII
+# FS encoding is probably ASCII or windows and codepage is 
non-Latin1
 pass
 else:
 with test_support.temp_cwd(unicwd):
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
@@ -117,3 +117,13 @@
 
 .. branch: improve-consecutive-dict-lookups
 Improve the situation when dict lookups of the same key are performed in a 
chain
+
+.. branch: add_PyErr_SetFromErrnoWithFilenameObject_try_2
+.. branch: test_SetFromErrnoWithFilename_NULL
+.. branch: test_SetFromErrnoWithFilename__tweaks
+
+.. branch: refactor_PyErr_SetFromErrnoWithFilename
+Add support for PyErr_SetFromErrnoWithFilenameObject to cpyext
+
+.. branch: win32-fixes4
+fix more tests for win32
diff --git a/pypy/module/_codecs/test/test_codecs.py 
b/pypy/module/_codecs/test/test_codecs.py
--- a/pypy/module/_codecs/test/test_codecs.py
+++ b/pypy/module/_codecs/test/test_codecs.py
@@ -1,3 +1,5 @@
+import sys
+
 class AppTestCodecs:
 spaceconfig = {
 usemodules: ['unicodedata', 'struct', 'binascii'],
@@ -138,7 +140,9 @@
 
 
 class AppTestPartialEvaluation:
-spaceconfig = dict(usemodules=('array',))
+spaceconfig = dict(usemodules=['array',])
+if sys.platform == 'win32':
+spaceconfig['usemodules'].append('_winreg')
 
 def test_partial_utf8(self):
 import _codecs
@@ -753,9 +757,25 @@
 import sys
 if sys.platform != 'win32':
 return
-assert 'test'.encode('mbcs') == b'test'
-assert 'caf\xe9'.encode('mbcs') == b'caf\xe9'
-raises(UnicodeEncodeError, '\u040a'.encode, 'mbcs')
-raises(UnicodeEncodeError,
-   -\u5171\u0141\u2661\u0363\uDC80.encode, 'mbcs')
-assert b'cafx\e9'.decode('mbcs') == 'cafx\e9'
+toencode = u'caf\xe9', b'caf\xe9'
+try:
+# test for non-latin1 codepage, more general test needed
+import _winreg
+key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
+r'System\CurrentControlSet\Control\Nls\CodePage')
+if _winreg.QueryValueEx(key, 'ACP')[0] == u'1255':  # non-latin1
+toencode = u'caf\xbf',b'caf\xbf'
+except:
+assert False, 'cannot test mbcs on this windows system, check code 
page'
+assert u'test'.encode('mbcs') == b'test'
+assert toencode[0].encode('mbcs') == toencode[1]
+assert u'\u040a'.encode('mbcs') == b'?'  # some cyrillic letter
+assert b'cafx\e9'.decode('mbcs') == u'cafx\e9'
+
+def test_bad_handler_string_result(self):
+import _codecs
+def f(exc):
+return (b'foo', exc.end)
+_codecs.register_error(test.test_codecs_not_a_string, f)
+raises(TypeError, u'\u1234'.encode, 'ascii',
+   'test.test_codecs_not_a_string')
diff --git a/pypy/module/cpyext/pyerrors.py b/pypy/module/cpyext/pyerrors.py
--- a/pypy/module/cpyext/pyerrors.py
+++ b/pypy/module/cpyext/pyerrors.py
@@ -146,14 +146,29 @@
 this is used to define the filename attribute of the exception instance.
 Return value: always NULL.
 # XXX Doesn't actually do anything with PyErr_CheckSignals.
+if llfilename:
+w_filename = rffi.charp2str(llfilename)
+filename = space.wrap(w_filename)
+else:
+filename = space.w_None
+
+PyErr_SetFromErrnoWithFilenameObject(space, w_type, filename)
+
+@cpython_api([PyObject, PyObject], PyObject)
+def PyErr_SetFromErrnoWithFilenameObject(space, w_type, w_value):
+Similar to PyErr_SetFromErrno(), with the additional behavior that if
+w_value is not NULL, it is passed to the constructor of type as a
+third parameter.  In the case of exceptions such as IOError and OSError,
+this is used to define the filename attribute of the exception instance.
+Return value: always NULL.
+# XXX Doesn't actually do anything with PyErr_CheckSignals.
 errno = get_errno()
 msg = os.strerror(errno)
-if llfilename:
-

[pypy-commit] pypy py3k: merge default

2014-03-20 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r70135:706e3a4c1ffa
Date: 2014-03-20 15:41 -0700
http://bitbucket.org/pypy/pypy/changeset/706e3a4c1ffa/

Log:merge default

diff --git a/pypy/doc/cpython_differences.rst b/pypy/doc/cpython_differences.rst
--- a/pypy/doc/cpython_differences.rst
+++ b/pypy/doc/cpython_differences.rst
@@ -292,6 +292,10 @@
   depending on the compiler settings, the default of 768KB is enough
   for about 1400 calls.
 
+* since the implementation of dictionary is different, the exact number
+  which ``__hash__`` and ``__eq__`` are called is different. Since CPython
+  does not give any specific guarantees either, don't rely on it.
+
 * assignment to ``__class__`` is limited to the cases where it
   works on CPython 2.5.  On CPython 2.6 and 2.7 it works in a bit
   more cases, which are not supported by PyPy so far.  (If needed,
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
@@ -114,3 +114,6 @@
 app-level.  The `Buffer` class is now used by `W_MemoryView` and
 `W_Buffer`, which is not present in Python 3.  Previously `W_Buffer` was
 an alias to `Buffer`, which was wrappable itself.
+
+.. branch: improve-consecutive-dict-lookups
+Improve the situation when dict lookups of the same key are performed in a 
chain
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -441,11 +441,10 @@
 
 return name
 
-def getbuiltinmodule(self, name, force_init=False, reuse=True):
+def getbuiltinmodule(self, name, force_init=False):
 w_name = self.wrap(name)
 w_modules = self.sys.get('modules')
 if not force_init:
-assert reuse is True
 try:
 return self.getitem(w_modules, w_name)
 except OperationError, e:
@@ -464,15 +463,7 @@
 # Initialize the module
 from pypy.interpreter.module import Module
 if isinstance(w_mod, Module):
-if not reuse and w_mod.startup_called:
-# Create a copy of the module
-w_mod.getdict(self)  # unlazy w_initialdict
-w_new = self.wrap(Module(self, w_name))
-self.call_method(w_new.getdict(self), 'update',
- w_mod.w_initialdict)
-w_mod = w_new
-else:
-w_mod.init(self)
+w_mod.init(self)
 
 # Add the module to sys.modules
 self.setitem(w_modules, w_name, w_mod)
diff --git a/pypy/module/imp/importing.py b/pypy/module/imp/importing.py
--- a/pypy/module/imp/importing.py
+++ b/pypy/module/imp/importing.py
@@ -585,8 +585,7 @@
 return space.call_method(find_info.w_loader, load_module, 
w_modulename)
 
 if find_info.modtype == C_BUILTIN:
-return space.getbuiltinmodule(find_info.filename, force_init=True,
-  reuse=reuse)
+return space.getbuiltinmodule(find_info.filename, force_init=True)
 
 if find_info.modtype in (PY_SOURCE, PY_COMPILED, C_EXTENSION, 
PKG_DIRECTORY):
 w_mod = None
diff --git a/pypy/module/imp/test/test_app.py b/pypy/module/imp/test/test_app.py
--- a/pypy/module/imp/test/test_app.py
+++ b/pypy/module/imp/test/test_app.py
@@ -219,6 +219,7 @@
 
 def test_builtin_reimport(self):
 # from https://bugs.pypy.org/issue1514
+skip(fix me)
 import sys, marshal
 
 old = marshal.loads
@@ -238,6 +239,7 @@
 # taken from https://bugs.pypy.org/issue1514, with extra cases
 # that show a difference with CPython: we can get on CPython
 # several module objects for the same built-in module :-(
+skip(several built-in module objects: not supported by pypy)
 import sys, marshal
 
 old = marshal.loads
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
@@ -652,6 +652,7 @@
 assert hasattr(time, 'clock')
 
 def test_reimport_builtin_simple_case_2(self):
+skip(fix me)
 import sys, time
 time.foo = bar
 del sys.modules['time']
@@ -660,6 +661,7 @@
 
 def test_reimport_builtin(self):
 import imp, sys, time
+skip(fix me)
 oldpath = sys.path
 time.tzset = test_reimport_builtin removed this
 
diff --git a/rpython/jit/backend/arm/opassembler.py 
b/rpython/jit/backend/arm/opassembler.py
--- a/rpython/jit/backend/arm/opassembler.py
+++ b/rpython/jit/backend/arm/opassembler.py
@@ -583,6 +583,10 @@
 emit_op_getfield_raw_pure = emit_op_getfield_gc
 emit_op_getfield_gc_pure = emit_op_getfield_gc
 
+def emit_op_increment_debug_counter(self, op, arglocs, regalloc, fcond):
+# 

[pypy-commit] pypy py3k: merge default

2014-03-20 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r70134:6ff661c8a2b0
Date: 2014-03-19 16:56 -0700
http://bitbucket.org/pypy/pypy/changeset/6ff661c8a2b0/

Log:merge default

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -441,10 +441,11 @@
 
 return name
 
-def getbuiltinmodule(self, name, force_init=False):
+def getbuiltinmodule(self, name, force_init=False, reuse=True):
 w_name = self.wrap(name)
 w_modules = self.sys.get('modules')
 if not force_init:
+assert reuse is True
 try:
 return self.getitem(w_modules, w_name)
 except OperationError, e:
@@ -460,10 +461,18 @@
 getbuiltinmodule() called with non-builtin module %s,
 name)
 else:
-# And initialize it
+# Initialize the module
 from pypy.interpreter.module import Module
 if isinstance(w_mod, Module):
-w_mod.init(self)
+if not reuse and w_mod.startup_called:
+# Create a copy of the module
+w_mod.getdict(self)  # unlazy w_initialdict
+w_new = self.wrap(Module(self, w_name))
+self.call_method(w_new.getdict(self), 'update',
+ w_mod.w_initialdict)
+w_mod = w_new
+else:
+w_mod.init(self)
 
 # Add the module to sys.modules
 self.setitem(w_modules, w_name, w_mod)
diff --git a/pypy/module/cpyext/include/pystate.h 
b/pypy/module/cpyext/include/pystate.h
--- a/pypy/module/cpyext/include/pystate.h
+++ b/pypy/module/cpyext/include/pystate.h
@@ -21,9 +21,8 @@
 #define Py_END_ALLOW_THREADS   PyEval_RestoreThread(_save); \
 }
 
-typedef
-enum {PyGILState_LOCKED, PyGILState_UNLOCKED}
-PyGILState_STATE;
+enum {PyGILState_LOCKED, PyGILState_UNLOCKED};
+typedef int PyGILState_STATE;
 
 #define PyThreadState_GET() PyThreadState_Get()
 
diff --git a/pypy/module/cpyext/pystate.py b/pypy/module/cpyext/pystate.py
--- a/pypy/module/cpyext/pystate.py
+++ b/pypy/module/cpyext/pystate.py
@@ -208,16 +208,14 @@
 # Before external call is after running Python
 rffi.aroundstate.before()
 
-PyGILState_STATE = rffi.COpaquePtr('PyGILState_STATE',
-   typedef='PyGILState_STATE',
-   compilation_info=CConfig._compilation_info_)
+PyGILState_STATE = rffi.INT
 
 @cpython_api([], PyGILState_STATE, error=CANNOT_FAIL)
 def PyGILState_Ensure(space):
 if rffi.aroundstate.after:
 # After external call is before entering Python
 rffi.aroundstate.after()
-return lltype.nullptr(PyGILState_STATE.TO)
+return rffi.cast(PyGILState_STATE, 0)
 
 @cpython_api([PyGILState_STATE], lltype.Void)
 def PyGILState_Release(space, state):
diff --git a/pypy/module/imp/importing.py b/pypy/module/imp/importing.py
--- a/pypy/module/imp/importing.py
+++ b/pypy/module/imp/importing.py
@@ -585,7 +585,8 @@
 return space.call_method(find_info.w_loader, load_module, 
w_modulename)
 
 if find_info.modtype == C_BUILTIN:
-return space.getbuiltinmodule(find_info.filename, force_init=True)
+return space.getbuiltinmodule(find_info.filename, force_init=True,
+  reuse=reuse)
 
 if find_info.modtype in (PY_SOURCE, PY_COMPILED, C_EXTENSION, 
PKG_DIRECTORY):
 w_mod = None
diff --git a/pypy/module/imp/test/test_app.py b/pypy/module/imp/test/test_app.py
--- a/pypy/module/imp/test/test_app.py
+++ b/pypy/module/imp/test/test_app.py
@@ -219,7 +219,6 @@
 
 def test_builtin_reimport(self):
 # from https://bugs.pypy.org/issue1514
-skip(fix me)
 import sys, marshal
 
 old = marshal.loads
@@ -239,7 +238,6 @@
 # taken from https://bugs.pypy.org/issue1514, with extra cases
 # that show a difference with CPython: we can get on CPython
 # several module objects for the same built-in module :-(
-skip(several built-in module objects: not supported by pypy)
 import sys, marshal
 
 old = marshal.loads
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
@@ -652,7 +652,6 @@
 assert hasattr(time, 'clock')
 
 def test_reimport_builtin_simple_case_2(self):
-skip(fix me)
 import sys, time
 time.foo = bar
 del sys.modules['time']
@@ -660,7 +659,6 @@
 assert not hasattr(time, 'foo')
 
 def test_reimport_builtin(self):
-skip(fix me)
 import imp, sys, time
 oldpath = sys.path
 time.tzset = test_reimport_builtin removed 

[pypy-commit] pypy py3k: merge default

2014-03-18 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r70069:fb381945ef16
Date: 2014-03-18 15:23 -0700
http://bitbucket.org/pypy/pypy/changeset/fb381945ef16/

Log:merge default

diff --git a/lib-python/2.7/test/test_memoryview.py 
b/lib-python/2.7/test/test_memoryview.py
--- a/lib-python/2.7/test/test_memoryview.py
+++ b/lib-python/2.7/test/test_memoryview.py
@@ -171,7 +171,7 @@
 # very inconsisten on CPython. In PyPy, memoryview supports
 # the buffer interface, and thus the following comparison
 # succeeds. See also the comment in
-# 
pypy.modules.__builtin__.interp_memoryview.W_MemoryView.descr_buffer
+# pypy.objspace.std.memoryview.W_MemoryView.descr_buffer
 #
 # Comparison with objects which don't support the buffer API
 self.assertFalse(m == uabcdef, %s %s % (self, tp))
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -194,11 +194,6 @@
 return None
 
 def buffer_w(self, space):
-w_impl = space.lookup(self, '__buffer__')
-if w_impl is not None:
-w_result = space.get_and_call_function(w_impl, self)
-if space.isinstance_w(w_result, space.w_buffer):
-return w_result.buf
 self._typed_unwrap_error(space, buffer)
 
 def bytes_w(self, space):
diff --git a/pypy/interpreter/buffer.py b/pypy/interpreter/buffer.py
--- a/pypy/interpreter/buffer.py
+++ b/pypy/interpreter/buffer.py
@@ -7,8 +7,7 @@
 
 class Buffer(object):
 Abstract base class for buffers.
-
-__slots__ = () # no extra slot here
+__slots__ = []
 
 def getlength(self):
 raise NotImplementedError
@@ -29,14 +28,13 @@
 def get_raw_address(self):
 raise ValueError(no raw buffer)
 
-
 def is_writable(self):
 return False
 
+
 class RWBuffer(Buffer):
 Abstract base class for read-write buffers.
-
-__slots__ = () # no extra slot here
+__slots__ = []
 
 def is_writable(self):
 return True
@@ -51,10 +49,8 @@
 self.setitem(start + i, string[i])
 
 
-
-# 
-
 class StringBuffer(Buffer):
+__slots__ = ['value']
 
 def __init__(self, value):
 self.value = value
@@ -76,48 +72,11 @@
 return self.value[start:stop]
 return .join([self.value[start + i*step] for i in xrange(size)])
 
-
-class StringLikeBuffer(Buffer):
-For app-level objects that already have a string-like interface
-with __len__ and a __getitem__ that returns characters or (with
-slicing) substrings.
-# XXX this is inefficient, it should only be used temporarily
-
-def __init__(self, space, w_obj):
-self.space = space
-self.w_obj = w_obj
-
-def getlength(self):
-space = self.space
-return space.len_w(self.w_obj)
-
-def getitem(self, index):
-space = self.space
-w_value = space.getitem(self.w_obj, space.wrap(index))
-try:
-return chr(space.int_w(w_value))
-except OperationError as e:
-if not e.match(space, space.w_TypeError):
-raise
-s = space.bytes_w(w_value)
-if len(s) != 1:
-raise OperationError(space.w_ValueError,
- space.wrap(single byte expected, got 
string))
-char = s[0]   # annotator hint
-return char
-
-def getslice(self, start, stop, step, size):
-space = self.space
-if step != 1:
-raise OperationError(space.w_ValueError, space.wrap(
-buffer object does not support slicing with a step))
-s = space.str_w(space.getslice(self.w_obj, space.wrap(start),
-   space.wrap(stop)))
-return s
-
 # 
 
 class SubBufferMixin(object):
+_attrs_ = ['buffer', 'offset', 'size']
+
 def __init__(self, buffer, offset, size):
 self.buffer = buffer
 self.offset = offset
@@ -141,9 +100,11 @@
   # out of bounds
 return self.buffer.getslice(self.offset + start, self.offset + stop, 
step, size)
 
+
 class SubBuffer(Buffer):
 import_from_mixin(SubBufferMixin)
 
+
 class RWSubBuffer(RWBuffer):
 import_from_mixin(SubBufferMixin)
 
diff --git a/pypy/interpreter/test/test_buffer.py 
b/pypy/interpreter/test/test_buffer.py
--- a/pypy/interpreter/test/test_buffer.py
+++ b/pypy/interpreter/test/test_buffer.py
@@ -1,12 +1,10 @@
 import py
-from pypy.module.__builtin__.interp_memoryview import W_Buffer
 from rpython.tool.udir import udir
 
 testdir = udir.ensure('test_buffer', dir=1)
 
 
 class TestBuffer:
-
 def test_buffer_w(self):
 space = self.space
 w_hello 

[pypy-commit] pypy py3k: merge default

2014-03-18 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r70082:1cf13b13b4a1
Date: 2014-03-18 22:08 -0700
http://bitbucket.org/pypy/pypy/changeset/1cf13b13b4a1/

Log:merge default

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -194,6 +194,11 @@
 return None
 
 def buffer_w(self, space):
+w_impl = space.lookup(self, '__buffer__')
+if w_impl is not None:
+w_result = space.get_and_call_function(w_impl, self)
+if space.isinstance_w(w_result, space.w_buffer):
+return w_result.buffer_w(space)
 self._typed_unwrap_error(space, buffer)
 
 def bytes_w(self, space):
diff --git a/pypy/interpreter/buffer.py b/pypy/interpreter/buffer.py
--- a/pypy/interpreter/buffer.py
+++ b/pypy/interpreter/buffer.py
@@ -1,7 +1,6 @@
 
 Buffer protocol support.
 
-from pypy.interpreter.error import OperationError
 from rpython.rlib.objectmodel import import_from_mixin
 
 
@@ -71,8 +70,8 @@
 assert 0 = start = stop
 return self.value[start:stop]
 return .join([self.value[start + i*step] for i in xrange(size)])
+# 
 
-# 
 
 class SubBufferMixin(object):
 _attrs_ = ['buffer', 'offset', 'size']
@@ -98,7 +97,8 @@
 if start == stop:
 return '' # otherwise, adding self.offset might make them
   # out of bounds
-return self.buffer.getslice(self.offset + start, self.offset + stop, 
step, size)
+return self.buffer.getslice(self.offset + start, self.offset + stop,
+step, size)
 
 
 class SubBuffer(Buffer):
diff --git a/pypy/module/__pypy__/interp_builders.py 
b/pypy/module/__pypy__/interp_builders.py
--- a/pypy/module/__pypy__/interp_builders.py
+++ b/pypy/module/__pypy__/interp_builders.py
@@ -4,7 +4,6 @@
 from pypy.interpreter.typedef import TypeDef
 from rpython.rlib.rstring import UnicodeBuilder, StringBuilder
 from rpython.tool.sourcetools import func_with_new_name
-from rpython.rlib import jit
 
 
 def create_builder(name, strtype, builder_cls):
diff --git a/pypy/module/_cffi_backend/cbuffer.py 
b/pypy/module/_cffi_backend/cbuffer.py
--- a/pypy/module/_cffi_backend/cbuffer.py
+++ b/pypy/module/_cffi_backend/cbuffer.py
@@ -1,4 +1,3 @@
-from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.buffer import RWBuffer
 from pypy.interpreter.error import oefmt
 from pypy.interpreter.gateway import unwrap_spec, interp2app
diff --git a/pypy/module/_cffi_backend/ctypestruct.py 
b/pypy/module/_cffi_backend/ctypestruct.py
--- a/pypy/module/_cffi_backend/ctypestruct.py
+++ b/pypy/module/_cffi_backend/ctypestruct.py
@@ -80,7 +80,6 @@
 return (cfield.ctype, cfield.offset)
 
 def _copy_from_same(self, cdata, w_ob):
-space = self.space
 if isinstance(w_ob, cdataobj.W_CData):
 if w_ob.ctype is self and self.size = 0:
 misc._raw_memcopy(w_ob._cdata, cdata, self.size)
diff --git a/pypy/module/_cffi_backend/handle.py 
b/pypy/module/_cffi_backend/handle.py
--- a/pypy/module/_cffi_backend/handle.py
+++ b/pypy/module/_cffi_backend/handle.py
@@ -1,4 +1,3 @@
-import weakref
 from pypy.interpreter.error import OperationError, oefmt
 from pypy.interpreter.gateway import unwrap_spec
 from pypy.module._cffi_backend import ctypeobj, ctypeptr, cdataobj
diff --git a/pypy/module/_cffi_backend/misc.py 
b/pypy/module/_cffi_backend/misc.py
--- a/pypy/module/_cffi_backend/misc.py
+++ b/pypy/module/_cffi_backend/misc.py
@@ -4,7 +4,7 @@
 
 from rpython.rlib import jit
 from rpython.rlib.objectmodel import keepalive_until_here, specialize
-from rpython.rlib.rarithmetic import r_uint, r_ulonglong, 
is_signed_integer_type
+from rpython.rlib.rarithmetic import r_uint, r_ulonglong
 from rpython.rlib.unroll import unrolling_iterable
 from rpython.rtyper.lltypesystem import lltype, llmemory, rffi
 from rpython.translator.tool.cbuild import ExternalCompilationInfo
diff --git a/pypy/module/_minimal_curses/fficurses.py 
b/pypy/module/_minimal_curses/fficurses.py
--- a/pypy/module/_minimal_curses/fficurses.py
+++ b/pypy/module/_minimal_curses/fficurses.py
@@ -1,4 +1,3 @@
-
  The ffi for rpython, need to be imported for side effects
 
 
@@ -8,8 +7,6 @@
 from rpython.rtyper.extfunc import register_external
 from pypy.module._minimal_curses import interp_curses
 from rpython.translator.tool.cbuild import ExternalCompilationInfo
-from sys import platform
-import os.path
 
 # We cannot trust ncurses5-config, it's broken in various ways in
 # various versions.  For example it might not list -ltinfo even though
diff --git a/pypy/module/_pickle_support/maker.py 
b/pypy/module/_pickle_support/maker.py
--- a/pypy/module/_pickle_support/maker.py
+++ 

[pypy-commit] pypy py3k: merge default

2014-03-13 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r69946:25f71fd3b631
Date: 2014-03-13 21:12 -0700
http://bitbucket.org/pypy/pypy/changeset/25f71fd3b631/

Log:merge default

diff --git a/_pytest/resultlog.py b/_pytest/resultlog.py
--- a/_pytest/resultlog.py
+++ b/_pytest/resultlog.py
@@ -51,16 +51,22 @@
 self.config = config
 self.logfile = logfile # preferably line buffered
 
-def write_log_entry(self, testpath, lettercode, longrepr):
+def write_log_entry(self, testpath, lettercode, longrepr, sections=[]):
 py.builtin.print_(%s %s % (lettercode, testpath), file=self.logfile)
 for line in longrepr.splitlines():
 py.builtin.print_( %s % line, file=self.logfile)
+for key, text in sections:
+py.builtin.print_( , file=self.logfile)
+py.builtin.print_(  %s 
+  % key.rstrip(), file=self.logfile)
+py.builtin.print_( %s % (text.rstrip().replace('\n', '\n '),),
+  file=self.logfile)
 
 def log_outcome(self, report, lettercode, longrepr):
 testpath = getattr(report, 'nodeid', None)
 if testpath is None:
 testpath = report.fspath
-self.write_log_entry(testpath, lettercode, longrepr)
+self.write_log_entry(testpath, lettercode, longrepr, report.sections)
 
 def pytest_runtest_logreport(self, report):
 if report.when != call and report.passed:
diff --git a/pypy/doc/faq.rst b/pypy/doc/faq.rst
--- a/pypy/doc/faq.rst
+++ b/pypy/doc/faq.rst
@@ -187,7 +187,7 @@
 
 No, we found no way of doing that.  The JIT generates machine code
 containing a large number of constant addresses --- constant at the time
-the machine code is written.  The vast majority is probably not at all
+the machine code is generated.  The vast majority is probably not at all
 constants that you find in the executable, with a nice link name.  E.g.
 the addresses of Python classes are used all the time, but Python
 classes don't come statically from the executable; they are created anew
@@ -212,12 +212,16 @@
 garbage collection, implementation of various things like arbitrarily long
 integers, etc. 
 
-Currently, we have preliminary versions of a JavaScript interpreter
-(Leonardo Santagada as his Summer of PyPy project), a `Prolog interpreter`_
-(Carl Friedrich Bolz as his Bachelor thesis), and a `SmallTalk interpreter`_
+Currently, we have `Topaz`_, a Ruby interpreter; `Hippy`_, a PHP
+interpreter; preliminary versions of a `JavaScript interpreter`_
+(Leonardo Santagada as his Summer of PyPy project); a `Prolog interpreter`_
+(Carl Friedrich Bolz as his Bachelor thesis); and a `SmallTalk interpreter`_
 (produced during a sprint).  On the `PyPy bitbucket page`_ there is also a
 Scheme and an Io implementation; both of these are unfinished at the moment.
 
+.. _`Topaz`: http://topazruby.com/
+.. _`Hippy`: http://morepypy.blogspot.ch/2012/07/hello-everyone.html
+.. _`JavaScript interpreter`: https://bitbucket.org/pypy/lang-js/
 .. _`Prolog interpreter`: https://bitbucket.org/cfbolz/pyrolog/
 .. _`SmallTalk interpreter`: http://dx.doi.org/10.1007/978-3-540-89275-5_7
 .. _`PyPy bitbucket page`: https://bitbucket.org/pypy/
diff --git a/pypy/module/micronumpy/__init__.py 
b/pypy/module/micronumpy/__init__.py
--- a/pypy/module/micronumpy/__init__.py
+++ b/pypy/module/micronumpy/__init__.py
@@ -24,7 +24,7 @@
 'set_string_function': 'appbridge.set_string_function',
 'typeinfo': 'descriptor.get_dtype_cache(space).w_typeinfo',
 }
-for c in ['CLIP', 'WRAP', 'RAISE']:
+for c in ['MAXDIMS', 'CLIP', 'WRAP', 'RAISE']:
 interpleveldefs[c] = 'space.wrap(constants.%s)' % c
 
 
diff --git a/pypy/module/micronumpy/base.py b/pypy/module/micronumpy/base.py
--- a/pypy/module/micronumpy/base.py
+++ b/pypy/module/micronumpy/base.py
@@ -58,10 +58,10 @@
 elif owning:
 # Will free storage when GCd
 impl = concrete.ConcreteArray(shape, dtype, order, strides,
-backstrides, storage=storage)
+  backstrides, storage=storage)
 else:
 impl = concrete.ConcreteArrayNotOwning(shape, dtype, order, 
strides,
-backstrides, storage)
+   backstrides, storage)
 if w_subtype:
 w_ret = space.allocate_instance(W_NDimArray, w_subtype)
 W_NDimArray.__init__(w_ret, impl)
diff --git a/pypy/module/micronumpy/boxes.py b/pypy/module/micronumpy/boxes.py
--- a/pypy/module/micronumpy/boxes.py
+++ b/pypy/module/micronumpy/boxes.py
@@ -87,7 +87,8 @@
 value[0] = self.value
 
 builder = StringBuilder()
-builder.append_charpsize(rffi.cast(rffi.CCHARP, value), 
rffi.sizeof(lltype.typeOf(self.value)))
+

[pypy-commit] pypy py3k: merge default

2014-03-12 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r69919:50d426596929
Date: 2014-03-12 18:24 -0700
http://bitbucket.org/pypy/pypy/changeset/50d426596929/

Log:merge default

diff --git a/lib_pypy/audioop.py b/lib_pypy/audioop.py
--- a/lib_pypy/audioop.py
+++ b/lib_pypy/audioop.py
@@ -349,7 +349,7 @@
 r_sample = getsample(cp, size, i + 1)
 
 sample = (l_sample * fac1) + (r_sample * fac2)
-sample = clip(sample)
+sample = int(clip(sample))
 
 _put_sample(result, size, i // 2, sample)
 
@@ -500,7 +500,7 @@
 
 # slice off extra bytes
 trim_index = (out_i * bytes_per_frame) - len(retval)
-retval = _buffer(retval)[:trim_index]
+retval = retval[:trim_index]
 
 return (retval, (d, tuple(samps)))
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: merge default (ac3ce8b66c72)

2014-03-08 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r69810:eae61b54e4fd
Date: 2014-03-07 12:16 -0800
http://bitbucket.org/pypy/pypy/changeset/eae61b54e4fd/

Log:merge default (ac3ce8b66c72)

diff --git a/pypy/module/_cffi_backend/__init__.py 
b/pypy/module/_cffi_backend/__init__.py
--- a/pypy/module/_cffi_backend/__init__.py
+++ b/pypy/module/_cffi_backend/__init__.py
@@ -8,7 +8,7 @@
 appleveldefs = {
 }
 interpleveldefs = {
-'__version__': 'space.wrap(0.8)',
+'__version__': 'space.wrap(0.8.2)',
 
 'load_library': 'libraryobj.load_library',
 
diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py 
b/pypy/module/_cffi_backend/test/_backend_test_c.py
--- a/pypy/module/_cffi_backend/test/_backend_test_c.py
+++ b/pypy/module/_cffi_backend/test/_backend_test_c.py
@@ -3175,6 +3175,8 @@
 assert alignof(BStruct) == 1
 
 def test_packed_with_bitfields():
+if sys.platform == win32:
+py.test.skip(testing gcc behavior)
 BLong = new_primitive_type(long)
 BChar = new_primitive_type(char)
 BStruct = new_struct_type(struct foo)
@@ -3186,4 +3188,4 @@
 
 def test_version():
 # this test is here mostly for PyPy
-assert __version__ == 0.8
+assert __version__ == 0.8.2
diff --git a/pypy/module/select/test/test_select.py 
b/pypy/module/select/test/test_select.py
--- a/pypy/module/select/test/test_select.py
+++ b/pypy/module/select/test/test_select.py
@@ -275,6 +275,8 @@
 
 self.make_server()
 
+self.make_server()
+
 self.sock.listen(1)
 s2 = socket.socket()
 _thread.start_new_thread(s2.connect, (self.sockaddress,))
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: merge default

2014-03-05 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r69747:10973dec5068
Date: 2014-03-05 17:12 -0800
http://bitbucket.org/pypy/pypy/changeset/10973dec5068/

Log:merge default

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
@@ -99,3 +99,6 @@
 Implements SimpleRangeListStrategy for case range(n) where n is a positive 
number.
 Makes some traces nicer by getting rid of multiplication for calculating loop 
counter
 and propagates that n  0 further to get rid of guards.
+
+.. branch: popen-pclose
+Provide an exit status for popen'ed RFiles via pclose
diff --git a/pypy/interpreter/special.py b/pypy/interpreter/special.py
--- a/pypy/interpreter/special.py
+++ b/pypy/interpreter/special.py
@@ -2,16 +2,10 @@
 
 
 class Ellipsis(W_Root):
-def __init__(self, space):
-self.space = space
-
-def descr__repr__(self):
-return self.space.wrap('Ellipsis')
+def descr__repr__(self, space):
+return space.wrap('Ellipsis')
 
 
 class NotImplemented(W_Root):
-def __init__(self, space):
-self.space = space
-
-def descr__repr__(self):
-return self.space.wrap('NotImplemented')
+def descr__repr__(self, space):
+return space.wrap('NotImplemented')
diff --git a/pypy/module/micronumpy/compile.py 
b/pypy/module/micronumpy/compile.py
--- a/pypy/module/micronumpy/compile.py
+++ b/pypy/module/micronumpy/compile.py
@@ -71,8 +71,8 @@
 def __init__(self):
 NOT_RPYTHON
 self.fromcache = InternalSpaceCache(self).getorbuild
-self.w_Ellipsis = special.Ellipsis(self)
-self.w_NotImplemented = special.NotImplemented(self)
+self.w_Ellipsis = special.Ellipsis()
+self.w_NotImplemented = special.NotImplemented()
 
 def _freeze_(self):
 return True
diff --git a/pypy/module/micronumpy/test/test_ndarray.py 
b/pypy/module/micronumpy/test/test_ndarray.py
--- a/pypy/module/micronumpy/test/test_ndarray.py
+++ b/pypy/module/micronumpy/test/test_ndarray.py
@@ -2319,6 +2319,16 @@
 a[...] = 4
 assert (a == [4, 4, 4]).all()
 
+b = np.arange(24).reshape(2,3,4)
+b[...] = 100
+assert (b == 100).all()
+assert b.shape == (2, 3, 4)
+b[...] = [10, 20, 30, 40]
+assert (b[:,:,0] == 10).all()
+assert (b[0,0,:] == [10, 20, 30, 40]).all()
+assert b.shape == b[...].shape
+assert (b == b[...]).all()
+
 
 class AppTestNumArrayFromBuffer(BaseNumpyAppTest):
 spaceconfig = dict(usemodules=[micronumpy, array, mmap])
diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py
--- a/pypy/objspace/std/objspace.py
+++ b/pypy/objspace/std/objspace.py
@@ -59,8 +59,8 @@
 self.w_None = W_NoneObject.w_None
 self.w_False = W_BoolObject.w_False
 self.w_True = W_BoolObject.w_True
-self.w_NotImplemented = self.wrap(special.NotImplemented(self))
-self.w_Ellipsis = self.wrap(special.Ellipsis(self))
+self.w_NotImplemented = self.wrap(special.NotImplemented())
+self.w_Ellipsis = self.wrap(special.Ellipsis())
 
 # types
 self.builtin_types = {}
diff --git a/pypy/objspace/std/test/test_intobject.py 
b/pypy/objspace/std/test/test_intobject.py
--- a/pypy/objspace/std/test/test_intobject.py
+++ b/pypy/objspace/std/test/test_intobject.py
@@ -543,10 +543,13 @@
 assert a == 9007199254740991
 a = operator.truediv(x, 7)
 assert a == 9007199254740991.0
-exec(from __future__ import division; 
- a = x / 7; b = operator.truediv(x, 7))
-assert a == 9007199254740991.0
-assert b == 9007199254740991.0
+
+def test_truediv_future(self):
+ns = dict(x=63050394783186940)
+exec(from __future__ import division; import operator; 
+ a = x / 7; b = operator.truediv(x, 7), ns)
+assert ns['a'] == 9007199254740991.0
+assert ns['b'] == 9007199254740991.0
 
 
 class AppTestIntShortcut(AppTestInt):
diff --git a/pypy/objspace/std/test/test_listobject.py 
b/pypy/objspace/std/test/test_listobject.py
--- a/pypy/objspace/std/test/test_listobject.py
+++ b/pypy/objspace/std/test/test_listobject.py
@@ -433,7 +433,7 @@
 intlist.find(w(4), 0, 2)
 
 
-class AppTestW_ListObject(object):
+class AppTestListObject(object):
 def setup_class(cls):
 import platform
 import sys
@@ -526,6 +526,18 @@
 l.__init__(assignment)
 assert l == list(assignment)
 
+def test_range_init(self):
+x = range(5,1)
+assert x == []
+
+x = range(1,10)
+x[22:0:-1] == range(1,10)
+
+r = range(10, 10)
+assert len(r) == 0
+assert list(reversed(r)) == []
+assert r[:] == []
+
 def test_extend_list(self):
 l = l0 = [1]
 l.extend([2])
@@ -598,24 +610,28 @@
 def test_sort_key(self):
 def lower(x): return 

[pypy-commit] pypy py3k: merge default

2014-02-13 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r69136:3b71e90dc818
Date: 2014-02-10 18:24 -0800
http://bitbucket.org/pypy/pypy/changeset/3b71e90dc818/

Log:merge default

diff --git a/pypy/objspace/std/dictmultiobject.py 
b/pypy/objspace/std/dictmultiobject.py
--- a/pypy/objspace/std/dictmultiobject.py
+++ b/pypy/objspace/std/dictmultiobject.py
@@ -1,3 +1,10 @@
+The builtin dict implementation
+
+from rpython.rlib import jit, rerased
+from rpython.rlib.debug import mark_dict_non_null
+from rpython.rlib.objectmodel import newlist_hint, r_dict, specialize
+from rpython.tool.sourcetools import func_renamer, func_with_new_name
+
 from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.error import OperationError, oefmt
 from pypy.interpreter.gateway import (
@@ -7,18 +14,10 @@
 from pypy.objspace.std.stdtypedef import StdTypeDef
 from pypy.objspace.std.util import negate
 
-from rpython.rlib import jit, rerased
-from rpython.rlib.debug import mark_dict_non_null
-from rpython.rlib.objectmodel import newlist_hint, r_dict, specialize
-from rpython.tool.sourcetools import func_renamer, func_with_new_name
-
 
 UNROLL_CUTOFF = 5
 
 
-def _is_str(space, w_key):
-return space.is_w(space.type(w_key), space.w_str)
-
 def _never_equal_to_string(space, w_lookup_type):
 Handles the case of a non string key lookup.
 Types that have a sane hash/eq function should allow us to return True
@@ -29,8 +28,8 @@
 return (space.is_w(w_lookup_type, space.w_NoneType) or
 space.is_w(w_lookup_type, space.w_int) or
 space.is_w(w_lookup_type, space.w_bool) or
-space.is_w(w_lookup_type, space.w_float)
-)
+space.is_w(w_lookup_type, space.w_float))
+
 
 @specialize.call_location()
 def w_dict_unrolling_heuristic(w_dct):
@@ -69,19 +68,18 @@
 w_type = space.w_dict
 
 storage = strategy.get_empty_storage()
-w_self = space.allocate_instance(W_DictMultiObject, w_type)
-W_DictMultiObject.__init__(w_self, space, strategy, storage)
-return w_self
+w_obj = space.allocate_instance(W_DictMultiObject, w_type)
+W_DictMultiObject.__init__(w_obj, space, strategy, storage)
+return w_obj
 
 def __init__(self, space, strategy, storage):
 self.space = space
 self.strategy = strategy
 self.dstorage = storage
 
-def __repr__(w_self):
+def __repr__(self):
 representation for debugging purposes
-#print('XXX', w_self.dstorage)
-return %s(%s) % (w_self.__class__.__name__, w_self.strategy)
+return %s(%s) % (self.__class__.__name__, self.strategy)
 
 def unwrap(w_dict, space):
 result = {}
@@ -98,9 +96,9 @@
 return space.get_and_call_function(w_missing, w_dict, w_key)
 return None
 
-def initialize_content(w_self, list_pairs_w):
+def initialize_content(self, list_pairs_w):
 for w_k, w_v in list_pairs_w:
-w_self.setitem(w_k, w_v)
+self.setitem(w_k, w_v)
 
 def setitem_str(self, key, w_value):
 self.strategy.setitem_str(self, key, w_value)
@@ -115,7 +113,8 @@
 if w_fill is None:
 w_fill = space.w_None
 if space.is_w(w_type, space.w_dict):
-w_dict = W_DictMultiObject.allocate_and_init_instance(space, 
w_type)
+w_dict = W_DictMultiObject.allocate_and_init_instance(space,
+  w_type)
 
 byteslist = space.listview_bytes(w_keys)
 if byteslist is not None:
@@ -250,8 +249,7 @@
 try:
 w_key, w_value = self.popitem()
 except KeyError:
-raise OperationError(space.w_KeyError,
- space.wrap(popitem(): dictionary is empty))
+raise oefmt(space.w_KeyError, popitem(): dictionary is empty)
 return space.newtuple([w_key, w_value])
 
 @unwrap_spec(w_default=WrappedDefault(None))
@@ -527,6 +525,7 @@
 def getiterkeys(self, w_dict):
 return iter([None])
 getitervalues = getiterkeys
+
 def getiteritems(self, w_dict):
 return iter([(None, None)])
 
@@ -545,8 +544,8 @@
 space = self.space
 if self.len != self.dictimplementation.length():
 self.len = -1   # Make this error state sticky
-msg = dictionary changed size during iteration
-raise OperationError(space.w_RuntimeError, space.wrap(msg))
+raise oefmt(space.w_RuntimeError,
+dictionary changed size during iteration)
 
 # look for the next entry
 if self.pos  self.len:
@@ -565,14 +564,15 @@
 w_value = self.dictimplementation.getitem(w_key)
 if w_value is None:
 self.len = -1   # Make this error state sticky
-msg = dictionary changed during iteration
-raise 

[pypy-commit] pypy py3k: merge default

2014-02-13 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r69135:305f4623907b
Date: 2014-02-10 14:42 -0800
http://bitbucket.org/pypy/pypy/changeset/305f4623907b/

Log:merge default

diff --git a/pypy/doc/faq.rst b/pypy/doc/faq.rst
--- a/pypy/doc/faq.rst
+++ b/pypy/doc/faq.rst
@@ -103,8 +103,7 @@
 
 .. _`extension modules`: cpython_differences.html#extension-modules
 .. _`cpython differences`: cpython_differences.html
-.. _`compatibility wiki`:
-.. https://bitbucket.org/pypy/compatibility/wiki/Home
+.. _`compatibility wiki`: https://bitbucket.org/pypy/compatibility/wiki/Home
 .. _cffi: http://cffi.readthedocs.org/
 
 -
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
@@ -57,3 +57,13 @@
 mapdicts keep track of whether or not an attribute is every assigned to
 multiple times. If it's only assigned once then an elidable lookup is used when
 possible.
+
+.. branch: precompiled-headers
+Create a Makefile using precompiled headers for MSVC platforms.
+The downside is a messy nmake-compatible Makefile. Since gcc shows minimal
+speedup, it was not implemented.
+
+.. branch: camelot
+With a properly configured 256-color terminal (TERM=...-256color), the
+Mandelbrot set shown during translation now uses a range of 50 colours.
+Essential!
diff --git a/pypy/module/__pypy__/__init__.py b/pypy/module/__pypy__/__init__.py
--- a/pypy/module/__pypy__/__init__.py
+++ b/pypy/module/__pypy__/__init__.py
@@ -82,6 +82,7 @@
 'newdict'   : 'interp_dict.newdict',
 'dictstrategy'  : 'interp_dict.dictstrategy',
 'set_debug' : 'interp_magic.set_debug',
+'locals_to_fast': 'interp_magic.locals_to_fast',
 'normalize_exc' : 'interp_magic.normalize_exc',
 }
 
diff --git a/pypy/module/__pypy__/interp_magic.py 
b/pypy/module/__pypy__/interp_magic.py
--- a/pypy/module/__pypy__/interp_magic.py
+++ b/pypy/module/__pypy__/interp_magic.py
@@ -1,5 +1,6 @@
 from pypy.interpreter.error import OperationError, wrap_oserror
 from pypy.interpreter.gateway import WrappedDefault, unwrap_spec
+from pypy.interpreter.pyframe import PyFrame
 from rpython.rlib.objectmodel import we_are_translated
 from pypy.objspace.std.listobject import W_ListObject
 from pypy.objspace.std.typeobject import MethodCache
@@ -109,6 +110,11 @@
 def add_memory_pressure(estimate):
 rgc.add_memory_pressure(estimate)
 
+@unwrap_spec(w_frame=PyFrame)
+def locals_to_fast(space, w_frame):
+assert isinstance(w_frame, PyFrame)
+w_frame.locals2fast()
+
 @unwrap_spec(w_value=WrappedDefault(None), w_tb=WrappedDefault(None))
 def normalize_exc(space, w_type, w_value=None, w_tb=None):
 operr = OperationError(w_type, w_value, w_tb)
diff --git a/pypy/module/__pypy__/test/test_locals2fast.py 
b/pypy/module/__pypy__/test/test_locals2fast.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/__pypy__/test/test_locals2fast.py
@@ -0,0 +1,81 @@
+# Tests from Fabio Zadrozny
+
+
+class AppTestLocals2Fast:
+
+Test setting locals in one function from another function
+using several approaches.
+
+
+def setup_class(cls):
+cls.w_save_locals = cls.space.appexec([], ():
+import sys
+if '__pypy__' in sys.builtin_module_names:
+import __pypy__
+save_locals = __pypy__.locals_to_fast
+else:
+# CPython version
+import ctypes
+@staticmethod
+def save_locals(frame):
+ctypes.pythonapi.PyFrame_LocalsToFast(
+ctypes.py_object(frame), ctypes.c_int(0))
+return save_locals
+)
+
+def test_set_locals_using_save_locals(self):
+import sys
+def use_save_locals(name, value):
+frame = sys._getframe().f_back
+locals_dict = frame.f_locals
+locals_dict[name] = value
+self.save_locals(frame)
+def test_method(fn):
+x = 1
+# The method 'fn' should attempt to set x = 2 in the current frame.
+fn('x', 2)
+return x
+x = test_method(use_save_locals)
+assert x == 2
+
+def test_frame_simple_change(self):
+import sys
+frame = sys._getframe()
+a = 20
+frame.f_locals['a'] = 50
+self.save_locals(frame)
+assert a == 50
+
+def test_frame_co_freevars(self):
+import sys
+outer_var = 20
+def func():
+frame = sys._getframe()
+frame.f_locals['outer_var'] = 50
+self.save_locals(frame)
+assert outer_var == 50
+func()
+
+def test_frame_co_cellvars(self):
+import sys
+def check_co_vars(a):
+frame = sys._getframe()
+def function2():
+print a
+

[pypy-commit] pypy py3k: merge default

2014-02-02 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r69056:5b5f0da64f64
Date: 2014-02-02 21:42 -0800
http://bitbucket.org/pypy/pypy/changeset/5b5f0da64f64/

Log:merge default

diff --git a/rpython/rlib/test/test_rarithmetic.py 
b/rpython/rlib/test/test_rarithmetic.py
--- a/rpython/rlib/test/test_rarithmetic.py
+++ b/rpython/rlib/test/test_rarithmetic.py
@@ -492,9 +492,9 @@
 py.test.raises(ParseStringError, string_to_int, '-0x', 16)
 
 exc = py.test.raises(ParseStringError, string_to_int, '')
-assert exc.value.msg == invalid literal for int() with base 10: ''
+assert exc.value.msg == invalid literal for int() with base 10
 exc = py.test.raises(ParseStringError, string_to_int, '', 0)
-assert exc.value.msg == invalid literal for int() with base 0: ''
+assert exc.value.msg == invalid literal for int() with base 0
 
 def test_string_to_int_overflow(self):
 import sys
diff --git a/rpython/rtyper/test/test_llannotation.py 
b/rpython/rtyper/test/test_llannotation.py
new file mode 100644
--- /dev/null
+++ b/rpython/rtyper/test/test_llannotation.py
@@ -0,0 +1,89 @@
+import py.test
+from rpython.annotator.model import (
+SomeInteger, SomeBool, SomeChar, unionof, SomeImpossibleValue,
+UnionError, SomeInstance, SomeSingleFloat)
+from rpython.rlib.rarithmetic import r_uint, r_singlefloat
+from rpython.rtyper.llannotation import (
+SomePtr, annotation_to_lltype, ll_to_annotation)
+from rpython.rtyper.typesystem import lltype
+import rpython.rtyper.rtyper  # make sure to import the world
+
+class C(object):
+pass
+
+class DummyClassDef:
+def __init__(self, cls=C):
+self.cls = cls
+self.name = cls.__name__
+
+def test_ll_to_annotation():
+s_z = ll_to_annotation(lltype.Signed._defl())
+s_s = SomeInteger()
+s_u = SomeInteger(nonneg=True, unsigned=True)
+assert s_z.contains(s_s)
+assert not s_z.contains(s_u)
+s_uz = ll_to_annotation(lltype.Unsigned._defl())
+assert s_uz.contains(s_u)
+assert ll_to_annotation(lltype.Bool._defl()).contains(SomeBool())
+assert ll_to_annotation(lltype.Char._defl()).contains(SomeChar())
+S = lltype.GcStruct('s')
+A = lltype.GcArray()
+s_p = ll_to_annotation(lltype.malloc(S))
+assert isinstance(s_p, SomePtr) and s_p.ll_ptrtype == lltype.Ptr(S)
+s_p = ll_to_annotation(lltype.malloc(A, 0))
+assert isinstance(s_p, SomePtr) and s_p.ll_ptrtype == lltype.Ptr(A)
+
+def test_annotation_to_lltype():
+s_i = SomeInteger()
+s_pos = SomeInteger(nonneg=True)
+s_1 = SomeInteger(nonneg=True)
+s_1.const = 1
+s_m1 = SomeInteger(nonneg=False)
+s_m1.const = -1
+s_u = SomeInteger(nonneg=True, unsigned=True)
+s_u1 = SomeInteger(nonneg=True, unsigned=True)
+s_u1.const = r_uint(1)
+assert annotation_to_lltype(s_i) == lltype.Signed
+assert annotation_to_lltype(s_pos) == lltype.Signed
+assert annotation_to_lltype(s_1) == lltype.Signed
+assert annotation_to_lltype(s_m1) == lltype.Signed
+assert annotation_to_lltype(s_u) == lltype.Unsigned
+assert annotation_to_lltype(s_u1) == lltype.Unsigned
+assert annotation_to_lltype(SomeBool()) == lltype.Bool
+assert annotation_to_lltype(SomeChar()) == lltype.Char
+PS = lltype.Ptr(lltype.GcStruct('s'))
+s_p = SomePtr(ll_ptrtype=PS)
+assert annotation_to_lltype(s_p) == PS
+si0 = SomeInstance(DummyClassDef(), True)
+with py.test.raises(ValueError):
+annotation_to_lltype(si0)
+s_singlefloat = SomeSingleFloat()
+s_singlefloat.const = r_singlefloat(0.0)
+assert annotation_to_lltype(s_singlefloat) == lltype.SingleFloat
+
+def test_ll_union():
+PS1 = lltype.Ptr(lltype.GcStruct('s'))
+PS2 = lltype.Ptr(lltype.GcStruct('s'))
+PS3 = lltype.Ptr(lltype.GcStruct('s3'))
+PA1 = lltype.Ptr(lltype.GcArray())
+PA2 = lltype.Ptr(lltype.GcArray())
+
+assert unionof(SomePtr(PS1), SomePtr(PS1)) == SomePtr(PS1)
+assert unionof(SomePtr(PS1), SomePtr(PS2)) == SomePtr(PS2)
+assert unionof(SomePtr(PS1), SomePtr(PS2)) == SomePtr(PS1)
+
+assert unionof(SomePtr(PA1), SomePtr(PA1)) == SomePtr(PA1)
+assert unionof(SomePtr(PA1), SomePtr(PA2)) == SomePtr(PA2)
+assert unionof(SomePtr(PA1), SomePtr(PA2)) == SomePtr(PA1)
+
+assert unionof(SomePtr(PS1), SomeImpossibleValue()) == SomePtr(PS1)
+assert unionof(SomeImpossibleValue(), SomePtr(PS1)) == SomePtr(PS1)
+
+with py.test.raises(UnionError):
+unionof(SomePtr(PA1), SomePtr(PS1))
+with py.test.raises(UnionError):
+unionof(SomePtr(PS1), SomePtr(PS3))
+with py.test.raises(UnionError):
+unionof(SomePtr(PS1), SomeInteger())
+with py.test.raises(UnionError):
+unionof(SomeInteger(), SomePtr(PS1))
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: merge default

2014-02-02 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r69052:220c588360e5
Date: 2014-02-02 16:35 -0800
http://bitbucket.org/pypy/pypy/changeset/220c588360e5/

Log:merge default

diff --git a/pypy/module/_cffi_backend/test/test_handle.py 
b/pypy/module/_cffi_backend/test/test_handle.py
--- a/pypy/module/_cffi_backend/test/test_handle.py
+++ b/pypy/module/_cffi_backend/test/test_handle.py
@@ -1,20 +1,5 @@
 import random
-from pypy.module._cffi_backend.handle import CffiHandles, reduced_value
-
-
-def test_reduced_value():
-assert reduced_value(0) == 0
-assert reduced_value(1) == 0
-assert reduced_value(2) == 1
-assert reduced_value(3) == 0
-assert reduced_value(4) == 2
-assert reduced_value(5) == 1
-assert reduced_value(6) == 3
-assert reduced_value(7) == 0
-assert reduced_value(8) == 4
-assert reduced_value(9) == 2
-assert reduced_value(10) == 5
-assert reduced_value(11) == 1
+from pypy.module._cffi_backend.handle import CffiHandles
 
 
 class PseudoWeakRef(object):
diff --git a/pypy/module/_csv/interp_reader.py 
b/pypy/module/_csv/interp_reader.py
--- a/pypy/module/_csv/interp_reader.py
+++ b/pypy/module/_csv/interp_reader.py
@@ -39,6 +39,7 @@
 field_builder.append(c)
 
 def save_field(self, field_builder):
+space = self.space
 field = field_builder.build()
 if self.numeric_field:
 from rpython.rlib.rstring import ParseStringError
@@ -46,12 +47,12 @@
 self.numeric_field = False
 try:
 ff = string_to_float(field)
-except ParseStringError, e:
-raise OperationError(self.space.w_ValueError,
- self.space.wrap(e.msg))
-w_obj = self.space.wrap(ff)
+except ParseStringError as e:
+from pypy.objspace.std.inttype import wrap_parsestringerror
+raise wrap_parsestringerror(space, e, space.wrap(field))
+w_obj = space.wrap(ff)
 else:
-w_obj = self.space.wrap(field)
+w_obj = space.wrap(field)
 self.fields_w.append(w_obj)
 
 def next_w(self):
diff --git a/pypy/module/micronumpy/interp_boxes.py 
b/pypy/module/micronumpy/interp_boxes.py
--- a/pypy/module/micronumpy/interp_boxes.py
+++ b/pypy/module/micronumpy/interp_boxes.py
@@ -251,6 +251,10 @@
 value = space.is_true(self)
 return get_dtype_cache(space).w_booldtype.box(value)
 
+def descr_zero(self, space):
+from pypy.module.micronumpy.interp_dtype import get_dtype_cache
+return get_dtype_cache(space).w_longdtype.box(0)
+
 def descr_ravel(self, space):
 from pypy.module.micronumpy.base import convert_to_array
 w_values = space.newtuple([self])
@@ -582,6 +586,12 @@
 __hash__ = interp2app(W_GenericBox.descr_hash),
 
 tolist = interp2app(W_GenericBox.item),
+min = interp2app(W_GenericBox.descr_self),
+max = interp2app(W_GenericBox.descr_self),
+argmin = interp2app(W_GenericBox.descr_zero),
+argmax = interp2app(W_GenericBox.descr_zero),
+sum = interp2app(W_GenericBox.descr_self),
+prod = interp2app(W_GenericBox.descr_self),
 any = interp2app(W_GenericBox.descr_any),
 all = interp2app(W_GenericBox.descr_all),
 ravel = interp2app(W_GenericBox.descr_ravel),
diff --git a/pypy/module/micronumpy/test/test_scalar.py 
b/pypy/module/micronumpy/test/test_scalar.py
--- a/pypy/module/micronumpy/test/test_scalar.py
+++ b/pypy/module/micronumpy/test/test_scalar.py
@@ -102,6 +102,16 @@
 assert b == a
 assert b is not a
 
+def test_methods(self):
+import numpy as np
+for a in [np.int32(2), np.float64(2.0), np.complex64(42)]:
+for op in ['min', 'max', 'sum', 'prod']:
+assert getattr(a, op)() == a
+for op in ['argmin', 'argmax']:
+b = getattr(a, op)()
+assert type(b) is np.int_
+assert b == 0
+
 def test_buffer(self):
 import numpy as np
 a = np.int32(123)
diff --git a/pypy/objspace/std/floattype.py b/pypy/objspace/std/floattype.py
--- a/pypy/objspace/std/floattype.py
+++ b/pypy/objspace/std/floattype.py
@@ -34,20 +34,11 @@
 value = space.float_w(w_obj)
 elif (space.isinstance_w(w_value, space.w_str) or
   space.isinstance_w(w_value, space.w_bytearray)):
-strvalue = space.bufferstr_w(w_value)
-try:
-value = rfloat.string_to_float(strvalue.decode('latin-1'))
-except ParseStringError, e:
-raise OperationError(space.w_ValueError,
- space.wrap(e.msg))
+value = _string_to_float(space, w_value, space.bufferstr_w(w_value))
 elif space.isinstance_w(w_value, space.w_unicode):
 from unicodeobject import unicode_to_decimal_w
-strvalue = unicode_to_decimal_w(space, w_value)
-try:
-value = 

[pypy-commit] pypy py3k: merge default

2014-01-28 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r68981:15b720ac779c
Date: 2014-01-28 12:43 -0800
http://bitbucket.org/pypy/pypy/changeset/15b720ac779c/

Log:merge default

diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py
--- a/pypy/interpreter/error.py
+++ b/pypy/interpreter/error.py
@@ -428,8 +428,8 @@
 class OpErrFmtNoArgs(OperationError):
 
 def __init__(self, w_type, value):
+self._value = value
 self.setup(w_type)
-self._value = value
 
 def get_w_value(self, space):
 w_value = self._w_value
diff --git a/pypy/module/micronumpy/interp_numarray.py 
b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -903,8 +903,8 @@
 w_res = self.descr_mul(space, other)
 assert isinstance(w_res, W_NDimArray)
 return w_res.descr_sum(space, space.wrap(-1), out)
-dtype = interp_ufuncs.find_binop_result_dtype(space,
- self.get_dtype(), other.get_dtype())
+dtype = interp_ufuncs.find_binop_result_dtype(space, self.get_dtype(),
+ other.get_dtype())
 if self.get_size()  1 and other.get_size()  1:
 # numpy compatability
 return W_NDimArray.new_scalar(space, dtype, space.wrap(0))
@@ -912,25 +912,27 @@
 out_shape, other_critical_dim = _match_dot_shapes(space, self, other)
 if out:
 matches = True
-if len(out.get_shape()) != len(out_shape):
+if dtype != out.get_dtype():
+matches = False
+elif not out.implementation.order == C:
+matches = False
+elif len(out.get_shape()) != len(out_shape):
 matches = False
 else:
 for i in range(len(out_shape)):
 if out.get_shape()[i] != out_shape[i]:
 matches = False
 break
-if dtype != out.get_dtype():
-matches = False
-if not out.implementation.order == C:
-matches = False
 if not matches:
 raise OperationError(space.w_ValueError, space.wrap(
-'output array is not acceptable (must have the right type, 
nr dimensions, and be a C-Array)'))
+'output array is not acceptable (must have the right type, 
'
+'nr dimensions, and be a C-Array)'))
 w_res = out
+w_res.fill(space, self.get_dtype().coerce(space, None))
 else:
 w_res = W_NDimArray.from_shape(space, out_shape, dtype, 
w_instance=self)
 # This is the place to add fpypy and blas
-return loop.multidim_dot(space, self, other,  w_res, dtype,
+return loop.multidim_dot(space, self, other, w_res, dtype,
  other_critical_dim)
 
 def descr_mean(self, space, __args__):
diff --git a/pypy/module/micronumpy/interp_ufuncs.py 
b/pypy/module/micronumpy/interp_ufuncs.py
--- a/pypy/module/micronumpy/interp_ufuncs.py
+++ b/pypy/module/micronumpy/interp_ufuncs.py
@@ -254,6 +254,13 @@
 return out
 return res
 
+def descr_outer(self, space, __args__):
+return self._outer(space, __args__)
+
+def _outer(self, space, __args__):
+raise OperationError(space.w_ValueError,
+ space.wrap(outer product only supported for 
binary functions))
+
 class W_Ufunc1(W_Ufunc):
 _immutable_fields_ = [func, bool_result]
 argcount = 1
@@ -432,6 +439,7 @@
 nin = interp_attrproperty(argcount, cls=W_Ufunc),
 
 reduce = interp2app(W_Ufunc.descr_reduce),
+outer = interp2app(W_Ufunc.descr_outer),
 )
 
 
diff --git a/pypy/module/micronumpy/loop.py b/pypy/module/micronumpy/loop.py
--- a/pypy/module/micronumpy/loop.py
+++ b/pypy/module/micronumpy/loop.py
@@ -146,8 +146,7 @@
 while not obj_iter.done():
 reduce_driver.jit_merge_point(shapelen=shapelen, func=func,
   done_func=done_func,
-  calc_dtype=calc_dtype,
-  )
+  calc_dtype=calc_dtype)
 rval = obj_iter.getitem().convert_to(space, calc_dtype)
 if done_func is not None and done_func(calc_dtype, rval):
 return rval
@@ -172,8 +171,7 @@
 shapelen = len(obj.get_shape())
 while not obj_iter.done():
 reduce_cum_driver.jit_merge_point(shapelen=shapelen, func=func,
-  dtype=calc_dtype,
- )
+  dtype=calc_dtype)
 rval = obj_iter.getitem().convert_to(space, calc_dtype)
 cur_value = func(calc_dtype, cur_value, rval)
 

[pypy-commit] pypy py3k: merge default

2014-01-24 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r68928:a27d22674995
Date: 2014-01-24 16:52 -0800
http://bitbucket.org/pypy/pypy/changeset/a27d22674995/

Log:merge default

diff --git a/pypy/module/micronumpy/interp_boxes.py 
b/pypy/module/micronumpy/interp_boxes.py
--- a/pypy/module/micronumpy/interp_boxes.py
+++ b/pypy/module/micronumpy/interp_boxes.py
@@ -389,6 +389,9 @@
 class W_Float64Box(W_FloatingBox, PrimitiveBox):
 descr__new__, _get_dtype, descr_reduce = new_dtype_getter(float64)
 
+def descr_as_integer_ratio(self, space):
+return space.call_method(self.item(space), 'as_integer_ratio')
+
 class W_ComplexFloatingBox(W_InexactBox):
 def descr_get_real(self, space):
 dtype = self._COMPONENTS_BOX._get_dtype(space)
@@ -715,6 +718,7 @@
 __module__ = numpy,
 __new__ = interp2app(W_Float64Box.descr__new__.im_func),
 __reduce__ = interp2app(W_Float64Box.descr_reduce),
+as_integer_ratio = interp2app(W_Float64Box.descr_as_integer_ratio),
 )
 
 W_ComplexFloatingBox.typedef = TypeDef(complexfloating, W_InexactBox.typedef,
diff --git a/pypy/module/micronumpy/test/test_scalar.py 
b/pypy/module/micronumpy/test/test_scalar.py
--- a/pypy/module/micronumpy/test/test_scalar.py
+++ b/pypy/module/micronumpy/test/test_scalar.py
@@ -181,6 +181,11 @@
 s = np.dtype([('a', 'int64'), ('b', 'int64')]).type('a' * 16)
 assert s.view('S16') == 'a' * 16
 
+def test_as_integer_ratio(self):
+import numpy as np
+raises(AttributeError, 'np.float32(1.5).as_integer_ratio()')
+assert np.float64(1.5).as_integer_ratio() == (3, 2)
+
 def test_complex_scalar_complex_cast(self):
 import numpy as np
 for tp in [np.csingle, np.cdouble, np.clongdouble]:
diff --git a/pypy/objspace/std/bytearrayobject.py 
b/pypy/objspace/std/bytearrayobject.py
--- a/pypy/objspace/std/bytearrayobject.py
+++ b/pypy/objspace/std/bytearrayobject.py
@@ -1,21 +1,22 @@
 The builtin bytearray implementation
 
+from rpython.rlib.objectmodel import (
+import_from_mixin, newlist_hint, resizelist_hint)
+from rpython.rlib.rstring import StringBuilder
+
 from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.buffer import RWBuffer
 from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.objspace.std.bytesobject import (
 getbytevalue, makebytesdata_w, newbytesdata_w)
-from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
+from pypy.interpreter.gateway import WrappedDefault, interp2app, unwrap_spec
 from pypy.objspace.std.sliceobject import W_SliceObject
 from pypy.objspace.std.stdtypedef import StdTypeDef
 from pypy.objspace.std.stringmethods import StringMethods
 from pypy.objspace.std.util import get_positive_index
-from rpython.rlib.objectmodel import import_from_mixin
-from rpython.rlib.rstring import StringBuilder
 
+NON_HEX_MSG = non-hexadecimal number found in fromhex() arg at position %d
 
-def _make_data(s):
-return [s[i] for i in range(len(s))]
 
 class W_BytearrayObject(W_Root):
 import_from_mixin(StringMethods)
@@ -24,7 +25,7 @@
 w_self.data = data
 
 def __repr__(w_self):
- representation for debugging purposes 
+representation for debugging purposes
 return %s(%s) % (w_self.__class__.__name__, ''.join(w_self.data))
 
 def _new(self, value):
@@ -126,11 +127,6 @@
 
 @staticmethod
 def descr_fromhex(space, w_bytearraytype, w_hexstring):
-bytearray.fromhex(string) - bytearray\n
-\n
-Create a bytearray object from a string of hexadecimal numbers.\n
-Spaces between two numbers are accepted.\n
-Example: bytearray.fromhex('B9 01EF') - 
bytearray(b'\\xb9\\x01\\xef').
 if not space.is_w(space.type(w_hexstring), space.w_unicode):
 raise operationerrfmt(space.w_TypeError, must be str, not %T,
   w_hexstring)
@@ -168,8 +164,8 @@
 elif not '\x20' = c  '\x7f':
 n = ord(c)
 buf.append('\\x')
-buf.append(0123456789abcdef[n4])
-buf.append(0123456789abcdef[n0xF])
+buf.append(0123456789abcdef[n  4])
+buf.append(0123456789abcdef[n  0xF])
 else:
 buf.append(c)
 
@@ -185,51 +181,60 @@
 
 def descr_eq(self, space, w_other):
 try:
-return space.newbool(self._val(space) == self._op_val(space, 
w_other))
-except OperationError, e:
+res = self._val(space) == self._op_val(space, w_other)
+except OperationError as e:
 if e.match(space, space.w_TypeError):
 return space.w_NotImplemented
 raise
+return space.newbool(res)
 
 def descr_ne(self, space, w_other):
 try:
-return space.newbool(self._val(space) != self._op_val(space, 
w_other))
-except OperationError, e:
+res 

[pypy-commit] pypy py3k: merge default

2014-01-24 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r68931:021856169522
Date: 2014-01-24 17:20 -0800
http://bitbucket.org/pypy/pypy/changeset/021856169522/

Log:merge default

diff --git a/pypy/objspace/std/unicodeobject.py 
b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -362,9 +362,9 @@
 elif space.isinstance_w(w_newval, space.w_int):
 newval = space.int_w(w_newval)
 if newval  0 or newval  maxunicode:
-msg = (character mapping must be in range(0x%x) %
-   (maxunicode + 1,))
-raise operationerrfmt(space.w_TypeError, msg)
+raise operationerrfmt(space.w_TypeError,
+  character mapping must be in 
+  range(%s), hex(maxunicode + 1))
 result.append(unichr(newval))
 elif space.isinstance_w(w_newval, space.w_unicode):
 result.append(space.unicode_w(w_newval))
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: merge default (6cbefcec4ceb)

2014-01-23 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r68867:6ebf49c04a51
Date: 2014-01-21 11:42 -0800
http://bitbucket.org/pypy/pypy/changeset/6ebf49c04a51/

Log:merge default (6cbefcec4ceb)

diff --git a/pypy/doc/project-ideas.rst b/pypy/doc/project-ideas.rst
--- a/pypy/doc/project-ideas.rst
+++ b/pypy/doc/project-ideas.rst
@@ -74,6 +74,10 @@
 The actual details would be rather differen in PyPy, but we would like to have
 the same optimization implemented.
 
+Or maybe not.  We can also play around with the idea of using a single
+representation: as a byte string in utf-8.  (This idea needs some extra logic
+for efficient indexing, like a cache.)
+
 .. _`optimized unicode representation`: 
http://www.python.org/dev/peps/pep-0393/
 
 Translation Toolchain
diff --git a/pypy/goal/getnightly.py b/pypy/goal/getnightly.py
--- a/pypy/goal/getnightly.py
+++ b/pypy/goal/getnightly.py
@@ -26,7 +26,12 @@
 if branch == 'default':
 branch = 'trunk'
 
-filename = 'pypy-c-jit-latest-%s.tar.bz2' % arch
+if '--nojit' in sys.argv:
+kind = 'nojit'
+else:
+kind = 'jit'
+
+filename = 'pypy-c-%s-latest-%s.tar.bz2' % (kind, arch)
 url = 'http://buildbot.pypy.org/nightly/%s/%s' % (branch, filename)
 tmp = py.path.local.mkdtemp()
 mydir = tmp.chdir()
diff --git a/pypy/interpreter/astcompiler/codegen.py 
b/pypy/interpreter/astcompiler/codegen.py
--- a/pypy/interpreter/astcompiler/codegen.py
+++ b/pypy/interpreter/astcompiler/codegen.py
@@ -1243,6 +1243,8 @@
 flags |= consts.CO_NESTED
 if scope.is_generator:
 flags |= consts.CO_GENERATOR
+if scope.has_yield_inside_try:
+flags |= consts.CO_YIELD_INSIDE_TRY
 if scope.has_variable_arg:
 flags |= consts.CO_VARARGS
 if scope.has_keywords_arg:
diff --git a/pypy/interpreter/astcompiler/consts.py 
b/pypy/interpreter/astcompiler/consts.py
--- a/pypy/interpreter/astcompiler/consts.py
+++ b/pypy/interpreter/astcompiler/consts.py
@@ -18,6 +18,7 @@
 CO_FUTURE_BARRY_AS_BDFL = 0x4
 #pypy specific:
 CO_KILL_DOCSTRING = 0x10
+CO_YIELD_INSIDE_TRY = 0x20
 
 PyCF_MASK = (CO_FUTURE_DIVISION | CO_FUTURE_ABSOLUTE_IMPORT |
  CO_FUTURE_WITH_STATEMENT | CO_FUTURE_PRINT_FUNCTION |
diff --git a/pypy/interpreter/astcompiler/symtable.py 
b/pypy/interpreter/astcompiler/symtable.py
--- a/pypy/interpreter/astcompiler/symtable.py
+++ b/pypy/interpreter/astcompiler/symtable.py
@@ -43,6 +43,7 @@
 self.child_has_free = False
 self.nested = False
 self.doc_removable = False
+self._in_try_body_depth = 0
 
 def lookup(self, name):
 Find the scope of identifier 'name'.
@@ -75,6 +76,14 @@
 self.varnames.append(mangled)
 return mangled
 
+def note_try_start(self, try_node):
+Called when a try is found, before visiting the body.
+self._in_try_body_depth += 1
+
+def note_try_end(self, try_node):
+Called after visiting a try body.
+self._in_try_body_depth -= 1
+
 def note_yield(self, yield_node):
 Called when a yield is found.
 raise SyntaxError('yield' outside function, yield_node.lineno,
@@ -223,6 +232,7 @@
 self.has_variable_arg = False
 self.has_keywords_arg = False
 self.is_generator = False
+self.has_yield_inside_try = False
 self.optimized = True
 self.return_with_value = False
 self.import_star = None
@@ -238,6 +248,8 @@
 raise SyntaxError('return' with argument inside generator,
   self.ret.lineno, self.ret.col_offset)
 self.is_generator = True
+if self._in_try_body_depth  0:
+self.has_yield_inside_try = True
 
 def note_return(self, ret):
 if ret.value:
@@ -489,7 +501,12 @@
 self.scope.new_temporary_name()
 if wih.optional_vars:
 self.scope.new_temporary_name()
-ast.GenericASTVisitor.visit_With(self, wih)
+wih.context_expr.walkabout(self)
+if wih.optional_vars:
+wih.optional_vars.walkabout(self)
+self.scope.note_try_start(wih)
+self.visit_sequence(wih.body)
+self.scope.note_try_end(wih)
 
 def visit_arguments(self, arguments):
 scope = self.scope
@@ -535,3 +552,16 @@
 else:
 role = SYM_ASSIGNED
 self.note_symbol(name.id, role)
+
+def visit_TryExcept(self, node):
+self.scope.note_try_start(node)
+self.visit_sequence(node.body)
+self.scope.note_try_end(node)
+self.visit_sequence(node.handlers)
+self.visit_sequence(node.orelse)
+
+def visit_TryFinally(self, node):
+self.scope.note_try_start(node)
+self.visit_sequence(node.body)
+self.scope.note_try_end(node)
+self.visit_sequence(node.finalbody)
diff --git a/pypy/interpreter/astcompiler/test/test_symtable.py 
b/pypy/interpreter/astcompiler/test/test_symtable.py
--- 

[pypy-commit] pypy py3k: merge default

2014-01-14 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r68672:60112abc6c12
Date: 2014-01-14 13:36 -0800
http://bitbucket.org/pypy/pypy/changeset/60112abc6c12/

Log:merge default

diff --git a/lib-python/2.7/test/test_ssl.py b/lib-python/2.7/test/test_ssl.py
--- a/lib-python/2.7/test/test_ssl.py
+++ b/lib-python/2.7/test/test_ssl.py
@@ -993,7 +993,7 @@
 try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True)
 try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, 
ssl.CERT_OPTIONAL)
 try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, 
ssl.CERT_REQUIRED)
-try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, True)
+try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, False)
 try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv3, False)
 try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_TLSv1, False)
 
diff --git a/lib-python/conftest.py b/lib-python/conftest.py
--- a/lib-python/conftest.py
+++ b/lib-python/conftest.py
@@ -107,7 +107,7 @@
 RegrTest('test_asynchat.py', usemodules='select fcntl'),
 RegrTest('test_asyncore.py', usemodules='select fcntl'),
 RegrTest('test_atexit.py', core=True),
-RegrTest('test_audioop.py', skip=unsupported extension module),
+RegrTest('test_audioop.py', skip=incomplete module),
 RegrTest('test_augassign.py', core=True),
 RegrTest('test_base64.py', usemodules='struct'),
 RegrTest('test_bigaddrspace.py'),
diff --git a/lib_pypy/_ctypes/array.py b/lib_pypy/_ctypes/array.py
--- a/lib_pypy/_ctypes/array.py
+++ b/lib_pypy/_ctypes/array.py
@@ -21,10 +21,13 @@
 # we don't want to have buffers here
 if len(val)  self._length_:
 raise ValueError(%r too long % (val,))
-for i in range(len(val)):
-self[i] = val[i]
+if isinstance(val, str):
+_rawffi.rawstring2charp(self._buffer.buffer, val)
+else:
+for i in range(len(val)):
+self[i] = val[i]
 if len(val)  self._length_:
-self[len(val)] = b'\x00'
+self._buffer[len(val)] = b'\x00'
 res.value = property(getvalue, setvalue)
 
 def getraw(self):
@@ -34,8 +37,7 @@
 def setraw(self, buffer):
 if len(buffer)  self._length_:
 raise ValueError(%r too long % (buffer,))
-for i in range(len(buffer)):
-self[i] = buffer[i]
+_rawffi.rawstring2charp(self._buffer.buffer, buffer)
 res.raw = property(getraw, setraw)
 elif subletter == 'u':
 def getvalue(self):
@@ -46,10 +48,14 @@
 # we don't want to have buffers here
 if len(val)  self._length_:
 raise ValueError(%r too long % (val,))
+if isinstance(val, str):
+target = self._buffer
+else:
+target = self
 for i in range(len(val)):
-self[i] = val[i]
+target[i] = val[i]
 if len(val)  self._length_:
-self[len(val)] = '\x00'
+target[len(val)] = '\x00'
 res.value = property(getvalue, setvalue)
 
 res._ffishape = (ffiarray, res._length_)
diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -330,6 +330,14 @@
 # SQLite version information
 sqlite_version = str(_ffi.string(_lib.sqlite3_libversion()).decode('ascii'))
 
+_STMT_TYPE_UPDATE = 0
+_STMT_TYPE_DELETE = 1
+_STMT_TYPE_INSERT = 2
+_STMT_TYPE_REPLACE = 3
+_STMT_TYPE_OTHER = 4
+_STMT_TYPE_SELECT = 5
+_STMT_TYPE_INVALID = 6
+
 
 class Error(StandardError):
 pass
@@ -1004,13 +1012,18 @@
 self.__statement = self.__connection._statement_cache.get(sql)
 
 if self.__connection._isolation_level is not None:
-if self.__statement._type in (UPDATE, DELETE, INSERT, 
REPLACE):
+if self.__statement._type in (
+_STMT_TYPE_UPDATE,
+_STMT_TYPE_DELETE,
+_STMT_TYPE_INSERT,
+_STMT_TYPE_REPLACE
+):
 if not self.__connection._in_transaction:
 self.__connection._begin()
-elif self.__statement._type == OTHER:
+elif self.__statement._type == _STMT_TYPE_OTHER:
 if self.__connection._in_transaction:
 self.__connection.commit()
-elif self.__statement._type == SELECT:
+elif self.__statement._type == _STMT_TYPE_SELECT:
 if multiple:
 raise ProgrammingError(You cannot 

[pypy-commit] pypy py3k: merge default

2014-01-03 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r68581:733bf19dd5a5
Date: 2014-01-03 15:46 -0800
http://bitbucket.org/pypy/pypy/changeset/733bf19dd5a5/

Log:merge default

diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -28,7 +28,7 @@
 DEALINGS IN THE SOFTWARE.
 
 
-PyPy Copyright holders 2003-2013
+PyPy Copyright holders 2003-2014
 --- 
 
 Except when otherwise stated (look for LICENSE files or information at
diff --git a/pypy/doc/conf.py b/pypy/doc/conf.py
--- a/pypy/doc/conf.py
+++ b/pypy/doc/conf.py
@@ -38,7 +38,7 @@
 
 # General information about the project.
 project = u'PyPy'
-copyright = u'2013, The PyPy Project'
+copyright = u'2014, The PyPy Project'
 
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the
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
@@ -39,3 +39,5 @@
 
 .. branch: 
OlivierBlanvillain/fix-3-broken-links-on-pypy-published-pap-1386250839215
 Fix 3 broken links on PyPy published papers in docs.
+
+.. branch: jit-ordereddict
diff --git a/pypy/module/sys/app.py b/pypy/module/sys/app.py
--- a/pypy/module/sys/app.py
+++ b/pypy/module/sys/app.py
@@ -69,11 +69,11 @@
 return None
 
 copyright_str = 
-Copyright 2003-2013 PyPy development team.
+Copyright 2003-2014 PyPy development team.
 All Rights Reserved.
 For further information, see http://pypy.org
 
-Portions Copyright (c) 2001-2013 Python Software Foundation.
+Portions Copyright (c) 2001-2014 Python Software Foundation.
 All Rights Reserved.
 
 Portions Copyright (c) 2000 BeOpen.com.
diff --git a/rpython/jit/metainterp/test/test_dict.py 
b/rpython/jit/metainterp/test/test_dict.py
--- a/rpython/jit/metainterp/test/test_dict.py
+++ b/rpython/jit/metainterp/test/test_dict.py
@@ -5,6 +5,10 @@
 from collections import OrderedDict
 
 class DictTests:
+@staticmethod
+def newdict():   # overridden in TestLLOrderedDict
+return {}
+
 def _freeze_(self):
 return True
 
@@ -191,9 +195,7 @@
 
 
 class TestLLtype(DictTests, LLJitMixin):
-@staticmethod
-def newdict():
-return {}
+pass
 
 class TestLLOrderedDict(DictTests, LLJitMixin):
 @staticmethod
diff --git a/rpython/jit/metainterp/test/test_rawmem.py 
b/rpython/jit/metainterp/test/test_rawmem.py
--- a/rpython/jit/metainterp/test/test_rawmem.py
+++ b/rpython/jit/metainterp/test/test_rawmem.py
@@ -71,7 +71,11 @@
'raw_store': 1, 'raw_load': 1,
'finish': 1})
 
+
+class TestRawMem(RawMemTests, LLJitMixin):
+
 def test_getarraysubstruct(self):
+# NOTE: not for backend/*/test
 A2 = lltype.Array(('a', lltype.Signed), ('b', lltype.Signed),
   hints={'nolength': True})
 p = lltype.malloc(A2, 10, flavor='raw', immortal=True, zero=True)
@@ -90,6 +94,3 @@
 assert res == 66
 res = self.interp_operations(f, [2, 2], disable_optimizations=True)
 assert res == 44
-
-class TestRawMem(RawMemTests, LLJitMixin):
-pass
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: merge default

2013-12-19 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r68488:a2ebaff30cc5
Date: 2013-12-19 13:20 -0800
http://bitbucket.org/pypy/pypy/changeset/a2ebaff30cc5/

Log:merge default

diff --git a/lib-python/2.7/ctypes/__init__.py 
b/lib-python/2.7/ctypes/__init__.py
--- a/lib-python/2.7/ctypes/__init__.py
+++ b/lib-python/2.7/ctypes/__init__.py
@@ -371,10 +371,9 @@
 self._handle = handle
 
 def __repr__(self):
-return %s '%s', handle %r at %x % \
-   (self.__class__.__name__, self._name,
-(self._handle),
-id(self)  (_sys.maxint*2 + 1))
+return %s '%s', handle %r at 0x%x % (
+self.__class__.__name__, self._name, self._handle,
+id(self)  (_sys.maxint * 2 + 1))
 
 
 def __getattr__(self, name):
diff --git a/pypy/module/micronumpy/interp_dtype.py 
b/pypy/module/micronumpy/interp_dtype.py
--- a/pypy/module/micronumpy/interp_dtype.py
+++ b/pypy/module/micronumpy/interp_dtype.py
@@ -1,4 +1,3 @@
-import sys
 from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.interpreter.gateway import interp2app, unwrap_spec
diff --git a/pypy/module/micronumpy/interp_ufuncs.py 
b/pypy/module/micronumpy/interp_ufuncs.py
--- a/pypy/module/micronumpy/interp_ufuncs.py
+++ b/pypy/module/micronumpy/interp_ufuncs.py
@@ -498,13 +498,14 @@
 promote_bools=False, promote_to_largest=False):
 if promote_to_largest:
 if dt.kind == NPY_GENBOOLLTR or dt.kind == NPY_SIGNEDLTR:
-return interp_dtype.get_dtype_cache(space).w_int64dtype
+if dt.get_size() * 8  LONG_BIT:
+return interp_dtype.get_dtype_cache(space).w_longdtype
 elif dt.kind == NPY_UNSIGNEDLTR:
-return interp_dtype.get_dtype_cache(space).w_uint64dtype
-elif dt.kind == NPY_FLOATINGLTR or dt.kind == NPY_COMPLEXLTR:
-return dt
+if dt.get_size() * 8  LONG_BIT:
+return interp_dtype.get_dtype_cache(space).w_ulongdtype
 else:
-assert False
+assert dt.kind == NPY_FLOATINGLTR or dt.kind == NPY_COMPLEXLTR
+return dt
 if promote_bools and (dt.kind == NPY_GENBOOLLTR):
 return interp_dtype.get_dtype_cache(space).w_int8dtype
 if promote_to_float:
diff --git a/pypy/module/micronumpy/test/test_numarray.py 
b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -1400,16 +1400,18 @@
 assert (array([[1,2],[3,4]]).prod(1) == [2, 12]).all()
 
 def test_prod(self):
-from numpypy import array, int_, dtype
+from numpypy import array, dtype
 a = array(range(1, 6))
 assert a.prod() == 120.0
 assert a[:4].prod() == 24.0
-a = array([True, False])
-assert a.prod() == 0
-assert type(a.prod()) is int_
-a = array([True, False], dtype='uint')
-assert a.prod() == 0
-assert type(a.prod()) is dtype('uint').type
+for dt in ['bool', 'int8', 'uint8', 'int16', 'uint16']:
+a = array([True, False], dtype=dt)
+assert a.prod() == 0
+assert a.prod().dtype == dtype('uint' if dt[0] == 'u' else 'int')
+for dt in ['l', 'L', 'q', 'Q', 'e', 'f', 'd', 'F', 'D']:
+a = array([True, False], dtype=dt)
+assert a.prod() == 0
+assert a.prod().dtype == dtype(dt)
 
 def test_max(self):
 from numpypy import array, zeros
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: merge default

2013-12-18 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r68477:d37bd06f36fa
Date: 2013-12-18 15:47 -0800
http://bitbucket.org/pypy/pypy/changeset/d37bd06f36fa/

Log:merge default

diff --git a/lib_pypy/_sha1.py b/lib_pypy/_sha1.py
--- a/lib_pypy/_sha1.py
+++ b/lib_pypy/_sha1.py
@@ -115,14 +115,14 @@
 ]
 
 class sha:
-An implementation of the MD5 hash function in pure Python.
+An implementation of the SHA hash function in pure Python.
 
 digest_size = digestsize = 20
-block_size = 1
+block_size = 512 // 8
 
 def __init__(self):
 Initialisation.
-
+
 # Initial message length in bits(!).
 self.length = 0
 self.count = [0, 0]
@@ -209,7 +209,7 @@
 self.H2 = (self.H2 + C)  0x
 self.H3 = (self.H3 + D)  0x
 self.H4 = (self.H4 + E)  0x
-
+
 
 # Down from here all methods follow the Python Standard Library
 # API of the sha module.
@@ -298,13 +298,13 @@
  _long2bytesBigEndian(self.H3, 4) + \
  _long2bytesBigEndian(self.H4, 4)
 
-self.H0 = H0 
-self.H1 = H1 
+self.H0 = H0
+self.H1 = H1
 self.H2 = H2
 self.H3 = H3
 self.H4 = H4
-self.input = input 
-self.count = count 
+self.input = input
+self.count = count
 
 return digest
 
diff --git a/pypy/module/micronumpy/__init__.py 
b/pypy/module/micronumpy/__init__.py
--- a/pypy/module/micronumpy/__init__.py
+++ b/pypy/module/micronumpy/__init__.py
@@ -10,7 +10,7 @@
 'array': 'interp_numarray.array',
 'zeros': 'interp_numarray.zeros',
 'empty': 'interp_numarray.zeros',
-'ones': 'interp_numarray.ones',
+'empty_like': 'interp_numarray.empty_like',
 '_reconstruct' : 'interp_numarray._reconstruct',
 'scalar' : 'interp_numarray.build_scalar',
 'dot': 'interp_arrayops.dot',
@@ -106,8 +106,6 @@
 ('logaddexp2', 'logaddexp2'),
 ('real', 'real'),
 ('imag', 'imag'),
-('ones_like', 'ones_like'),
-('zeros_like', 'zeros_like'),
 ]:
 interpleveldefs[exposed] = interp_ufuncs.get(space).%s % impl
 
diff --git a/pypy/module/micronumpy/arrayimpl/concrete.py 
b/pypy/module/micronumpy/arrayimpl/concrete.py
--- a/pypy/module/micronumpy/arrayimpl/concrete.py
+++ b/pypy/module/micronumpy/arrayimpl/concrete.py
@@ -47,7 +47,7 @@
 def setslice(self, space, arr):
 impl = arr.implementation
 if impl.is_scalar():
-self.fill(impl.get_scalar_value())
+self.fill(space, impl.get_scalar_value())
 return
 shape = shape_agreement(space, self.get_shape(), arr)
 if impl.storage == self.storage:
@@ -100,7 +100,7 @@
 tmp = self.get_real(orig_array)
 tmp.setslice(space, convert_to_array(space, w_value))
 
-def get_imag(self, orig_array):
+def get_imag(self, space, orig_array):
 strides = self.get_strides()
 backstrides = self.get_backstrides()
 if self.dtype.is_complex_type():
@@ -110,11 +110,11 @@
 impl = NonWritableArray(self.get_shape(), self.dtype, self.order, 
strides,
  backstrides)
 if not self.dtype.is_flexible_type():
-impl.fill(self.dtype.box(0))
+impl.fill(space, self.dtype.box(0))
 return impl
 
 def set_imag(self, space, orig_array, w_value):
-tmp = self.get_imag(orig_array)
+tmp = self.get_imag(space, orig_array)
 tmp.setslice(space, convert_to_array(space, w_value))
 
 #  applevel get/setitem ---
@@ -357,7 +357,7 @@
  self.get_backstrides(),
  self.get_shape())
 
-def fill(self, box):
+def fill(self, space, box):
 self.dtype.itemtype.fill(self.storage, self.dtype.get_size(),
  box, 0, self.size, 0)
 
@@ -435,8 +435,8 @@
 def base(self):
 return self.orig_arr
 
-def fill(self, box):
-loop.fill(self, box.convert_to(self.dtype))
+def fill(self, space, box):
+loop.fill(self, box.convert_to(space, self.dtype))
 
 def create_iter(self, shape=None, backward_broadcast=False, 
require_index=False):
 if shape is not None and \
diff --git a/pypy/module/micronumpy/arrayimpl/scalar.py 
b/pypy/module/micronumpy/arrayimpl/scalar.py
--- a/pypy/module/micronumpy/arrayimpl/scalar.py
+++ b/pypy/module/micronumpy/arrayimpl/scalar.py
@@ -54,8 +54,7 @@
 return self.value
 
 def set_scalar_value(self, w_val):
-assert isinstance(w_val, W_GenericBox)
-self.value = w_val.convert_to(self.dtype)
+self.value = w_val
 
 def copy(self, space):
 scalar = Scalar(self.dtype)
@@ -96,12 +95,12 @@
 ','.join([str(x) for x in w_arr.get_shape()],
   

[pypy-commit] pypy py3k: merge default

2013-12-18 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r68475:c9fe258e0217
Date: 2013-12-18 15:40 -0800
http://bitbucket.org/pypy/pypy/changeset/c9fe258e0217/

Log:merge default

diff --git a/pypy/module/__builtin__/app_operation.py 
b/pypy/module/__builtin__/app_operation.py
--- a/pypy/module/__builtin__/app_operation.py
+++ b/pypy/module/__builtin__/app_operation.py
@@ -2,8 +2,8 @@
 
 def bin(x):
 Return the binary representation of an integer.
-x = operator.index(x)
-return x.__format__(#b)
+value = operator.index(x)
+return value.__format__(#b)
 
 def oct(x):
 Return the octal representation of an integer.
diff --git a/pypy/module/__builtin__/test/test_builtin.py 
b/pypy/module/__builtin__/test/test_builtin.py
--- a/pypy/module/__builtin__/test/test_builtin.py
+++ b/pypy/module/__builtin__/test/test_builtin.py
@@ -84,6 +84,15 @@
 assert bin(-2) == -0b10
 assert bin(Foo()) == 0b100
 raises(TypeError, bin, 0.)
+class C(object):
+def __index__(self):
+return 42
+assert bin(C()) == bin(42)
+class D(object):
+def __int__(self):
+return 42
+exc = raises(TypeError, bin, D())
+assert index in exc.value.message
 
 def test_oct(self):
 class Foo:
diff --git a/pypy/module/_cffi_backend/cbuffer.py 
b/pypy/module/_cffi_backend/cbuffer.py
--- a/pypy/module/_cffi_backend/cbuffer.py
+++ b/pypy/module/_cffi_backend/cbuffer.py
@@ -5,7 +5,9 @@
 from pypy.interpreter.typedef import TypeDef, make_weakref_descr
 from pypy.module._cffi_backend import cdataobj, ctypeptr, ctypearray
 
+from rpython.rtyper.annlowlevel import llstr
 from rpython.rtyper.lltypesystem import rffi
+from rpython.rtyper.lltypesystem.rstr import copy_string_to_raw
 
 
 class LLBuffer(RWBuffer):
@@ -34,8 +36,7 @@
 
 def setslice(self, start, string):
 raw_cdata = rffi.ptradd(self.raw_cdata, start)
-for i in range(len(string)):
-raw_cdata[i] = string[i]
+copy_string_to_raw(llstr(string), raw_cdata, 0, len(string))
 
 
 class MiniBuffer(W_Root):
diff --git a/pypy/module/_cffi_backend/cdataobj.py 
b/pypy/module/_cffi_backend/cdataobj.py
--- a/pypy/module/_cffi_backend/cdataobj.py
+++ b/pypy/module/_cffi_backend/cdataobj.py
@@ -206,8 +206,7 @@
 w_value.get_array_length() == length):
 # fast path: copying from exactly the correct type
 s = w_value._cdata
-for i in range(ctitemsize * length):
-cdata[i] = s[i]
+rffi.c_memcpy(cdata, s, ctitemsize * length)
 keepalive_until_here(w_value)
 return
 #
@@ -259,7 +258,6 @@
 space = self.space
 if isinstance(w_other, W_CData):
 from pypy.module._cffi_backend import ctypeptr, ctypearray
-from pypy.module._cffi_backend import ctypevoid
 ct = w_other.ctype
 if isinstance(ct, ctypearray.W_CTypeArray):
 ct = ct.ctptr
diff --git a/pypy/module/math/app_math.py b/pypy/module/math/app_math.py
--- a/pypy/module/math/app_math.py
+++ b/pypy/module/math/app_math.py
@@ -1,7 +1,9 @@
 import sys
 
 def factorial(x):
-Find x!.
+factorial(x) - Integral
+
+Find x!. Raise a ValueError if x is negative or non-integral.
 if isinstance(x, float):
 fl = int(x)
 if fl != x:
@@ -18,15 +20,15 @@
 res *= i
 return res
 
-#Experimentally this gap seems good
-gap = max(100, x7)
+# Experimentally this gap seems good
+gap = max(100, x  7)
 def _fac_odd(low, high):
-if low+gap = high:
+if low + gap = high:
 t = 1
 for i in range(low, high, 2):
 t *= i
 return t
-
+
 mid = ((low + high)  1) | 1
 return _fac_odd(low, mid) * _fac_odd(mid, high)
 
diff --git a/pypy/module/micronumpy/arrayimpl/concrete.py 
b/pypy/module/micronumpy/arrayimpl/concrete.py
--- a/pypy/module/micronumpy/arrayimpl/concrete.py
+++ b/pypy/module/micronumpy/arrayimpl/concrete.py
@@ -502,3 +502,6 @@
 
 def getlength(self):
 return self.impl.size
+
+def get_raw_address(self):
+return self.impl.storage
diff --git a/pypy/module/micronumpy/arrayimpl/scalar.py 
b/pypy/module/micronumpy/arrayimpl/scalar.py
--- a/pypy/module/micronumpy/arrayimpl/scalar.py
+++ b/pypy/module/micronumpy/arrayimpl/scalar.py
@@ -132,6 +132,12 @@
 if space.isinstance_w(w_idx, space.w_tuple):
 if space.len_w(w_idx) == 0:
 return self.get_scalar_value()
+if space.is_none(w_idx):
+new_shape = [1]
+arr = W_NDimArray.from_shape(space, new_shape, self.dtype)
+arr_iter = arr.create_iter(new_shape)
+arr_iter.setitem(self.value)
+return arr
 raise OperationError(space.w_IndexError,

[pypy-commit] pypy py3k: merge default

2013-11-25 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r68322:a0f4678afc88
Date: 2013-11-20 11:22 -0800
http://bitbucket.org/pypy/pypy/changeset/a0f4678afc88/

Log:merge default

diff --git a/rpython/annotator/unaryop.py b/rpython/annotator/unaryop.py
--- a/rpython/annotator/unaryop.py
+++ b/rpython/annotator/unaryop.py
@@ -460,13 +460,13 @@
 check_negative_slice(start, end, count)
 return SomeInteger(nonneg=True)
 
-def method_strip(str, chr):
+def method_strip(str, chr=None):
 return str.basestringclass(no_nul=str.no_nul)
 
-def method_lstrip(str, chr):
+def method_lstrip(str, chr=None):
 return str.basestringclass(no_nul=str.no_nul)
 
-def method_rstrip(str, chr):
+def method_rstrip(str, chr=None):
 return str.basestringclass(no_nul=str.no_nul)
 
 def method_join(str, s_list):
diff --git a/rpython/rtyper/lltypesystem/rstr.py 
b/rpython/rtyper/lltypesystem/rstr.py
--- a/rpython/rtyper/lltypesystem/rstr.py
+++ b/rpython/rtyper/lltypesystem/rstr.py
@@ -9,6 +9,7 @@
 from rpython.rlib.rarithmetic import ovfcheck
 from rpython.rtyper.error import TyperError
 from rpython.rtyper.lltypesystem import ll_str, llmemory
+from rpython.rtyper.lltypesystem.lloperation import llop
 from rpython.rtyper.lltypesystem.lltype import (GcStruct, Signed, Array, Char,
 UniChar, Ptr, malloc, Bool, Void, GcArray, nullptr, cast_primitive,
 typeOf, staticAdtMethod, GcForwardReference)
@@ -402,6 +403,46 @@
 return result
 
 @jit.elidable
+def ll_strip_default(s, left, right):
+s_len = len(s.chars)
+if s_len == 0:
+return s.empty()
+lpos = 0
+rpos = s_len - 1
+if left:
+while lpos  rpos and s.chars[lpos].isspace():
+lpos += 1
+if right:
+while lpos  rpos + 1 and s.chars[rpos].isspace():
+rpos -= 1
+if rpos  lpos:
+return s.empty()
+r_len = rpos - lpos + 1
+result = s.malloc(r_len)
+s.copy_contents(s, result, lpos, 0, r_len)
+return result
+
+@jit.elidable
+def ll_strip_multiple(s, s2, left, right):
+s_len = len(s.chars)
+if s_len == 0:
+return s.empty()
+lpos = 0
+rpos = s_len - 1
+if left:
+while lpos  rpos and LLHelpers.ll_contains(s2, s.chars[lpos]):
+lpos += 1
+if right:
+while lpos  rpos + 1 and LLHelpers.ll_contains(s2, s.chars[rpos]):
+rpos -= 1
+if rpos  lpos:
+return s.empty()
+r_len = rpos - lpos + 1
+result = s.malloc(r_len)
+s.copy_contents(s, result, lpos, 0, r_len)
+return result
+
+@jit.elidable
 def ll_upper(s):
 s_chars = s.chars
 s_len = len(s_chars)
diff --git a/rpython/rtyper/rstr.py b/rpython/rtyper/rstr.py
--- a/rpython/rtyper/rstr.py
+++ b/rpython/rtyper/rstr.py
@@ -231,11 +231,22 @@
 def rtype_method_strip(self, hop, left=True, right=True):
 rstr = hop.args_r[0].repr
 v_str = hop.inputarg(rstr.repr, arg=0)
-v_char = hop.inputarg(rstr.char_repr, arg=1)
-v_left = hop.inputconst(Bool, left)
-v_right = hop.inputconst(Bool, right)
+args_v = [v_str]
+if len(hop.args_s) == 2:
+if isinstance(hop.args_s[1], annmodel.SomeString):
+v_stripstr = hop.inputarg(rstr.repr, arg=1)
+args_v.append(v_stripstr)
+func = self.ll.ll_strip_multiple
+else:
+v_char = hop.inputarg(rstr.char_repr, arg=1)
+args_v.append(v_char)
+func = self.ll.ll_strip
+else:
+func = self.ll.ll_strip_default
+args_v.append(hop.inputconst(Bool, left))
+args_v.append(hop.inputconst(Bool, right))
 hop.exception_is_here()
-return hop.gendirectcall(self.ll.ll_strip, v_str, v_char, v_left, 
v_right)
+return hop.gendirectcall(func, *args_v)
 
 def rtype_method_lstrip(self, hop):
 return self.rtype_method_strip(hop, left=True, right=False)
diff --git a/rpython/rtyper/test/test_rstr.py b/rpython/rtyper/test/test_rstr.py
--- a/rpython/rtyper/test/test_rstr.py
+++ b/rpython/rtyper/test/test_rstr.py
@@ -9,6 +9,7 @@
 from rpython.rtyper.rstr import AbstractLLHelpers
 from rpython.rtyper.rtyper import TyperError
 from rpython.rtyper.test.tool import BaseRtypingTest
+from rpython.rtyper.annlowlevel import llstr, hlstr
 
 
 def test_parse_fmt():
@@ -457,6 +458,29 @@
 res = self.interpret(left2, [])
 assert self.ll_to_string(res) == const('a')
 
+def test_strip_multiple_chars(self):
+const = self.const
+def both():
+return const('!ab!').strip(const('!a'))
+def left():
+return const('!+ab!').lstrip(const('!+'))
+def right():
+return const('!ab!+').rstrip(const('!+'))
+

[pypy-commit] pypy py3k: merge default

2013-11-25 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r68324:0e2516a31328
Date: 2013-11-25 15:08 -0800
http://bitbucket.org/pypy/pypy/changeset/0e2516a31328/

Log:merge default

diff --git a/lib-python/2.7/socket.py b/lib-python/2.7/socket.py
--- a/lib-python/2.7/socket.py
+++ b/lib-python/2.7/socket.py
@@ -335,9 +335,10 @@
 s = self._sock
 self._sock = None
 if s is not None:
-s._drop()
 if self._close:
 s.close()
+else:
+s._drop()
 
 def __del__(self):
 try:
diff --git a/lib_pypy/pyrepl/simple_interact.py 
b/lib_pypy/pyrepl/simple_interact.py
--- a/lib_pypy/pyrepl/simple_interact.py
+++ b/lib_pypy/pyrepl/simple_interact.py
@@ -67,3 +67,6 @@
 except KeyboardInterrupt:
 console.write(\nKeyboardInterrupt\n)
 console.resetbuffer()
+except MemoryError:
+console.write(\nMemoryError\n)
+console.resetbuffer()
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,3 +15,6 @@
 
 .. branch: armhf-singlefloat
 JIT support for singlefloats on ARM using the hardfloat ABI
+
+.. branch: voidtype_strformat
+Better support for record numpy arrays
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -25,6 +25,7 @@
 from pypy.objspace.std.sliceobject import W_SliceObject
 from pypy.module.__builtin__.descriptor import W_Property
 from pypy.module.__builtin__.interp_memoryview import W_MemoryView
+from pypy.module.micronumpy.base import W_NDimArray
 from rpython.rlib.entrypoint import entrypoint_lowlevel
 from rpython.rlib.rposix import is_valid_fd, validate_fd
 from rpython.rlib.unroll import unrolling_iterable
@@ -470,6 +471,7 @@
 Complex: space.w_complex,
 ByteArray: space.w_bytearray,
 MemoryView: space.gettypeobject(W_MemoryView.typedef),
+Array: space.gettypeobject(W_NDimArray.typedef),
 BaseObject: space.w_object,
 'None': 'space.type(space.w_None)',
 'NotImplemented': 'space.type(space.w_NotImplemented)',
diff --git a/pypy/module/cpyext/include/pyconfig.h 
b/pypy/module/cpyext/include/pyconfig.h
--- a/pypy/module/cpyext/include/pyconfig.h
+++ b/pypy/module/cpyext/include/pyconfig.h
@@ -29,6 +29,22 @@
 #define VA_LIST_IS_ARRAY
 #endif
 
+#ifndef Py_BUILD_CORE /* not building the core - must be an ext */
+#if defined(_MSC_VER)
+ /* So MSVC users need not specify the .lib file in
+  * their Makefile (other compilers are generally
+  * taken care of by distutils.) */
+#ifdef _DEBUG
+#error(debug first with cpython)
+#pragma comment(lib,python27.lib)
+#else
+#pragma comment(lib,python27.lib)
+#endif /* _DEBUG */
+#endif
+#endif /* _MSC_VER */
+
+
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/pypy/module/cpyext/src/ndarrayobject.c 
b/pypy/module/cpyext/src/ndarrayobject.c
--- a/pypy/module/cpyext/src/ndarrayobject.c
+++ b/pypy/module/cpyext/src/ndarrayobject.c
@@ -3,8 +3,6 @@
 #include numpy/arrayobject.h
 #include string.h   /* memset, memcpy */
 
-PyTypeObject PyArray_Type;
-
 void 
 _PyArray_FILLWBYTE(PyObject* obj, int val) {
 memset(PyArray_DATA(obj), val, PyArray_NBYTES(obj));
diff --git a/pypy/module/cpyext/test/test_ndarrayobject.py 
b/pypy/module/cpyext/test/test_ndarrayobject.py
--- a/pypy/module/cpyext/test/test_ndarrayobject.py
+++ b/pypy/module/cpyext/test/test_ndarrayobject.py
@@ -286,3 +286,19 @@
 assert dt.num == 11
 
 
+def test_pass_ndarray_object_to_c(self):
+from _numpypy.multiarray import ndarray
+mod = self.import_extension('foo', [
+(check_array, METH_VARARGS,
+'''
+PyObject* obj;
+if (!PyArg_ParseTuple(args, O!, PyArray_Type, obj))
+return NULL;
+Py_INCREF(obj);
+return obj;
+'''),
+], prologue='#include numpy/arrayobject.h')
+array = ndarray((3, 4), dtype='d')
+assert mod.check_array(array) is array
+raises(TypeError, mod.check_array(42))
+
diff --git a/pypy/module/itertools/interp_itertools.py 
b/pypy/module/itertools/interp_itertools.py
--- a/pypy/module/itertools/interp_itertools.py
+++ b/pypy/module/itertools/interp_itertools.py
@@ -288,10 +288,8 @@
 if space.is_w(w_startstop, space.w_None):
 start = 0
 else:
-start = space.int_w(w_startstop)
-if start  0:
-raise OperationError(space.w_ValueError, space.wrap(
-   Indicies for islice() must be non-negative integers.))
+start = self.arg_int_w(w_startstop, 0,
+ 

[pypy-commit] pypy py3k: merge default

2013-11-19 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r68255:6331cf185f84
Date: 2013-11-19 17:44 -0800
http://bitbucket.org/pypy/pypy/changeset/6331cf185f84/

Log:merge default

diff --git a/lib-python/2.7/test/test_multiprocessing.py 
b/lib-python/2.7/test/test_multiprocessing.py
--- a/lib-python/2.7/test/test_multiprocessing.py
+++ b/lib-python/2.7/test/test_multiprocessing.py
@@ -1,5 +1,10 @@
 #!/usr/bin/env python
 
+## FIXME: remove when https://bugs.pypy.org/issue1644 is resolved
+import sys
+if sys.platform.startswith('freebsd'):
+raise Exception(This test hangs on FreeBSD. Test deactivated for now 
until https://bugs.pypy.org/issue1644 get resolved)
+
 #
 # Unit tests for the multiprocessing package
 #
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
@@ -10,6 +10,8 @@
 .. branch: numpy-newbyteorder
 Clean up numpy types, add newbyteorder functionality
 
-.. branch windows-packaging
+.. branch: windows-packaging
 Package tk/tcl runtime with win32
 
+.. branch: armhf-singlefloat
+JIT support for singlefloats on ARM using the hardfloat ABI
diff --git a/pypy/module/micronumpy/interp_dtype.py 
b/pypy/module/micronumpy/interp_dtype.py
--- a/pypy/module/micronumpy/interp_dtype.py
+++ b/pypy/module/micronumpy/interp_dtype.py
@@ -151,6 +151,14 @@
 endian = NPY_NATBYTE
 return space.wrap(%s%s%s % (endian, basic, size))
 
+def descr_get_descr(self, space):
+if not self.is_record_type():
+return space.newlist([space.newtuple([space.wrap(),
+  self.descr_get_str(space)])])
+else:
+raise OperationError(space.w_NotImplementedError, space.wrap(
+descr not implemented for record types))
+
 def descr_get_base(self, space):
 return space.wrap(self.base)
 
@@ -448,6 +456,7 @@
 fields = GetSetProperty(W_Dtype.descr_get_fields),
 names = GetSetProperty(W_Dtype.descr_get_names),
 hasobject = GetSetProperty(W_Dtype.descr_get_hasobject),
+descr = GetSetProperty(W_Dtype.descr_get_descr),
 )
 W_Dtype.typedef.acceptable_as_base_class = False
 
diff --git a/pypy/module/micronumpy/interp_numarray.py 
b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -93,7 +93,11 @@
 def descr_fill(self, space, w_value):
 self.fill(self.get_dtype().coerce(space, w_value))
 
-def descr_tostring(self, space):
+def descr_tostring(self, space, w_order=None):
+order = order_converter(space, w_order, NPY_CORDER)
+if order == NPY_FORTRANORDER:
+raise OperationError(space.w_NotImplementedError, space.wrap(
+unsupported value for order))
 return space.wrap(loop.tostring(space, self))
 
 def getitem_filter(self, space, arr):
diff --git a/pypy/module/micronumpy/test/test_dtypes.py 
b/pypy/module/micronumpy/test/test_dtypes.py
--- a/pypy/module/micronumpy/test/test_dtypes.py
+++ b/pypy/module/micronumpy/test/test_dtypes.py
@@ -831,6 +831,17 @@
 assert x.dtype == int8
 assert (x == array(42)).all()
 
+def test_descr(self):
+import numpy as np
+assert np.dtype('i8').descr == [('', 'i8')]
+assert np.dtype('|S4').descr == [('', '|S4')]
+d = [('test', 'i8'), ('blah', 'i2', (2, 3))]
+import sys
+if '__pypy__' in sys.builtin_module_names:
+raises(NotImplementedError, np.dtype(d).descr)
+else:
+assert np.dtype(d).descr == d
+
 class AppTestStrUnicodeDtypes(BaseNumpyAppTest):
 def test_mro(self):
 from numpypy import str_, unicode_, character, flexible, generic
diff --git a/pypy/module/micronumpy/test/test_numarray.py 
b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -68,7 +68,8 @@
 assert s.start == 1
 assert s.strides == [2, 10, 50]
 assert s.backstrides == [6, 40, 100]
-s = create_slice(self.space, a, [Chunk(1, 5, 3, 2), Chunk(1, 2, 1, 1), 
Chunk(1, 0, 0, 1)])
+s = create_slice(self.space, a, [Chunk(1, 5, 3, 2), Chunk(1, 2, 1, 1),
+ Chunk(1, 0, 0, 1)])
 assert s.shape == [2, 1]
 assert s.strides == [3, 10]
 assert s.backstrides == [3, 0]
@@ -2043,7 +2044,8 @@
 a = array([1, 2], dtype=int64)
 data = a.__reduce__()
 
-assert data[2][4] == 
'\x01\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00'
+assert data[2][4] == '\x01\x00\x00\x00\x00\x00\x00\x00' \
+ '\x02\x00\x00\x00\x00\x00\x00\x00'
 
 pickled_data = dumps(a)
 assert (loads(pickled_data) == a).all()
@@ -2791,9 +2793,11 @@
 assert k[0] == dtype('float16').type(5.)
 

[pypy-commit] pypy py3k: merge default

2013-10-07 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r67186:7cd5f50e628b
Date: 2013-10-07 12:18 -0700
http://bitbucket.org/pypy/pypy/changeset/7cd5f50e628b/

Log:merge default

diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -363,9 +363,11 @@
 pass
 
 
-def connect(database, **kwargs):
-factory = kwargs.get(factory, Connection)
-return factory(database, **kwargs)
+def connect(database, timeout=5.0, detect_types=0, isolation_level=,
+ check_same_thread=True, factory=None, cached_statements=100):
+factory = Connection if not factory else factory
+return factory(database, timeout, detect_types, isolation_level,
+check_same_thread, factory, cached_statements)
 
 
 def _unicode_text_factory(x):
diff --git a/lib_pypy/_tkinter/tclobj.py b/lib_pypy/_tkinter/tclobj.py
--- a/lib_pypy/_tkinter/tclobj.py
+++ b/lib_pypy/_tkinter/tclobj.py
@@ -22,9 +22,11 @@
 return result
 
 elif value.typePtr == typeCache.BooleanType:
-return result
+return bool(value.internalRep.longValue)
 elif value.typePtr == typeCache.ByteArrayType:
-return result
+size = tkffi.new('int*')
+data = tklib.Tcl_GetByteArrayFromObj(value, size)
+return tkffi.buffer(data, size[0])[:]
 elif value.typePtr == typeCache.DoubleType:
 return value.internalRep.doubleValue
 elif value.typePtr == typeCache.IntType:
@@ -44,7 +46,7 @@
 result.append(FromObj(app, tcl_elem[0]))
 return tuple(result)
 elif value.typePtr == typeCache.ProcBodyType:
-return result
+pass  # fall through and return tcl object.
 elif value.typePtr == typeCache.StringType:
 buf = tklib.Tcl_GetUnicode(value)
 length = tklib.Tcl_GetCharLength(value)
diff --git a/lib_pypy/_tkinter/tklib.py b/lib_pypy/_tkinter/tklib.py
--- a/lib_pypy/_tkinter/tklib.py
+++ b/lib_pypy/_tkinter/tklib.py
@@ -72,6 +72,7 @@
 int Tcl_GetBoolean(Tcl_Interp* interp, const char* src, int* boolPtr);
 char *Tcl_GetString(Tcl_Obj* objPtr);
 char *Tcl_GetStringFromObj(Tcl_Obj* objPtr, int* lengthPtr);
+unsigned char *Tcl_GetByteArrayFromObj(Tcl_Obj* objPtr, int* lengthPtr);
 
 Tcl_UniChar *Tcl_GetUnicode(Tcl_Obj* objPtr);
 int Tcl_GetCharLength(Tcl_Obj* objPtr);
diff --git a/pypy/doc/arm.rst b/pypy/doc/arm.rst
--- a/pypy/doc/arm.rst
+++ b/pypy/doc/arm.rst
@@ -35,6 +35,11 @@
   * ``qemu-system``
   * ``qemu-user-static``
 
+- The dependencies above are in addition to the ones needed for a regular
+  translation, `listed here`_.
+
+.. _`listed here`: 
getting-started-python.html#translating-the-pypy-python-interpreter
+
 
 Creating a Qemu based ARM chroot
 
diff --git a/pypy/interpreter/eval.py b/pypy/interpreter/eval.py
--- a/pypy/interpreter/eval.py
+++ b/pypy/interpreter/eval.py
@@ -107,9 +107,15 @@
 for i in range(min(len(varnames), self.getfastscopelength())):
 name = varnames[i]
 w_value = fastscope_w[i]
+w_name = self.space.wrap(name.decode('utf-8'))
 if w_value is not None:
-w_name = self.space.wrap(name.decode('utf-8'))
 self.space.setitem(self.w_locals, w_name, w_value)
+else:
+try:
+self.space.delitem(self.w_locals, w_name)
+except OperationError as e:
+if not e.match(self.space, self.space.w_KeyError):
+raise
 
 def locals2fast(self):
 # Copy values from self.w_locals to the fastlocals
diff --git a/pypy/interpreter/test/test_app_main.py 
b/pypy/interpreter/test/test_app_main.py
--- a/pypy/interpreter/test/test_app_main.py
+++ b/pypy/interpreter/test/test_app_main.py
@@ -1073,6 +1073,8 @@
 
 sys.path.append(self.goal_dir)
 # make sure cwd does not contain a stdlib
+if self.tmp_dir.startswith(self.trunkdir):
+skip('TMPDIR is inside the PyPy source')
 os.chdir(self.tmp_dir)
 tmp_pypy_c = os.path.join(self.tmp_dir, 'pypy-c')
 try:
diff --git a/pypy/module/__builtin__/test/test_builtin.py 
b/pypy/module/__builtin__/test/test_builtin.py
--- a/pypy/module/__builtin__/test/test_builtin.py
+++ b/pypy/module/__builtin__/test/test_builtin.py
@@ -129,10 +129,21 @@
 def test_locals(self):
 def f():
 return locals()
+
 def g(c=0, b=0, a=0):
 return locals()
+
 assert f() == {}
-assert g() == {'a':0, 'b':0, 'c':0}
+assert g() == {'a': 0, 'b': 0, 'c': 0}
+
+def test_locals_deleted_local(self):
+def f():
+a = 3
+locals()
+del a
+return locals()
+
+assert f() == {}
 
 def test_dir(self):
 def f():
@@ -298,22 +309,6 @@
 assert next(x) == 3
 
 def test_range_args(self):
-### range() attributes are 

[pypy-commit] pypy py3k: merge default

2013-09-11 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r66920:927908bea004
Date: 2013-09-11 14:17 -0700
http://bitbucket.org/pypy/pypy/changeset/927908bea004/

Log:merge default

diff --git a/lib-python/2.7/argparse.py b/lib-python/2.7/argparse.py
--- a/lib-python/2.7/argparse.py
+++ b/lib-python/2.7/argparse.py
@@ -1780,7 +1780,19 @@
 # error if this argument is not allowed with other previously
 # seen arguments, assuming that actions that use the default
 # value don't really count as present
-if argument_values is not action.default:
+
+# XXX PyPy bug-to-bug compatibility: is on primitive types
+# is not consistent in CPython.  We'll assume it is close
+# enough for ints (which is true only for small ints), but
+# for floats and longs and complexes we'll go for the option
+# of forcing is to say False, like it usually does on
+# CPython.  A fix is pending on CPython trunk
+# (http://bugs.python.org/issue18943) but that might change
+# the details of the semantics and so not be applied to 2.7.
+# See the line AA below.
+
+if (argument_values is not action.default or
+type(argument_values) in (float, long, complex)):  # AA
 seen_non_default_actions.add(action)
 for conflict_action in action_conflicts.get(action, []):
 if conflict_action in seen_non_default_actions:
diff --git a/pypy/module/thread/test/test_thread.py 
b/pypy/module/thread/test/test_thread.py
--- a/pypy/module/thread/test/test_thread.py
+++ b/pypy/module/thread/test/test_thread.py
@@ -187,9 +187,12 @@
 skip(this OS supports too many threads to check ( 1000))
 lock = _thread.allocate_lock()
 lock.acquire()
+count = [0]
 def f():
+count[0] += 1
 lock.acquire()
 lock.release()
+count[0] -= 1
 try:
 try:
 for i in range(1000):
@@ -197,11 +200,15 @@
 finally:
 lock.release()
 # wait a bit to allow most threads to finish now
-self.busywait(2.0)
+while count[0]  10:
+print(count[0]) # - releases the GIL
+print(ok.)
 except (_thread.error, MemoryError):
 pass
 else:
 raise Exception(could unexpectedly start 1000 threads)
+# safety: check that we can start a new thread here
+thread.start_new_thread(lambda: None, ())
 
 def test_stack_size(self):
 import _thread
diff --git a/rpython/jit/codewriter/call.py b/rpython/jit/codewriter/call.py
--- a/rpython/jit/codewriter/call.py
+++ b/rpython/jit/codewriter/call.py
@@ -92,17 +92,6 @@
 else:
 assert op.opname == 'indirect_call'
 graphs = op.args[-1].value
-if graphs is None:
-# special case: handle the indirect call that goes to
-# the 'instantiate' methods.  This check is a bit imprecise
-# but it's not too bad if we mistake a random indirect call
-# for the one to 'instantiate'.
-from rpython.rtyper.lltypesystem import rclass
-CALLTYPE = op.args[0].concretetype
-if (op.opname == 'indirect_call' and len(op.args) == 2 and
-CALLTYPE == rclass.OBJECT_VTABLE.instantiate):
-graphs = list(self._graphs_of_all_instantiate())
-#
 if graphs is not None:
 result = []
 for graph in graphs:
@@ -114,11 +103,6 @@
 # residual call case: we don't need to look into any graph
 return None
 
-def _graphs_of_all_instantiate(self):
-for vtable in self.rtyper.lltype2vtable.values():
-if vtable.instantiate:
-yield vtable.instantiate._obj.graph
-
 def guess_call_kind(self, op, is_candidate=None):
 if op.opname == 'direct_call':
 funcptr = op.args[0].value
diff --git a/rpython/jit/codewriter/effectinfo.py 
b/rpython/jit/codewriter/effectinfo.py
--- a/rpython/jit/codewriter/effectinfo.py
+++ b/rpython/jit/codewriter/effectinfo.py
@@ -166,9 +166,6 @@
 EffectInfo.MOST_GENERAL = EffectInfo(None, None, None, None,
  EffectInfo.EF_RANDOM_EFFECTS,
  can_invalidate=True)
-EffectInfo.LEAST_GENERAL = EffectInfo([], [], [], [],
-  EffectInfo.EF_ELIDABLE_CANNOT_RAISE,
-  can_invalidate=False)
 
 
 def effectinfo_from_writeanalyze(effects, cpu,
diff --git a/rpython/jit/metainterp/test/test_ajit.py 
b/rpython/jit/metainterp/test/test_ajit.py
--- a/rpython/jit/metainterp/test/test_ajit.py
+++ 

[pypy-commit] pypy py3k: merge default

2013-09-11 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r66919:f1e02da40fe0
Date: 2013-09-10 11:19 -0700
http://bitbucket.org/pypy/pypy/changeset/f1e02da40fe0/

Log:merge default

diff --git a/rpython/jit/backend/llgraph/runner.py 
b/rpython/jit/backend/llgraph/runner.py
--- a/rpython/jit/backend/llgraph/runner.py
+++ b/rpython/jit/backend/llgraph/runner.py
@@ -418,7 +418,6 @@
 
 bh_setfield_raw   = bh_setfield_gc
 bh_setfield_raw_i = bh_setfield_raw
-bh_setfield_raw_r = bh_setfield_raw
 bh_setfield_raw_f = bh_setfield_raw
 
 def bh_arraylen_gc(self, a, descr):
diff --git a/rpython/jit/backend/llsupport/gc.py 
b/rpython/jit/backend/llsupport/gc.py
--- a/rpython/jit/backend/llsupport/gc.py
+++ b/rpython/jit/backend/llsupport/gc.py
@@ -64,8 +64,6 @@
 return True
 def initialize(self):
 pass
-def do_write_barrier(self, gcref_struct, gcref_newptr):
-pass
 def can_use_nursery_malloc(self, size):
 return False
 def has_write_barrier_class(self):
@@ -135,9 +133,7 @@
 def malloc_jitframe(self, frame_info):
  Allocate a new frame, overwritten by tests
 
-frame = jitframe.JITFRAME.allocate(frame_info)
-llop.gc_writebarrier(lltype.Void, frame)
-return frame
+return jitframe.JITFRAME.allocate(frame_info)
 
 class JitFrameDescrs:
 def _freeze_(self):
@@ -547,17 +543,6 @@
 hdr = llmemory.cast_adr_to_ptr(hdr_addr, self.HDRPTR)
 hdr.tid = tid
 
-def do_write_barrier(self, gcref_struct, gcref_newptr):
-hdr_addr = llmemory.cast_ptr_to_adr(gcref_struct)
-hdr_addr -= self.gcheaderbuilder.size_gc_header
-hdr = llmemory.cast_adr_to_ptr(hdr_addr, self.HDRPTR)
-if hdr.tid  self.GCClass.JIT_WB_IF_FLAG:
-# get a pointer to the 'remember_young_pointer' function from
-# the GC, and call it immediately
-llop1 = self.llop1
-funcptr = llop1.get_write_barrier_failing_case(self.WB_FUNCPTR)
-funcptr(llmemory.cast_ptr_to_adr(gcref_struct))
-
 def can_use_nursery_malloc(self, size):
 return size  self.max_size_of_young_obj
 
diff --git a/rpython/jit/backend/llsupport/llmodel.py 
b/rpython/jit/backend/llsupport/llmodel.py
--- a/rpython/jit/backend/llsupport/llmodel.py
+++ b/rpython/jit/backend/llsupport/llmodel.py
@@ -247,6 +247,7 @@
 else:
 assert kind == history.REF
 self.set_ref_value(ll_frame, num, arg)
+llop.gc_writebarrier(lltype.Void, ll_frame)
 ll_frame = func(ll_frame)
 finally:
 if not self.translate_support_code:
@@ -390,9 +391,11 @@
 else:
 raise NotImplementedError(size = %d % size)
 
+@specialize.argtype(1)
 def read_ref_at_mem(self, gcref, ofs):
 return llop.raw_load(llmemory.GCREF, gcref, ofs)
 
+# non-@specialized: must only be called with llmemory.GCREF
 def write_ref_at_mem(self, gcref, ofs, newvalue):
 llop.raw_store(lltype.Void, gcref, ofs, newvalue)
 # the write barrier is implied above
@@ -541,6 +544,7 @@
 ofs, size, sign = self.unpack_fielddescr_size(fielddescr)
 return self.read_int_at_mem(struct, ofs, size, sign)
 
+@specialize.argtype(1)
 def bh_getfield_gc_r(self, struct, fielddescr):
 ofs = self.unpack_fielddescr(fielddescr)
 return self.read_ref_at_mem(struct, ofs)
@@ -551,6 +555,7 @@
 return self.read_float_at_mem(struct, ofs)
 
 bh_getfield_raw_i = bh_getfield_gc_i
+bh_getfield_raw_r = bh_getfield_gc_r
 bh_getfield_raw_f = bh_getfield_gc_f
 
 @specialize.argtype(1)
diff --git a/rpython/jit/backend/llsupport/test/test_gc.py 
b/rpython/jit/backend/llsupport/test/test_gc.py
--- a/rpython/jit/backend/llsupport/test/test_gc.py
+++ b/rpython/jit/backend/llsupport/test/test_gc.py
@@ -175,26 +175,6 @@
   repr(basesize), repr(itemsize),
   repr(ofs_length), p)]
 
-def test_do_write_barrier(self):
-gc_ll_descr = self.gc_ll_descr
-R = lltype.GcStruct('R')
-S = lltype.GcStruct('S', ('r', lltype.Ptr(R)))
-s = lltype.malloc(S)
-r = lltype.malloc(R)
-s_hdr = gc_ll_descr.gcheaderbuilder.new_header(s)
-s_gcref = lltype.cast_opaque_ptr(llmemory.GCREF, s)
-r_gcref = lltype.cast_opaque_ptr(llmemory.GCREF, r)
-s_adr = llmemory.cast_ptr_to_adr(s)
-llmemory.cast_ptr_to_adr(r)
-#
-s_hdr.tid = ~gc_ll_descr.GCClass.JIT_WB_IF_FLAG
-gc_ll_descr.do_write_barrier(s_gcref, r_gcref)
-assert self.llop1.record == []# not called
-#
-s_hdr.tid |= gc_ll_descr.GCClass.JIT_WB_IF_FLAG
-gc_ll_descr.do_write_barrier(s_gcref, r_gcref)
-assert self.llop1.record == [('barrier', s_adr)]
-
 def test_gen_write_barrier(self):
   

[pypy-commit] pypy py3k: merge default

2013-08-15 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r66167:8dc61b6df4f4
Date: 2013-08-15 12:05 -0700
http://bitbucket.org/pypy/pypy/changeset/8dc61b6df4f4/

Log:merge default

diff --git a/pypy/doc/cppyy.rst b/pypy/doc/cppyy.rst
--- a/pypy/doc/cppyy.rst
+++ b/pypy/doc/cppyy.rst
@@ -83,7 +83,7 @@
 the selection of scientific software) will also work for a build with the
 builtin backend.
 
-.. _`download`: http://cern.ch/wlav/reflex-2013-04-23.tar.bz2
+.. _`download`: http://cern.ch/wlav/reflex-2013-08-14.tar.bz2
 .. _`ROOT`: http://root.cern.ch/
 
 Besides Reflex, you probably need a version of `gccxml`_ installed, which is
@@ -98,8 +98,8 @@
 
 To install the standalone version of Reflex, after download::
 
-$ tar jxf reflex-2013-04-23.tar.bz2
-$ cd reflex-2013-04-23
+$ tar jxf reflex-2013-08-14.tar.bz2
+$ cd reflex-2013-08-14
 $ ./build/autogen
 $ ./configure usual set of options such as --prefix
 $ make  make install
diff --git a/pypy/interpreter/app_main.py b/pypy/interpreter/app_main.py
--- a/pypy/interpreter/app_main.py
+++ b/pypy/interpreter/app_main.py
@@ -114,13 +114,12 @@
 except BaseException as e:
 try:
 stderr = sys.stderr
-except AttributeError:
-pass   # too bad
-else:
 print('Error calling sys.excepthook:', file=stderr)
 originalexcepthook(type(e), e, e.__traceback__)
 print(file=stderr)
 print('Original exception was:', file=stderr)
+except:
+pass   # too bad
 
 # we only get here if sys.excepthook didn't do its job
 originalexcepthook(etype, evalue, etraceback)
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
@@ -856,6 +856,69 @@
 assert l
 assert l[0] is None or len(l[0]) == 0
 
+def test_assign_object_with_special_methods(self):
+from array import array
+
+class Num(object):
+def __float__(self):
+return 5.25
+
+def __int__(self):
+return 7
+
+class NotNum(object):
+pass
+
+class Silly(object):
+def __float__(self):
+return None
+
+def __int__(self):
+return None 
+
+class OldNum:
+def __float__(self):
+return 6.25
+
+def __int__(self):
+return 8
+
+class OldNotNum:
+pass
+
+class OldSilly:
+def __float__(self):
+return None
+
+def __int__(self):
+return None
+
+for tc in 'bBhHiIlL':
+a = array(tc, [0])
+raises(TypeError, a.__setitem__, 0, 1.0)
+a[0] = 1
+a[0] = Num()
+assert a[0] == 7
+raises(TypeError, a.__setitem__, NotNum())
+a[0] = OldNum()
+assert a[0] == 8
+raises(TypeError, a.__setitem__, OldNotNum())
+raises(TypeError, a.__setitem__, Silly())
+raises(TypeError, a.__setitem__, OldSilly())
+
+for tc in 'fd':
+a = array(tc, [0])
+a[0] = 1.0
+a[0] = 1
+a[0] = Num()
+assert a[0] == 5.25
+raises(TypeError, a.__setitem__, NotNum())
+a[0] = OldNum()
+assert a[0] == 6.25
+raises(TypeError, a.__setitem__, OldNotNum())
+raises(TypeError, a.__setitem__, Silly())
+raises(TypeError, a.__setitem__, OldSilly())
+
 def test_bytearray(self):
 a = self.array('u', 'hi')
 b = self.array('u')
diff --git a/pypy/module/cppyy/genreflex-methptrgetter.patch 
b/pypy/module/cppyy/genreflex-methptrgetter.patch
--- a/pypy/module/cppyy/genreflex-methptrgetter.patch
+++ b/pypy/module/cppyy/genreflex-methptrgetter.patch
@@ -10,7 +10,7 @@
  # The next is to avoid a known problem with gccxml that it generates a
  # references to id equal '_0' which is not defined anywhere
  self.xref['_0'] = {'elem':'Unknown', 'attrs':{'id':'_0','name':''}, 
'subelems':[]}
-@@ -1306,6 +1307,8 @@
+@@ -1328,6 +1329,8 @@
  bases = self.getBases( attrs['id'] )
  if inner and attrs.has_key('demangled') and 
self.isUnnamedType(attrs['demangled']) :
cls = attrs['demangled']
@@ -19,7 +19,7 @@
clt = ''
  else:
cls = self.genTypeName(attrs['id'],const=True,colon=True)
-@@ -1343,7 +1346,7 @@
+@@ -1365,7 +1368,7 @@
# Inner class/struct/union/enum.
for m in memList :
  member = self.xref[m]
@@ -28,7 +28,7 @@
 and member['attrs'].get('access') in ('private','protected') \
 and 

  1   2   3   >