[pypy-commit] pypy reverse-debugger: Breakpoints
Author: Armin Rigo Branch: reverse-debugger Changeset: r85117:c146f7200672 Date: 2016-06-13 09:45 +0200 http://bitbucket.org/pypy/pypy/changeset/c146f7200672/ Log:Breakpoints diff --git a/rpython/rlib/revdb.py b/rpython/rlib/revdb.py --- a/rpython/rlib/revdb.py +++ b/rpython/rlib/revdb.py @@ -7,14 +7,14 @@ from rpython.rtyper.annlowlevel import llhelper, hlstr -def stop_point(n): +def stop_point(): """Indicates a point in the execution of the RPython program where the reverse-debugger can stop. When reverse-debugging, we see the "time" as the index of the stop-point that happened. """ if we_are_translated(): if fetch_translated_config().translation.reverse_debugger: -llop.revdb_stop_point(lltype.Void, n) +llop.revdb_stop_point(lltype.Void) def register_debug_command(command, lambda_func): """Register the extra RPython-implemented debug command.""" @@ -25,18 +25,23 @@ def current_time(): """For RPython debug commands: returns the current time.""" -return llop.revdb_get_value(lltype.Signed, 'c') +return llop.revdb_get_value(lltype.SignedLongLong, 'c') + +def current_break_time(): +"""Returns the time configured for the next break. When going forward, +this is the target time at which we'll stop going forward.""" +return llop.revdb_get_value(lltype.SignedLongLong, 'b') def most_recent_fork(): """For RPython debug commands: returns the time of the most recent fork. Going back to that time is fast; going back to a time just before is slow.""" -return llop.revdb_get_value(lltype.Signed, 'm') +return llop.revdb_get_value(lltype.SignedLongLong, 'f') def total_time(): """For RPython debug commands: returns the total time (measured as the total number of stop-points).""" -return llop.revdb_get_value(lltype.Signed, 't') +return llop.revdb_get_value(lltype.SignedLongLong, 't') @specialize.arg(1) def go_forward(time_delta, callback, arg_string): @@ -89,8 +94,8 @@ try: cmds = t.revdb_commands except AttributeError: -cmds = t.revdb_commands = {} -cmds[command] = func +cmds = t.revdb_commands = [] +cmds.append((command, func)) s_func = self.bookkeeper.immutablevalue(func) self.bookkeeper.emulate_pbc_call(self.bookkeeper.position_key, s_func, [annmodel.s_Str0]) diff --git a/rpython/rtyper/lltypesystem/lloperation.py b/rpython/rtyper/lltypesystem/lloperation.py --- a/rpython/rtyper/lltypesystem/lloperation.py +++ b/rpython/rtyper/lltypesystem/lloperation.py @@ -569,6 +569,7 @@ 'revdb_send_output':LLOp(), 'revdb_change_time':LLOp(), 'revdb_get_value': LLOp(sideeffects=False), +'revdb_set_value': LLOp(), 'revdb_identityhash': LLOp(), } # * Run test_lloperation after changes. * diff --git a/rpython/translator/revdb/revdb_genc.py b/rpython/translator/revdb/revdb_genc.py --- a/rpython/translator/revdb/revdb_genc.py +++ b/rpython/translator/revdb/revdb_genc.py @@ -23,7 +23,7 @@ FUNCPTR = lltype.Ptr(lltype.FuncType([lltype.Ptr(rstr.STR)], lltype.Void)) bk = db.translator.annotator.bookkeeper -cmds = getattr(db.translator, 'revdb_commands', {}).items() +cmds = getattr(db.translator, 'revdb_commands', []) array_names = lltype.malloc(rffi.CArray(rffi.CCHARP), len(cmds) + 1, flavor='raw', immortal=True, zero=True) diff --git a/rpython/translator/revdb/src-revdb/revdb.c b/rpython/translator/revdb/src-revdb/revdb.c --- a/rpython/translator/revdb/src-revdb/revdb.c +++ b/rpython/translator/revdb/src-revdb/revdb.c @@ -151,15 +151,17 @@ /* Boehm only */ if (obj->h_hash == 0) { Signed h; +if (flag_io_disabled) { +/* This is when running debug commands. Don't cache the + hash on the object at all. */ +return ~((Signed)obj); +} /* When recording, we get the hash the normal way from the pointer casted to an int, and record that. When replaying, we read it from the record. In both cases, we cache the hash in the object, so that we record/replay only once per object. */ -if (flag_io_disabled) -h = ~((Signed)obj); -else -RPY_REVDB_EMIT(h = ~((Signed)obj);, Signed _e, h); +RPY_REVDB_EMIT(h = ~((Signed)obj);, Signed _e, h); assert(h != 0); obj->h_hash = h; } @@ -297,7 +299,7 @@ } fprintf(stderr, "%s", RDB_SIGNATURE); while ((read_all(input, 1), input[0] != 0)) -fwrite(input, 1, 1, stderr); +fputc(input[0], stderr); read_all(&h, sizeof(h)); if (h.version != RDB_VERSION) { @@ -743,18 +745,12 @@ cmd_go(target_time, NULL, NULL); } -static void act_info_fork(char *
[pypy-commit] pypy reverse-debugger: Rename the src directory
Author: Armin Rigo Branch: reverse-debugger Changeset: r85116:eff7204f9b22 Date: 2016-06-13 08:49 +0200 http://bitbucket.org/pypy/pypy/changeset/eff7204f9b22/ Log:Rename the src directory diff --git a/rpython/translator/c/src/entrypoint.c b/rpython/translator/c/src/entrypoint.c --- a/rpython/translator/c/src/entrypoint.c +++ b/rpython/translator/c/src/entrypoint.c @@ -38,7 +38,7 @@ #endif #ifdef RPY_REVERSE_DEBUGGER -# include +# include #endif RPY_EXPORTED diff --git a/rpython/translator/c/src/g_include.h b/rpython/translator/c/src/g_include.h --- a/rpython/translator/c/src/g_include.h +++ b/rpython/translator/c/src/g_include.h @@ -52,5 +52,5 @@ #endif #ifdef RPY_REVERSE_DEBUGGER -#include "rdb-src/revdb_include.h" +#include "src-revdb/revdb_include.h" #endif diff --git a/rpython/translator/revdb/revdb_genc.py b/rpython/translator/revdb/revdb_genc.py --- a/rpython/translator/revdb/revdb_genc.py +++ b/rpython/translator/revdb/revdb_genc.py @@ -5,7 +5,7 @@ def extra_files(): -srcdir = py.path.local(__file__).join('..', 'rdb-src') +srcdir = py.path.local(__file__).join('..', 'src-revdb') return [ srcdir / 'revdb.c', ] diff --git a/rpython/translator/revdb/rdb-src/revdb.c b/rpython/translator/revdb/src-revdb/revdb.c rename from rpython/translator/revdb/rdb-src/revdb.c rename to rpython/translator/revdb/src-revdb/revdb.c --- a/rpython/translator/revdb/rdb-src/revdb.c +++ b/rpython/translator/revdb/src-revdb/revdb.c @@ -12,7 +12,7 @@ #include "forwarddecl.h" #include "preimpl.h" #include "src/rtyper.h" -#include "rdb-src/revdb_include.h" +#include "src-revdb/revdb_include.h" #define RDB_SIGNATURE "RevDB:" #define RDB_VERSION 0x00FF0001 diff --git a/rpython/translator/revdb/rdb-src/revdb_include.h b/rpython/translator/revdb/src-revdb/revdb_include.h rename from rpython/translator/revdb/rdb-src/revdb_include.h rename to rpython/translator/revdb/src-revdb/revdb_include.h ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy reverse-debugger: Record the creation time of objects
Author: Armin Rigo Branch: reverse-debugger Changeset: r85119:55db2cb66764 Date: 2016-06-13 11:15 +0200 http://bitbucket.org/pypy/pypy/changeset/55db2cb66764/ Log:Record the creation time of objects diff --git a/rpython/memory/gctransform/boehm.py b/rpython/memory/gctransform/boehm.py --- a/rpython/memory/gctransform/boehm.py +++ b/rpython/memory/gctransform/boehm.py @@ -10,7 +10,6 @@ class BoehmGCTransformer(GCTransformer): malloc_zero_filled = True FINALIZER_PTR = lltype.Ptr(lltype.FuncType([llmemory.Address], lltype.Void)) -HDR = lltype.Struct("header", ("hash", lltype.Signed)) def __init__(self, translator, inline=False): super(BoehmGCTransformer, self).__init__(translator, inline=inline) @@ -28,6 +27,10 @@ ll_malloc_varsize_no_length = mh.ll_malloc_varsize_no_length ll_malloc_varsize = mh.ll_malloc_varsize +fields = [("hash", lltype.Signed)] +if translator.config.translation.reverse_debugger: +fields.append(("ctime", lltype.SignedLongLong)) +self.HDR = lltype.Struct("header", *fields) HDRPTR = lltype.Ptr(self.HDR) if self.translator: @@ -167,7 +170,7 @@ hop.genop('int_invert', [v_int], resultvar=hop.spaceop.result) def gcheader_initdata(self, obj): -hdr = lltype.malloc(self.HDR, immortal=True) +hdr = lltype.malloc(self.HDR, immortal=True, zero=True) hdr.hash = lltype.identityhash_nocache(obj._as_ptr()) return hdr._obj diff --git a/rpython/rlib/revdb.py b/rpython/rlib/revdb.py --- a/rpython/rlib/revdb.py +++ b/rpython/rlib/revdb.py @@ -43,6 +43,14 @@ as the total number of stop-points).""" return llop.revdb_get_value(lltype.SignedLongLong, 't') +@specialize.argtype(0) +def creation_time_of(x): +"""Returns the time at which the object 'x' was created. +More precisely, returns t such that object 'x' was created when +current_time()==t; this means that the object exists from time t+1. +""" +return llop.revdb_creation_time_of(lltype.SignedLongLong, x) + @specialize.arg(1) def go_forward(time_delta, callback, arg_string): """For RPython debug commands: tells that after this function finishes, diff --git a/rpython/rtyper/lltypesystem/lloperation.py b/rpython/rtyper/lltypesystem/lloperation.py --- a/rpython/rtyper/lltypesystem/lloperation.py +++ b/rpython/rtyper/lltypesystem/lloperation.py @@ -571,6 +571,7 @@ 'revdb_get_value': LLOp(sideeffects=False), 'revdb_set_value': LLOp(), 'revdb_identityhash': LLOp(), +'revdb_creation_time_of': LLOp(sideeffects=False), } # * Run test_lloperation after changes. * diff --git a/rpython/translator/c/funcgen.py b/rpython/translator/c/funcgen.py --- a/rpython/translator/c/funcgen.py +++ b/rpython/translator/c/funcgen.py @@ -578,13 +578,22 @@ self.expr(op.args[0]), self.expr(op.args[1])) +def _op_boehm_malloc(self, op, is_atomic): +expr_result = self.expr(op.result) +res = 'OP_BOEHM_ZERO_MALLOC(%s, %s, void*, %d, 0);' % ( +self.expr(op.args[0]), +expr_result, +is_atomic) +if self.db.reverse_debugger: +from rpython.translator.revdb import revdb_genc +res += revdb_genc.record_malloc_ctime(expr_result) +return res + def OP_BOEHM_MALLOC(self, op): -return 'OP_BOEHM_ZERO_MALLOC(%s, %s, void*, 0, 0);' % (self.expr(op.args[0]), - self.expr(op.result)) +return self._op_boehm_malloc(op, 0) def OP_BOEHM_MALLOC_ATOMIC(self, op): -return 'OP_BOEHM_ZERO_MALLOC(%s, %s, void*, 1, 0);' % (self.expr(op.args[0]), - self.expr(op.result)) +return self._op_boehm_malloc(op, 1) def OP_BOEHM_REGISTER_FINALIZER(self, op): return 'GC_REGISTER_FINALIZER(%s, (GC_finalization_proc)%s, NULL, NULL, NULL);' \ diff --git a/rpython/translator/revdb/revdb_genc.py b/rpython/translator/revdb/revdb_genc.py --- a/rpython/translator/revdb/revdb_genc.py +++ b/rpython/translator/revdb/revdb_genc.py @@ -18,6 +18,9 @@ return emit_void(normal_code) return 'RPY_REVDB_EMIT(%s, %s, %s);' % (normal_code, cdecl(tp, '_e'), value) +def record_malloc_ctime(expr): +return ' RPY_REVDB_REC_CTIME(%s);' % (expr,) + def prepare_database(db): FUNCPTR = lltype.Ptr(lltype.FuncType([lltype.Ptr(rstr.STR)], lltype.Void)) diff --git a/rpython/translator/revdb/src-revdb/revdb_include.h b/rpython/translator/revdb/src-revdb/revdb_include.h --- a/rpython/translator/revdb/src-revdb/revdb_include.h +++ b/rpython/translator/revdb/src-revdb/revdb_include.h @@ -67,6 +67,11 @@ #define RPY_REVDB_EMIT_VOID(normal_code)\ if (!RPY_RDB_REPLAY) { normal_code } else { } +#define RPY_RE
[pypy-commit] pypy default: Support 'llhelper(F, multiple_functions)', as long as they all have the
Author: Armin Rigo Branch: Changeset: r85118:6709ea850047 Date: 2016-06-13 10:18 +0200 http://bitbucket.org/pypy/pypy/changeset/6709ea850047/ Log:Support 'llhelper(F, multiple_functions)', as long as they all have the right signature. diff --git a/rpython/rtyper/annlowlevel.py b/rpython/rtyper/annlowlevel.py --- a/rpython/rtyper/annlowlevel.py +++ b/rpython/rtyper/annlowlevel.py @@ -348,19 +348,30 @@ _about_ = llhelper def compute_result_annotation(self, s_F, s_callable): +from rpython.annotator.description import FunctionDesc assert s_F.is_constant() -assert s_callable.is_constant() +assert isinstance(s_callable, annmodel.SomePBC) F = s_F.const FUNC = F.TO args_s = [lltype_to_annotation(T) for T in FUNC.ARGS] -key = (llhelper, s_callable.const) -s_res = self.bookkeeper.emulate_pbc_call(key, s_callable, args_s) -assert lltype_to_annotation(FUNC.RESULT).contains(s_res) +for desc in s_callable.descriptions: +assert isinstance(desc, FunctionDesc) +assert desc.pyobj is not None +if s_callable.is_constant(): +assert s_callable.const is desc.pyobj +key = (llhelper, desc.pyobj) +s_res = self.bookkeeper.emulate_pbc_call(key, s_callable, args_s) +assert lltype_to_annotation(FUNC.RESULT).contains(s_res) return SomePtr(F) def specialize_call(self, hop): hop.exception_cannot_occur() -return hop.args_r[1].get_unique_llfn() +if hop.args_s[1].is_constant(): +return hop.args_r[1].get_unique_llfn() +else: +F = hop.args_s[0].const +assert hop.args_r[1].lowleveltype == F +return hop.inputarg(hop.args_r[1], 1) # diff --git a/rpython/rtyper/test/test_llann.py b/rpython/rtyper/test/test_llann.py --- a/rpython/rtyper/test/test_llann.py +++ b/rpython/rtyper/test/test_llann.py @@ -462,6 +462,30 @@ res = interpret(h, [8, 5, 2]) assert res == 99 +def test_llhelper_multiple_functions(): +S = GcStruct('S', ('x', Signed), ('y', Signed)) +def f(s): +return s.x - s.y +def g(s): +return s.x + s.y + +F = Ptr(FuncType([Ptr(S)], Signed)) + +myfuncs = [f, g] + +def h(x, y, z): +s = malloc(S) +s.x = x +s.y = y +fptr = llhelper(F, myfuncs[z]) +assert typeOf(fptr) == F +return fptr(s) + +res = interpret(h, [80, 5, 0]) +assert res == 75 +res = interpret(h, [80, 5, 1]) +assert res == 85 + def test_cast_instance_to_base_ptr(): class A: ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix for module.cpyext.test.test_ztranslation
Author: Armin Rigo Branch: Changeset: r85120:30a77e18d1db Date: 2016-06-13 11:19 +0200 http://bitbucket.org/pypy/pypy/changeset/30a77e18d1db/ Log:fix for module.cpyext.test.test_ztranslation 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 @@ -417,11 +417,11 @@ class FakeModule(W_Root): def __init__(self): self.w_dict = w_some_obj() - def get(self, name): name + "xx" # check that it's a string return w_some_obj() FakeObjSpace.sys = FakeModule() FakeObjSpace.sys.filesystemencoding = 'foobar' FakeObjSpace.sys.defaultencoding = 'ascii' +FakeObjSpace.sys.dlopenflags = 123 FakeObjSpace.builtin = FakeModule() ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Add a test checking the conversion_table() function and the
Author: Armin Rigo Branch: Changeset: r85121:4e4fa6046959 Date: 2016-06-13 11:53 +0200 http://bitbucket.org/pypy/pypy/changeset/4e4fa6046959/ Log:Add a test checking the conversion_table() function and the pointer_table array. Add 'immutable' hints on these arrays. diff --git a/rpython/rtyper/rpbc.py b/rpython/rtyper/rpbc.py --- a/rpython/rtyper/rpbc.py +++ b/rpython/rtyper/rpbc.py @@ -414,7 +414,7 @@ if self.s_pbc.can_be_None: self.descriptions.insert(0, None) POINTER_TABLE = Array(self.pointer_repr.lowleveltype, - hints={'nolength': True}) + hints={'nolength': True, 'immutable': True}) pointer_table = malloc(POINTER_TABLE, len(self.descriptions), immortal=True) for i, desc in enumerate(self.descriptions): @@ -564,7 +564,7 @@ if r_to in r_from._conversion_tables: return r_from._conversion_tables[r_to] else: -t = malloc(Array(Char, hints={'nolength': True}), +t = malloc(Array(Char, hints={'nolength': True, 'immutable': True}), len(r_from.descriptions), immortal=True) l = [] for i, d in enumerate(r_from.descriptions): @@ -577,7 +577,7 @@ if l == range(len(r_from.descriptions)): r = None else: -r = inputconst(Ptr(Array(Char, hints={'nolength': True})), t) +r = inputconst(typeOf(t), t) r_from._conversion_tables[r_to] = r return r diff --git a/rpython/rtyper/test/test_rpbc.py b/rpython/rtyper/test/test_rpbc.py --- a/rpython/rtyper/test/test_rpbc.py +++ b/rpython/rtyper/test/test_rpbc.py @@ -2012,6 +2012,36 @@ e = py.test.raises(ValueError, self.interpret, f, [3]) assert str(e.value).startswith(r"exit case '\xff' not found") +@py.test.mark.parametrize('limit', [3, 5]) +def test_conversion_table(self, limit): +# with limit==3, check conversion from Char to Ptr(Func). +# with limit>3, check conversion from Char to Char. +def f1(): +return 111 +def f2(): +return 222 +def f3(): +return 333 +def g(n): +if n & 1: +return f1 +else: +return f2 +def f(n): +x = g(n)# can be f1 or f2 +if n > 10: +x = f3 # now can be f1 or f2 or f3 +return x() + +from rpython.config.translationoption import get_combined_translation_config +self.config = get_combined_translation_config(translating=True) +self.config.translation.withsmallfuncsets = limit +assert self.interpret(f, [3]) == 111 +assert self.interpret(f, [4]) == 222 +assert self.interpret(f, [13]) == 333 +assert self.interpret(f, [14]) == 333 + + def test_smallfuncsets_basic(): from rpython.translator.translator import TranslationContext, graphof from rpython.config.translationoption import get_combined_translation_config ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy reverse-debugger: Don't record the reads out of the small funcset arrays
Author: Armin Rigo Branch: reverse-debugger Changeset: r85123:1f9da349e92c Date: 2016-06-13 12:03 +0200 http://bitbucket.org/pypy/pypy/changeset/1f9da349e92c/ Log:Don't record the reads out of the small funcset arrays diff --git a/rpython/rlib/revdb.py b/rpython/rlib/revdb.py --- a/rpython/rlib/revdb.py +++ b/rpython/rlib/revdb.py @@ -47,7 +47,8 @@ def creation_time_of(x): """Returns the time at which the object 'x' was created. More precisely, returns t such that object 'x' was created when -current_time()==t; this means that the object exists from time t+1. +current_time()==t; this means that the object exists at the stop +point number t+1, but does not exist yet at the stop point number t. """ return llop.revdb_creation_time_of(lltype.SignedLongLong, x) diff --git a/rpython/rtyper/rpbc.py b/rpython/rtyper/rpbc.py --- a/rpython/rtyper/rpbc.py +++ b/rpython/rtyper/rpbc.py @@ -414,7 +414,8 @@ if self.s_pbc.can_be_None: self.descriptions.insert(0, None) POINTER_TABLE = Array(self.pointer_repr.lowleveltype, - hints={'nolength': True, 'immutable': True}) + hints={'nolength': True, 'immutable': True, + 'static_immutable': True}) pointer_table = malloc(POINTER_TABLE, len(self.descriptions), immortal=True) for i, desc in enumerate(self.descriptions): @@ -564,7 +565,8 @@ if r_to in r_from._conversion_tables: return r_from._conversion_tables[r_to] else: -t = malloc(Array(Char, hints={'nolength': True, 'immutable': True}), +t = malloc(Array(Char, hints={'nolength': True, 'immutable': True, + 'static_immutable': True}), len(r_from.descriptions), immortal=True) l = [] for i, d in enumerate(r_from.descriptions): diff --git a/rpython/translator/revdb/test/test_basic.py b/rpython/translator/revdb/test/test_basic.py --- a/rpython/translator/revdb/test/test_basic.py +++ b/rpython/translator/revdb/test/test_basic.py @@ -59,12 +59,15 @@ return self.cur == len(self.buffer) -def compile(self, entry_point, argtypes, backendopt=True): +def compile(self, entry_point, argtypes, backendopt=True, +withsmallfuncsets=None): t = Translation(entry_point, None, gc="boehm") self.t = t t.config.translation.reverse_debugger = True t.config.translation.rweakref = False t.config.translation.lldebug0 = True +if withsmallfuncsets is not None: +t.config.translation.withsmallfuncsets = withsmallfuncsets if not backendopt: t.disable(["backendopt_lltype"]) t.annotate() @@ -171,6 +174,40 @@ x = rdb.next('q'); assert x == 0 # number of stop points assert rdb.done() +@py.test.mark.parametrize('limit', [3, 5]) +def test_dont_record_small_funcset_conversions(self, limit): +def f1(): +return 111 +def f2(): +return 222 +def f3(): +return 333 +def g(n): +if n & 1: +return f1 +else: +return f2 +def main(argv): +x = g(len(argv))# can be f1 or f2 +if len(argv) > 5: +x = f3 # now can be f1 or f2 or f3 +print x() +return 9 +self.compile(main, [], backendopt=False, withsmallfuncsets=limit) +for input, expected_output in [ +('2 3', '111\n'), +('2 3 4', '222\n'), +('2 3 4 5 6 7', '333\n'), +]: +out = self.run(input) +assert out == expected_output +rdb = self.fetch_rdb([self.exename] + input.split()) +# write() call +x = rdb.next(); assert x == len(out) +x = rdb.next('i'); assert x == 0 # errno +x = rdb.next('q'); assert x == 0 # number of stop points +assert rdb.done() + class InteractiveTests(object): EOF = pexpect.EOF ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy reverse-debugger: hg merge default
Author: Armin Rigo Branch: reverse-debugger Changeset: r85122:ea07e83296cd Date: 2016-06-13 11:59 +0200 http://bitbucket.org/pypy/pypy/changeset/ea07e83296cd/ Log:hg merge default diff too long, truncating to 2000 out of 4843 lines diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -25,3 +25,4 @@ 80ef432a32d9baa4b3c5a54c215e8ebe499f6374 release-5.1.2 40497617ae91caa1a394d8be6f9cd2de31cb0628 release-pypy3.3-v5.2 40497617ae91caa1a394d8be6f9cd2de31cb0628 release-pypy3.3-v5.2 +c09c19272c990a0611b17569a0085ad1ab00c8ff release-pypy2.7-v5.3 diff --git a/LICENSE b/LICENSE --- a/LICENSE +++ b/LICENSE @@ -43,17 +43,17 @@ Samuele Pedroni Matti Picus Alex Gaynor + Philip Jenvey Brian Kearns - Philip Jenvey + Ronan Lamy Michael Hudson - Ronan Lamy + Manuel Jacob David Schneider - Manuel Jacob Holger Krekel Christian Tismer Hakan Ardo + Richard Plangger Benjamin Peterson - Richard Plangger Anders Chrigstrom Eric van Riet Paap Wim Lavrijsen @@ -93,9 +93,9 @@ stian Jan de Mooij Tyler Wade + Vincent Legoll Michael Foord Stephan Diehl - Vincent Legoll Stefan Schwarzer Valentino Volonghi Tomek Meka @@ -104,17 +104,20 @@ Bruno Gola David Malcolm Jean-Paul Calderone + Mark Young Timo Paulssen Squeaky + Devin Jeanpierre Marius Gedminas Alexandre Fayolle Simon Burton + Stefano Rivera Martin Matusiak Konstantin Lopuhin - Stefano Rivera Wenzhu Man John Witulski Laurence Tratt + Raffael Tfirst Ivan Sichmann Freitas Greg Price Dario Bertini @@ -122,13 +125,13 @@ Simon Cross Edd Barrett Andreas Stührk + Tobias Pape Jean-Philippe St. Pierre Guido van Rossum Pavel Vinogradov Spenser Bauman Jeremy Thurgood Paweł Piotr Przeradowski - Tobias Pape Paul deGrandis Ilya Osadchiy marky1991 @@ -140,7 +143,6 @@ Georg Brandl Bert Freudenberg Stian Andreassen - Mark Young Wanja Saatkamp Gerald Klix Mike Blume @@ -156,11 +158,13 @@ Dusty Phillips Lukas Renggli Guenter Jantzen + William Leslie Ned Batchelder Tim Felgentreff Anton Gulenko Amit Regmi Ben Young + Sergey Matyunin Nicolas Chauvat Andrew Durdin Andrew Chambers @@ -171,9 +175,9 @@ Yichao Yu Rocco Moretti Gintautas Miliauskas - Devin Jeanpierre Michael Twomey Lucian Branescu Mihaila + anatoly techtonik Gabriel Lavoie Olivier Dormond Jared Grubb @@ -183,8 +187,6 @@ Brian Dorsey Victor Stinner Andrews Medina - anatoly techtonik - Sergey Matyunin Stuart Williams Jasper Schulz Christian Hudon @@ -208,11 +210,11 @@ Alex Perry Vaibhav Sood Alan McIntyre - William Leslie Alexander Sedov Attila Gobi Jasper.Schulz Christopher Pope + Florin Papa Christian Tismer Marc Abramowitz Dan Stromberg @@ -228,7 +230,6 @@ Lukas Vacek Kunal Grover Andrew Dalke - Florin Papa Sylvain Thenault Jakub Stasiak Nathan Taylor @@ -270,8 +271,9 @@ Yury V. Zaytsev Anna Katrina Dominguez Bobby Impollonia - t...@eistee.fritz.box + Vasantha Ganesh K Andrew Thompson + florinpapa Yusei Tahara Aaron Tubbs Ben Darnell @@ -295,9 +297,9 @@ Akira Li Gustavo Niemeyer Stephan Busemann - florinpapa Rafał Gałczyński Matt Bogosian + timo Christian Muirhead Berker Peksag James Lan 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.6.0 +Version: 1.7.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.6.0" -__version_info__ = (1, 6, 0) +__version__ = "1.7.0" +__version_info__ = (1, 7, 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/_cffi_include.h b/lib_pypy/cffi/_cffi_include.h --- a/lib_pypy/cffi/_cffi_include.h +++ b/lib_pypy/cffi/_cffi_include.h @@ -57,6 +57,12 @@ # define _CFFI_UNUSED_FN /* nothing */ #endif +#ifdef __cplusplus +# ifndef _Bool +# define _Bool bool /* semi-hackish: C++ has no _Bool; bool is builtin */ +# endif +#endif + /** CPython-specific section **/ #ifndef PYPY_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:
[pypy-commit] pypy reverse-debugger: object_to_id
Author: Armin Rigo Branch: reverse-debugger Changeset: r85124:6494d80c50d8 Date: 2016-06-13 13:03 +0200 http://bitbucket.org/pypy/pypy/changeset/6494d80c50d8/ Log:object_to_id diff --git a/rpython/rlib/revdb.py b/rpython/rlib/revdb.py --- a/rpython/rlib/revdb.py +++ b/rpython/rlib/revdb.py @@ -5,6 +5,8 @@ from rpython.rtyper.lltypesystem.lloperation import llop from rpython.rtyper.extregistry import ExtRegistryEntry from rpython.rtyper.annlowlevel import llhelper, hlstr +from rpython.rtyper.annlowlevel import cast_base_ptr_to_instance +from rpython.rtyper.rclass import OBJECTPTR def stop_point(): @@ -52,6 +54,15 @@ """ return llop.revdb_creation_time_of(lltype.SignedLongLong, x) +@specialize.argtype(0) +def object_to_id(x): +return llop.revdb_object_to_id(lltype.Signed, x) + +@specialize.arg(0) +def id_to_object(Class, object_id): +x = llop.revdb_id_to_object(OBJECTPTR, object_id) +return cast_base_ptr_to_instance(Class, x) + @specialize.arg(1) def go_forward(time_delta, callback, arg_string): """For RPython debug commands: tells that after this function finishes, diff --git a/rpython/rtyper/lltypesystem/lloperation.py b/rpython/rtyper/lltypesystem/lloperation.py --- a/rpython/rtyper/lltypesystem/lloperation.py +++ b/rpython/rtyper/lltypesystem/lloperation.py @@ -572,6 +572,8 @@ 'revdb_set_value': LLOp(), 'revdb_identityhash': LLOp(), 'revdb_creation_time_of': LLOp(sideeffects=False), +'revdb_object_to_id': LLOp(sideeffects=False), +'revdb_id_to_object': LLOp(sideeffects=False), } # * Run test_lloperation after changes. * diff --git a/rpython/translator/revdb/src-revdb/revdb_include.h b/rpython/translator/revdb/src-revdb/revdb_include.h --- a/rpython/translator/revdb/src-revdb/revdb_include.h +++ b/rpython/translator/revdb/src-revdb/revdb_include.h @@ -79,7 +79,7 @@ #define OP_REVDB_SEND_OUTPUT(ll_string, r) \ rpy_reverse_db_send_output(ll_string) -#define OP_REVDB_CHANGE_TIME(mode, time, callback, ll_string, r) \ +#define OP_REVDB_CHANGE_TIME(mode, time, callback, ll_string, r)\ rpy_reverse_db_change_time(mode, time, callback, ll_string) #define OP_REVDB_GET_VALUE(value_id, r) \ @@ -88,9 +88,15 @@ #define OP_REVDB_IDENTITYHASH(obj, r) \ r = rpy_reverse_db_identityhash((struct pypy_header0 *)(obj)) -#define OP_REVDB_CREATION_TIME_OF(x, r) \ +#define OP_REVDB_CREATION_TIME_OF(x, r) \ r = ((struct pypy_header0 *)x)->h_ctime +#define OP_REVDB_OBJECT_TO_ID(x, r) \ +r = (Signed)x + +#define OP_REVDB_ID_TO_OBJECT(x, r) \ +r = (void *)x + RPY_EXTERN void rpy_reverse_db_flush(void); RPY_EXTERN char *rpy_reverse_db_fetch(int expected_size, const char *file, int line); diff --git a/rpython/translator/revdb/test/test_basic.py b/rpython/translator/revdb/test/test_basic.py --- a/rpython/translator/revdb/test/test_basic.py +++ b/rpython/translator/revdb/test/test_basic.py @@ -292,6 +292,9 @@ def setup_class(cls): # +class Stuff: +pass +# def g(cmdline): if len(cmdline) > 5: raise ValueError @@ -333,6 +336,12 @@ revdb.jump_in_time(2, changed_time, "xyzzy") if cmdline == 'set-break-after-0': dbstate.break_after = 0 +if cmdline == 'print-id': +revdb.send_output('%d\n' % (revdb.object_to_id(dbstate.stuff),)) +if cmdline.startswith('check-id '): +obj_id = int(cmdline[len('check-id '):]) +revdb.send_output("%d\n" % +int(revdb.id_to_object(Stuff, obj_id) is dbstate.stuff)) revdb.send_output('blipped\n') lambda_blip = lambda: blip # @@ -341,6 +350,7 @@ dbstate = DBState() # def main(argv): +dbstate.stuff = Stuff() revdb.register_debug_command('r', lambda_blip) for i, op in enumerate(argv[1:]): revdb.stop_point() @@ -439,3 +449,22 @@ child.sendline('__forward 5') child.expectx('breakpoint!\r\n' '(2)$ ') + +def test_object_to_id(self): +child = self.replay() +child.expectx('(3)$ ') +child.sendline('r print-id') +child.expect(re.escape('<<>>\r\n') + + r'(-?\d+)' + + re.escape('\r\n' + 'blipped\r\n' + '(3)$ ')) +object_id = child.match.group(1) +for at_time in [1, 2, 3]: +child.sendline('__go %d' % at_time) +child.expectx('(%d)$ ' % at_time) +child.sendline('r check-id ' + object_id) +
[pypy-commit] pypy reverse-debugger: fix
Author: Armin Rigo Branch: reverse-debugger Changeset: r85125:da8e81bf6327 Date: 2016-06-13 15:03 +0200 http://bitbucket.org/pypy/pypy/changeset/da8e81bf6327/ Log:fix diff --git a/rpython/translator/revdb/src-revdb/revdb.c b/rpython/translator/revdb/src-revdb/revdb.c --- a/rpython/translator/revdb/src-revdb/revdb.c +++ b/rpython/translator/revdb/src-revdb/revdb.c @@ -224,6 +224,7 @@ static jmp_buf jmp_buf_cancel_execution; static uint64_t most_recent_fork; static uint64_t total_stop_points; +static uint64_t stopped_time; static void (*invoke_after_forward)(RPyString *); static RPyString *invoke_argument; @@ -552,7 +553,7 @@ if (process_kind == PK_DEBUG_PROCESS) { printf("At end.\n"); -cmd_go(rpy_revdb.stop_point_seen, NULL, NULL); +cmd_go(stop_points, NULL, NULL); abort(); /* unreachable */ } @@ -779,12 +780,13 @@ { NULL } }; while (rpy_revdb.stop_point_break == rpy_revdb.stop_point_seen) { +stopped_time = rpy_revdb.stop_point_seen; if (invoke_after_forward != NULL) { execute_rpy_function(invoke_after_forward, invoke_argument); } else { char input[256]; -printf("(%llu)$ ", (unsigned long long)rpy_revdb.stop_point_seen); +printf("(%llu)$ ", (unsigned long long)stopped_time); fflush(stdout); if (fgets(input, sizeof(input), stdin) != input) { fprintf(stderr, "\n"); @@ -793,6 +795,7 @@ } process_input(input, "command", 1, actions_1); } +stopped_time = 0; } } @@ -825,7 +828,11 @@ fprintf(stderr, "revdb.go_forward(): negative amount of steps\n"); exit(1); } -rpy_revdb.stop_point_break = rpy_revdb.stop_point_seen + time; +if (stopped_time == 0) { +fprintf(stderr, "revdb.go_forward(): not from a debug command\n"); +exit(1); +} +rpy_revdb.stop_point_break = stopped_time + time; invoke_after_forward = callback; invoke_argument = arg; break; @@ -844,7 +851,7 @@ { switch (value_id) { case 'c': /* current_time() */ -return rpy_revdb.stop_point_seen; +return stopped_time ? stopped_time : rpy_revdb.stop_point_seen; case 'f': /* most_recent_fork() */ return most_recent_fork; case 't': /* total_time() */ ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy hypothesis-apptest: a hypothesis strategy for randomizing the results of we_are_jitted()
Author: Carl Friedrich Bolz Branch: hypothesis-apptest Changeset: r85126:0485618dc84d Date: 2016-06-13 15:44 +0200 http://bitbucket.org/pypy/pypy/changeset/0485618dc84d/ Log:a hypothesis strategy for randomizing the results of we_are_jitted() diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py --- a/rpython/rlib/jit.py +++ b/rpython/rlib/jit.py @@ -325,12 +325,42 @@ hop.exception_cannot_occur() return hop.genop('hint', [v, c_hint], resulttype=v.concretetype) - def we_are_jitted(): """ Considered as true during tracing and blackholing, so its consquences are reflected into jitted code """ +global _hypothesis_data +if _hypothesis_data is not None: +if _hypothesis_data.data.frozen: +# outside of test, reset +_hypothesis_data = None +else: +import hypothesis.strategies as strategies +return _hypothesis_data.draw(strategies.booleans()) return False +def _randomize_we_are_jitted_from(data): +global _hypothesis_data +_hypothesis_data = data +return None + +def randomized_we_are_jitted_strategy(): +""" a Hypothesis strategy to test functions that rely on we_are_jitted(). +At runtime, we_are_jitted() can either return True of False, in a somewhat +hard to predict way. The functionality of the interpreter should never +really depend on the value of the returned bool. To test this, hypothesis +can be used with this strategy, in the following way: + +@given(randomized_we_are_jitted_strategy()) +def test_something(_ignored): +# in here, we_are_jitted() randomly returns True or False. +# the test is run many times to try to make it fail. + +(the implementation, however, is a bit of a hack). +""" +from hypothesis import strategies +return strategies.builds(_randomize_we_are_jitted_from, strategies.data()) + + _we_are_jitted = CDefinedIntSymbolic('0 /* we are not jitted here */', default=0) diff --git a/rpython/rlib/test/test_jit.py b/rpython/rlib/test/test_jit.py --- a/rpython/rlib/test/test_jit.py +++ b/rpython/rlib/test/test_jit.py @@ -5,7 +5,7 @@ from rpython.rlib.jit import (hint, we_are_jitted, JitDriver, elidable_promote, JitHintError, oopspec, isconstant, conditional_call, elidable, unroll_safe, dont_look_inside, -enter_portal_frame, leave_portal_frame) +enter_portal_frame, leave_portal_frame, randomized_we_are_jitted_strategy) from rpython.rlib.rarithmetic import r_uint from rpython.rtyper.test.tool import BaseRtypingTest from rpython.rtyper.lltypesystem import lltype @@ -115,6 +115,32 @@ def f(): pass +def test_randomized_we_are_jitted(): +from hypothesis import given +def good(): +if we_are_jitted(): +return 1 +return 1 +counter = [0] +def bad(): +if we_are_jitted(): +return 2 +return 1 +@given(randomized_we_are_jitted_strategy()) +def test_random_good(_): +assert good() == 1 +test_random_good() + +@given(randomized_we_are_jitted_strategy()) +def test_random_bad(_): +assert bad() == 1 +try: +test_random_bad() +except AssertionError: +pass +else: +assert 0, "should have failed!" + class TestJIT(BaseRtypingTest): def test_hint(self): def f(): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy guard-compatible: merge
Author: Carl Friedrich Bolz Branch: guard-compatible Changeset: r85130:febecdcd73b2 Date: 2016-06-13 15:50 +0200 http://bitbucket.org/pypy/pypy/changeset/febecdcd73b2/ Log:merge diff --git a/pypy/objspace/std/callmethod.py b/pypy/objspace/std/callmethod.py --- a/pypy/objspace/std/callmethod.py +++ b/pypy/objspace/std/callmethod.py @@ -48,11 +48,15 @@ name = None if jit.we_are_jitted(): # compute safeness without reading the type -map = w_obj._get_mapdict_map_no_promote() -if map is not None and map._type_safe_to_do_getattr(): -safe = True -name = space.str_w(w_name) -w_descr = map._type_lookup_safe(name) +try: +map = w_obj._get_mapdict_map_no_promote() +except TypeError: +pass +else: +if map._type_safe_to_do_getattr(): +safe = True +name = space.str_w(w_name) +w_descr = map._type_lookup_safe(name) else: w_type = space.type(w_obj) safe = w_type.has_object_getattribute() @@ -143,10 +147,14 @@ w_descr = None if jit.we_are_jitted(): # compute safeness without reading the type -map = w_obj._get_mapdict_map_no_promote() -if map is not None and map._type_safe_to_do_getattr(): -safe = True -w_descr = map._type_lookup_safe(methname) +try: +map = w_obj._get_mapdict_map_no_promote() +except TypeError: +pass +else: +if map._type_safe_to_do_getattr(): +safe = True +w_descr = map._type_lookup_safe(methname) else: w_type = space.type(w_obj) safe = w_type.has_object_getattribute() 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 @@ -535,11 +535,15 @@ safe = False if jit.we_are_jitted(): # compute safeness without reading the type -map = w_obj._get_mapdict_map_no_promote() -if map is not None and map._type_safe_to_do_getattr(): -safe = True -name = self.str_w(w_name) -w_descr = map._type_lookup_safe(name) +try: +map = w_obj._get_mapdict_map_no_promote() +except TypeError: +pass +else: +if map._type_safe_to_do_getattr(): +safe = True +name = self.str_w(w_name) +w_descr = map._type_lookup_safe(name) if not safe: w_type = self.type(w_obj) diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py --- a/rpython/rlib/jit.py +++ b/rpython/rlib/jit.py @@ -1,4 +1,5 @@ import sys +import random import py @@ -381,7 +382,9 @@ def we_are_jitted(): """ Considered as true during tracing and blackholing, so its consquences are reflected into jitted code """ -return False +# during testing we return something randomly, to emulate the real +# behaviour where you can switch to tracing a arbitrary points. +return random.random() > 0.5 _we_are_jitted = CDefinedIntSymbolic('0 /* we are not jitted here */', default=0) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy guard-compatible: (arigo, cfbolz): to make the tests check both paths, return True or False
Author: Carl Friedrich Bolz Branch: guard-compatible Changeset: r85127:d3b59f1f5ac9 Date: 2016-05-24 10:54 +0200 http://bitbucket.org/pypy/pypy/changeset/d3b59f1f5ac9/ Log:(arigo, cfbolz): to make the tests check both paths, return True or False randomly from we_are_jitted diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py --- a/rpython/rlib/jit.py +++ b/rpython/rlib/jit.py @@ -1,4 +1,5 @@ import sys +import random import py @@ -381,7 +382,9 @@ def we_are_jitted(): """ Considered as true during tracing and blackholing, so its consquences are reflected into jitted code """ -return False +# during testing we return something randomly, to emulate the real +# behaviour where you can switch to tracing a arbitrary points. +return random.random() > 0.5 _we_are_jitted = CDefinedIntSymbolic('0 /* we are not jitted here */', default=0) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy guard-compatible: deal with TypeErrors in we_are_jitted() blocks correctly
Author: Carl Friedrich Bolz Branch: guard-compatible Changeset: r85128:4d70d977e2f2 Date: 2016-05-24 10:57 +0200 http://bitbucket.org/pypy/pypy/changeset/4d70d977e2f2/ Log:deal with TypeErrors in we_are_jitted() blocks correctly diff --git a/pypy/objspace/std/callmethod.py b/pypy/objspace/std/callmethod.py --- a/pypy/objspace/std/callmethod.py +++ b/pypy/objspace/std/callmethod.py @@ -48,11 +48,15 @@ name = None if jit.we_are_jitted(): # compute safeness without reading the type -map = w_obj._get_mapdict_map_no_promote() -if map is not None and map._type_safe_to_do_getattr(): -safe = True -name = space.str_w(w_name) -w_descr = map._type_lookup_safe(name) +try: +map = w_obj._get_mapdict_map_no_promote() +except TypeError: +pass +else: +if map._type_safe_to_do_getattr(): +safe = True +name = space.str_w(w_name) +w_descr = map._type_lookup_safe(name) else: w_type = space.type(w_obj) safe = w_type.has_object_getattribute() @@ -143,10 +147,14 @@ w_descr = None if jit.we_are_jitted(): # compute safeness without reading the type -map = w_obj._get_mapdict_map_no_promote() -if map is not None and map._type_safe_to_do_getattr(): -safe = True -w_descr = map._type_lookup_safe(methname) +try: +map = w_obj._get_mapdict_map_no_promote() +except TypeError: +pass +else: +if map._type_safe_to_do_getattr(): +safe = True +w_descr = map._type_lookup_safe(methname) else: w_type = space.type(w_obj) safe = w_type.has_object_getattribute() 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 @@ -535,11 +535,15 @@ safe = False if jit.we_are_jitted(): # compute safeness without reading the type -map = w_obj._get_mapdict_map_no_promote() -if map is not None and map._type_safe_to_do_getattr(): -safe = True -name = self.str_w(w_name) -w_descr = map._type_lookup_safe(name) +try: +map = w_obj._get_mapdict_map_no_promote() +except TypeError: +pass +else: +if map._type_safe_to_do_getattr(): +safe = True +name = self.str_w(w_name) +w_descr = map._type_lookup_safe(name) if not safe: w_type = self.type(w_obj) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy guard-compatible: merge default
Author: Carl Friedrich Bolz Branch: guard-compatible Changeset: r85129:6ead2971b58b Date: 2016-06-13 15:49 +0200 http://bitbucket.org/pypy/pypy/changeset/6ead2971b58b/ Log:merge default diff too long, truncating to 2000 out of 16968 lines diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -22,3 +22,7 @@ bbd45126bc691f669c4ebdfbd74456cd274c6b92 release-5.0.1 3260adbeba4a8b6659d1cc0d0b41f266769b74da release-5.1 b0a649e90b6642251fb4a765fe5b27a97b1319a9 release-5.1.1 +80ef432a32d9baa4b3c5a54c215e8ebe499f6374 release-5.1.2 +40497617ae91caa1a394d8be6f9cd2de31cb0628 release-pypy3.3-v5.2 +40497617ae91caa1a394d8be6f9cd2de31cb0628 release-pypy3.3-v5.2 +c09c19272c990a0611b17569a0085ad1ab00c8ff release-pypy2.7-v5.3 diff --git a/LICENSE b/LICENSE --- a/LICENSE +++ b/LICENSE @@ -43,17 +43,17 @@ Samuele Pedroni Matti Picus Alex Gaynor + Philip Jenvey Brian Kearns - Philip Jenvey + Ronan Lamy Michael Hudson - Ronan Lamy + Manuel Jacob David Schneider - Manuel Jacob Holger Krekel Christian Tismer Hakan Ardo + Richard Plangger Benjamin Peterson - Richard Plangger Anders Chrigstrom Eric van Riet Paap Wim Lavrijsen @@ -93,9 +93,9 @@ stian Jan de Mooij Tyler Wade + Vincent Legoll Michael Foord Stephan Diehl - Vincent Legoll Stefan Schwarzer Valentino Volonghi Tomek Meka @@ -104,17 +104,20 @@ Bruno Gola David Malcolm Jean-Paul Calderone + Mark Young Timo Paulssen Squeaky + Devin Jeanpierre Marius Gedminas Alexandre Fayolle Simon Burton + Stefano Rivera Martin Matusiak Konstantin Lopuhin - Stefano Rivera Wenzhu Man John Witulski Laurence Tratt + Raffael Tfirst Ivan Sichmann Freitas Greg Price Dario Bertini @@ -122,13 +125,13 @@ Simon Cross Edd Barrett Andreas Stührk + Tobias Pape Jean-Philippe St. Pierre Guido van Rossum Pavel Vinogradov Spenser Bauman Jeremy Thurgood Paweł Piotr Przeradowski - Tobias Pape Paul deGrandis Ilya Osadchiy marky1991 @@ -140,7 +143,6 @@ Georg Brandl Bert Freudenberg Stian Andreassen - Mark Young Wanja Saatkamp Gerald Klix Mike Blume @@ -156,11 +158,13 @@ Dusty Phillips Lukas Renggli Guenter Jantzen + William Leslie Ned Batchelder Tim Felgentreff Anton Gulenko Amit Regmi Ben Young + Sergey Matyunin Nicolas Chauvat Andrew Durdin Andrew Chambers @@ -171,9 +175,9 @@ Yichao Yu Rocco Moretti Gintautas Miliauskas - Devin Jeanpierre Michael Twomey Lucian Branescu Mihaila + anatoly techtonik Gabriel Lavoie Olivier Dormond Jared Grubb @@ -183,8 +187,6 @@ Brian Dorsey Victor Stinner Andrews Medina - anatoly techtonik - Sergey Matyunin Stuart Williams Jasper Schulz Christian Hudon @@ -208,11 +210,11 @@ Alex Perry Vaibhav Sood Alan McIntyre - William Leslie Alexander Sedov Attila Gobi Jasper.Schulz Christopher Pope + Florin Papa Christian Tismer Marc Abramowitz Dan Stromberg @@ -228,7 +230,6 @@ Lukas Vacek Kunal Grover Andrew Dalke - Florin Papa Sylvain Thenault Jakub Stasiak Nathan Taylor @@ -270,8 +271,9 @@ Yury V. Zaytsev Anna Katrina Dominguez Bobby Impollonia - t...@eistee.fritz.box + Vasantha Ganesh K Andrew Thompson + florinpapa Yusei Tahara Aaron Tubbs Ben Darnell @@ -295,9 +297,9 @@ Akira Li Gustavo Niemeyer Stephan Busemann - florinpapa Rafał Gałczyński Matt Bogosian + timo Christian Muirhead Berker Peksag James Lan 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 @@ -834,54 +834,63 @@ c2pread, c2pwrite = None, None errread, errwrite = None, None +ispread = False if stdin is None: p2cread = _subprocess.GetStdHandle(_subprocess.STD_INPUT_HANDLE) if p2cread is None: p2cread, _ = _subprocess.CreatePipe(None, 0) +ispread = True elif stdin == PIPE: p2cread, p2cwrite = _subprocess.CreatePipe(None, 0) +ispread = True elif isinstance(stdin, int): p2cread = msvcrt.get_osfhandle(stdin) else: # Assuming file-like object p2cread = msvcrt.get_osfhandle(stdin.fileno()) -p2cread = self._make_inheritable(p2cread) +p2cread = self._make_inheritable(p2cread, ispread) # We just duplicated the handle, it has to be closed at the end to_close.add(p2cread) if stdin == PIPE: to_close.add(p2cwrite) +ispwrite = False if stdout is None: c2pwrite = _subprocess.GetStdHandle(_subprocess.STD_OUTPUT_HANDLE) if c2pwrite is None: _, c2pwrite = _subprocess.Cre
[pypy-commit] pypy hypothesis-apptest: unbreak regular execution
Author: Carl Friedrich Bolz Branch: hypothesis-apptest Changeset: r85131:8261a2709a7c Date: 2016-06-13 16:44 +0200 http://bitbucket.org/pypy/pypy/changeset/8261a2709a7c/ Log:unbreak regular execution diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py --- a/rpython/rlib/jit.py +++ b/rpython/rlib/jit.py @@ -325,6 +325,8 @@ hop.exception_cannot_occur() return hop.genop('hint', [v, c_hint], resulttype=v.concretetype) +_hypothesis_data = None + def we_are_jitted(): """ Considered as true during tracing and blackholing, so its consquences are reflected into jitted code """ diff --git a/rpython/rlib/test/test_jit.py b/rpython/rlib/test/test_jit.py --- a/rpython/rlib/test/test_jit.py +++ b/rpython/rlib/test/test_jit.py @@ -121,11 +121,12 @@ if we_are_jitted(): return 1 return 1 -counter = [0] def bad(): if we_are_jitted(): return 2 return 1 +assert good() == 1 +assert bad() == 1 @given(randomized_we_are_jitted_strategy()) def test_random_good(_): assert good() == 1 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Issue #2324: fix for bytearray().replace('a', 'ab')
Author: Armin Rigo Branch: Changeset: r85132:41928beccff9 Date: 2016-06-13 17:26 +0200 http://bitbucket.org/pypy/pypy/changeset/41928beccff9/ Log:Issue #2324: fix for bytearray().replace('a', 'ab') We have too much mess and code duplication around here. diff --git a/pypy/objspace/std/stringmethods.py b/pypy/objspace/std/stringmethods.py --- a/pypy/objspace/std/stringmethods.py +++ b/pypy/objspace/std/stringmethods.py @@ -162,7 +162,8 @@ buffer = _get_buffer(space, w_sub) res = count(value, buffer, start, end) -return space.wrap(max(res, 0)) +assert res >= 0 +return space.wrap(res) def descr_decode(self, space, w_encoding=None, w_errors=None): from pypy.objspace.std.unicodeobject import ( diff --git a/pypy/objspace/std/test/test_bytearrayobject.py b/pypy/objspace/std/test/test_bytearrayobject.py --- a/pypy/objspace/std/test/test_bytearrayobject.py +++ b/pypy/objspace/std/test/test_bytearrayobject.py @@ -211,6 +211,7 @@ check(bytearray('abc').replace('b', bytearray('d')), 'adc') check(bytearray('abc').replace('b', 'd'), 'adc') +check(bytearray('').replace('a', 'ab'), '') check(bytearray('abc').upper(), 'ABC') check(bytearray('ABC').lower(), 'abc') diff --git a/rpython/rlib/rstring.py b/rpython/rlib/rstring.py --- a/rpython/rlib/rstring.py +++ b/rpython/rlib/rstring.py @@ -291,6 +291,7 @@ return _search(value, other, start, end, SEARCH_COUNT) # -- substring searching helper +# XXX a lot of code duplication with lltypesystem.rstr :-( SEARCH_COUNT = 0 SEARCH_FIND = 1 @@ -309,6 +310,8 @@ if end > len(value): end = len(value) if start > end: +if mode == SEARCH_COUNT: +return 0 return -1 count = 0 @@ -326,6 +329,8 @@ w = n - m if w < 0: +if mode == SEARCH_COUNT: +return 0 return -1 mlast = m - 1 @@ -570,18 +575,20 @@ class ByteListBuilder(object): def __init__(self, init_size=INIT_SIZE): +assert init_size >= 0 self.l = newlist_hint(init_size) @specialize.argtype(1) def append(self, s): +l = self.l for c in s: -self.l.append(c) +l.append(c) @specialize.argtype(1) def append_slice(self, s, start, end): -assert 0 <= start <= end <= len(s) -for c in s[start:end]: -self.l.append(c) +l = self.l +for i in xrange(start, end): +l.append(s[i]) def append_multiple_char(self, c, times): assert isinstance(c, str) @@ -589,8 +596,9 @@ def append_charpsize(self, s, size): assert size >= 0 +l = self.l for i in xrange(size): -self.l.append(s[i]) +l.append(s[i]) def build(self): return self.l diff --git a/rpython/rlib/test/test_rstring.py b/rpython/rlib/test/test_rstring.py --- a/rpython/rlib/test/test_rstring.py +++ b/rpython/rlib/test/test_rstring.py @@ -231,6 +231,10 @@ check_search(count, 'one two three', 'e', 0, 1, res=0) check_search(count, 'one two three', '', 0, 13, res=14) +check_search(count, '', 'ab', 0, 0, res=0) +check_search(count, 'a', 'ab', 0, 1, res=0) +check_search(count, 'ac', 'ab', 0, 2, res=0) + class TestTranslates(BaseRtypingTest): def test_split_rsplit(self): 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 @@ -972,6 +972,13 @@ s.count(s, -10) py.test.raises(AnnotatorError, self.interpret, f, ()) +def test_count_in_empty_string(self): +const = self.const +def fn(): +return const('').count(const('ab')) +res = self.interpret(fn, []) +assert res == 0 + def test_getitem_exc(self): const = self.const def f(x): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy testing-cleanup-py3k: Don't attempt to modify sys.filesystemencoding; skip tests instead if it's not good enough
Author: Ronan Lamy Branch: testing-cleanup-py3k Changeset: r85133:0814a8d50e58 Date: 2016-06-13 16:30 +0100 http://bitbucket.org/pypy/pypy/changeset/0814a8d50e58/ Log:Don't attempt to modify sys.filesystemencoding; skip tests instead if it's not good enough 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 @@ -1180,25 +1180,19 @@ res = os.system(cmd) assert res == 0 +@py.test.fixture +def check_fsencoding(space, pytestconfig): +if pytestconfig.getvalue('runappdirect'): +fsencoding = sys.getfilesystemencoding() +else: +fsencoding = space.sys.filesystemencoding +try: +u"ą".encode(fsencoding) +except UnicodeEncodeError: +py.test.skip("encoding not good enough") +@py.test.mark.usefixtures('check_fsencoding') class AppTestPosixUnicode: -def setup_class(cls): -if cls.runappdirect: -# Can't change encoding -try: -u"ą".encode(sys.getfilesystemencoding()) -except UnicodeEncodeError: -py.test.skip("encoding not good enough") -else: -cls.save_fs_encoding = cls.space.sys.filesystemencoding -cls.space.sys.filesystemencoding = "utf-8" - -def teardown_class(cls): -try: -cls.space.sys.filesystemencoding = cls.save_fs_encoding -except AttributeError: -pass - def test_stat_unicode(self): # test that passing unicode would not raise UnicodeDecodeError import posix ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: hg merge default
Author: Ronan Lamy Branch: py3k Changeset: r85135:fef0c44d0976 Date: 2016-06-13 16:50 +0100 http://bitbucket.org/pypy/pypy/changeset/fef0c44d0976/ Log:hg 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 @@ -5,6 +5,9 @@ .. this is a revision shortly after release-pypy2.7-v5.3 .. startrev: 873218a739f1 +.. pull request #455 +Add sys.{get,set}dlopenflags, for cpyext extensions. + .. branch: fix-gen-dfa Resolves an issue with the generator script to build the dfa for Python syntax. @@ -19,3 +22,12 @@ .. branch: s390x-5.3-catchup Implement the backend related changes for s390x. + +.. branch: incminimark-ll_assert +.. branch: vmprof-openbsd + +.. branch: testing-cleanup + +Simplify handling of interp-level tests and make it more forward- +compatible. + diff --git a/pypy/interpreter/astcompiler/test/test_compiler.py b/pypy/interpreter/astcompiler/test/test_compiler.py --- a/pypy/interpreter/astcompiler/test/test_compiler.py +++ b/pypy/interpreter/astcompiler/test/test_compiler.py @@ -1203,7 +1203,7 @@ def test_const_fold_unicode_subscr(self, monkeypatch): source = """def f(): -return "abc"[0] +return u"abc"[0] """ counts = self.count_instructions(source) if 0: # xxx later? @@ -1211,14 +1211,14 @@ # getitem outside of the BMP should not be optimized source = """def f(): -return "\U00012345"[0] +return u"\U00012345"[0] """ counts = self.count_instructions(source) assert counts == {ops.LOAD_CONST: 2, ops.BINARY_SUBSCR: 1, ops.RETURN_VALUE: 1} source = """def f(): -return "\U00012345abcdef"[3] +return u"\U00012345abcdef"[3] """ counts = self.count_instructions(source) assert counts == {ops.LOAD_CONST: 2, ops.BINARY_SUBSCR: 1, @@ -1226,7 +1226,7 @@ monkeypatch.setattr(optimize, "MAXUNICODE", 0x) source = """def f(): -return "\uE01F"[0] +return u"\uE01F"[0] """ counts = self.count_instructions(source) if 0: # xxx later? @@ -1236,7 +1236,7 @@ # getslice is not yet optimized. # Still, check a case which yields the empty string. source = """def f(): -return "abc"[:0] +return u"abc"[:0] """ counts = self.count_instructions(source) assert counts == {ops.LOAD_CONST: 3, ops.BUILD_SLICE: 1, diff --git a/pypy/module/__pypy__/interp_intop.py b/pypy/module/__pypy__/interp_intop.py --- a/pypy/module/__pypy__/interp_intop.py +++ b/pypy/module/__pypy__/interp_intop.py @@ -2,21 +2,10 @@ from rpython.rtyper.lltypesystem import lltype from rpython.rtyper.lltypesystem.lloperation import llop from rpython.rlib.rarithmetic import r_uint, intmask +from rpython.rlib.rarithmetic import int_c_div, int_c_mod from rpython.rlib import jit -# XXX maybe temporary: hide llop.int_{floordiv,mod} from the JIT, -# because now it expects only Python-style divisions, not the -# C-style divisions of these two ll operations -@jit.dont_look_inside -def _int_floordiv(n, m): -return llop.int_floordiv(lltype.Signed, n, m) - -@jit.dont_look_inside -def _int_mod(n, m): -return llop.int_mod(lltype.Signed, n, m) - - @unwrap_spec(n=int, m=int) def int_add(space, n, m): return space.wrap(llop.int_add(lltype.Signed, n, m)) @@ -31,11 +20,11 @@ @unwrap_spec(n=int, m=int) def int_floordiv(space, n, m): -return space.wrap(_int_floordiv(n, m)) +return space.wrap(int_c_div(n, m)) @unwrap_spec(n=int, m=int) def int_mod(space, n, m): -return space.wrap(_int_mod(n, m)) +return space.wrap(int_c_mod(n, m)) @unwrap_spec(n=int, m=int) def int_lshift(space, n, m): diff --git a/pypy/module/_cffi_backend/ccallback.py b/pypy/module/_cffi_backend/ccallback.py --- a/pypy/module/_cffi_backend/ccallback.py +++ b/pypy/module/_cffi_backend/ccallback.py @@ -220,6 +220,11 @@ if rffi.cast(lltype.Signed, res) != clibffi.FFI_OK: raise oefmt(space.w_SystemError, "libffi failed to build this callback") +if closure_ptr.c_user_data != unique_id: +raise oefmt(space.w_SystemError, +"ffi_prep_closure(): bad user_data (it seems that the " +"version of the libffi library seen at runtime is " +"different from the 'ffi.h' file seen at compile-time)") def py_invoke(self, ll_res, ll_args): jitdriver1.jit_merge_point(callback=self, 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 @@ -1516,7 +1516,7 @@ try: ll_libname = rffi.str2charp(path) try: -dll = rdynload.dlopen(ll_libname) +dll = rdynload.dlopen(ll_libname, space.sys.dlopenflags)
[pypy-commit] pypy py3k: Merge branch 'testing-cleanup-py3k'
Author: Ronan Lamy Branch: py3k Changeset: r85134:8028f6e5a9c9 Date: 2016-06-13 16:35 +0100 http://bitbucket.org/pypy/pypy/changeset/8028f6e5a9c9/ Log:Merge branch 'testing-cleanup-py3k' diff --git a/pypy/conftest.py b/pypy/conftest.py --- a/pypy/conftest.py +++ b/pypy/conftest.py @@ -94,6 +94,20 @@ def pytest_pycollect_makemodule(path, parent): return PyPyModule(path, parent) +def is_applevel(item): +from pypy.tool.pytest.apptest import AppTestFunction +return isinstance(item, AppTestFunction) + +def pytest_collection_modifyitems(config, items): +if config.option.runappdirect: +return +for item in items: +if isinstance(item, py.test.Function): +if is_applevel(item): +item.add_marker('applevel') +else: +item.add_marker('interplevel') + class PyPyModule(py.test.collect.Module): """ we take care of collecting classes both at app level and at interp-level (because we need to stick a space @@ -128,9 +142,6 @@ if name.startswith('AppTest'): from pypy.tool.pytest.apptest import AppClassCollector return AppClassCollector(name, parent=self) -else: -from pypy.tool.pytest.inttest import IntClassCollector -return IntClassCollector(name, parent=self) elif hasattr(obj, 'func_code') and self.funcnamefilter(name): if name.startswith('app_test_'): @@ -138,11 +149,7 @@ "generator app level functions? you must be joking" from pypy.tool.pytest.apptest import AppTestFunction return AppTestFunction(name, parent=self) -elif obj.func_code.co_flags & 32: # generator function -return pytest.Generator(name, parent=self) -else: -from pypy.tool.pytest.inttest import IntTestFunction -return IntTestFunction(name, parent=self) +return super(PyPyModule, self).makeitem(name, obj) def skip_on_missing_buildoption(**ropts): __tracebackhide__ = True @@ -171,28 +178,19 @@ def pytest_runtest_setup(__multicall__, item): if isinstance(item, py.test.collect.Function): -appclass = item.getparent(PyPyClassCollector) +appclass = item.getparent(py.test.Class) if appclass is not None: # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', None) if spaceconfig is not None: from pypy.tool.pytest.objspace import gettestobjspace appclass.obj.space = gettestobjspace(**spaceconfig) +else: +appclass.obj.space = LazyObjSpaceGetter() appclass.obj.runappdirect = option.runappdirect __multicall__.execute() -class PyPyClassCollector(py.test.collect.Class): -# All pypy Test classes have a "space" member. -def setup(self): -cls = self.obj -if not hasattr(cls, 'spaceconfig'): -cls.space = LazyObjSpaceGetter() -else: -assert hasattr(cls, 'space') # set by pytest_runtest_setup -super(PyPyClassCollector, self).setup() - - def pytest_ignore_collect(path): return path.check(link=1) diff --git a/pypy/interpreter/astcompiler/test/test_compiler.py b/pypy/interpreter/astcompiler/test/test_compiler.py --- a/pypy/interpreter/astcompiler/test/test_compiler.py +++ b/pypy/interpreter/astcompiler/test/test_compiler.py @@ -965,7 +965,20 @@ """ self.simple_test(source, 'ok', 1) -def test_remove_docstring(self): +@py.test.mark.parametrize('expr, result', [ +("f1.__doc__", None), +("f2.__doc__", 'docstring'), +("f2()", 'docstring'), +("f3.__doc__", None), +("f3()", 'bar'), +("C1.__doc__", None), +("C2.__doc__", 'docstring'), +("C3.field", 'not docstring'), +("C4.field", 'docstring'), +("C4.__doc__", 'docstring'), +("C4.__doc__", 'docstring'), +("__doc__", None),]) +def test_remove_docstring(self, expr, result): source = '"module_docstring"\n' + """if 1: def f1(): 'docstring' @@ -989,19 +1002,7 @@ code_w.remove_docstrings(self.space) dict_w = self.space.newdict(); code_w.exec_code(self.space, dict_w, dict_w) - -yield self.check, dict_w, "f1.__doc__", None -yield self.check, dict_w, "f2.__doc__", 'docstring' -yield self.check, dict_w, "f2()", 'docstring' -yield self.check, dict_w, "f3.__doc__", None -yield self.check, dict_w, "f3()", 'bar' -yield self.check, dict_w, "C1.__doc__", None -yield self.check, dict_w, "C2.__doc__", 'docstring' -yield self.check, dict_w, "C3.field", 'not docstring' -yield self.check, dict_w, "C4.field", 'docstring' -yield self.check, dict_w, "C4.__doc__",
[pypy-commit] pypy guard-compatible: fix merge
Author: Carl Friedrich Bolz Branch: guard-compatible Changeset: r85136:de092081d81f Date: 2016-06-13 16:42 +0200 http://bitbucket.org/pypy/pypy/changeset/de092081d81f/ Log:fix merge 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 @@ -241,7 +241,7 @@ self._version_tag = version_tag self.terminator.mutated_w_cls_version(version_tag) -def getattribute_if_not_from_object(w_self): +def getattribute_if_not_from_object(self): """ this method returns the applevel __getattribute__ if that is not the one from object, in which case it returns None """ from pypy.objspace.descroperation import object_getattribute ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Improve CPython compatibility of 'is'. Now 'x is y' is guaranteed
Author: Armin Rigo Branch: Changeset: r85137:418b05f95db5 Date: 2016-06-13 19:07 +0200 http://bitbucket.org/pypy/pypy/changeset/418b05f95db5/ Log:Improve CPython compatibility of 'is'. Now 'x is y' is guaranteed to return True if x == y and x, y are: * empty strings; empty unicode strings * single-character (unicode) strings * empty tuples This is in addition to all other special cases (ints, etc.) diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py --- a/pypy/objspace/std/bytesobject.py +++ b/pypy/objspace/std/bytesobject.py @@ -18,6 +18,7 @@ from pypy.objspace.std.unicodeobject import ( decode_object, unicode_from_encoded_object, unicode_from_string, getdefaultencoding) +from pypy.objspace.std.util import IDTAG_SPECIAL, IDTAG_SHIFT class W_AbstractBytesObject(W_Root): @@ -30,12 +31,26 @@ return True if self.user_overridden_class or w_other.user_overridden_class: return False -return space.str_w(self) is space.str_w(w_other) +s1 = space.str_w(self) +s2 = space.str_w(w_other) +if len(s2) > 1: +return s1 is s2 +else:# strings of len <= 1 are unique-ified +return s1 == s2 def immutable_unique_id(self, space): if self.user_overridden_class: return None -return space.wrap(compute_unique_id(space.str_w(self))) +s = space.str_w(self) +if len(s) > 1: +uid = compute_unique_id(s) +else:# strings of len <= 1 are unique-ified +if len(s) == 1: +base = ord(s[0]) # base values 0-255 +else: +base = 256 # empty string: base value 256 +uid = (base << IDTAG_SHIFT) | IDTAG_SPECIAL +return space.wrap(uid) def unicode_w(self, space): # Use the default encoding. diff --git a/pypy/objspace/std/test/test_obj.py b/pypy/objspace/std/test/test_obj.py --- a/pypy/objspace/std/test/test_obj.py +++ b/pypy/objspace/std/test/test_obj.py @@ -186,17 +186,28 @@ def test_id_on_strs(self): if self.appdirect: skip("cannot run this test as apptest") -u = u"a" -assert id(self.unwrap_wrap_unicode(u)) == id(u) -s = "a" -assert id(self.unwrap_wrap_str(s)) == id(s) +for u in [u"", u"a", u"aa"]: +assert id(self.unwrap_wrap_unicode(u)) == id(u) +s = str(u) +assert id(self.unwrap_wrap_str(s)) == id(s) +# +assert id('') == (256 << 4) | 11 # always +assert id(u'') == (257 << 4) | 11 +assert id('a') == (ord('a') << 4) | 11 +assert id(u'\u1234') == ((~0x1234) << 4) | 11 + +def test_id_of_tuples(self): +l = [] +x = (l,) +assert id(x) != id((l,)) # no caching at all +if self.appdirect: +skip("cannot run this test as apptest") +assert id(()) == (258 << 4) | 11 # always def test_identity_vs_id_primitives(self): -if self.cpython_apptest: -skip("cpython behaves differently") import sys -l = range(-10, 10) -for i in range(10): +l = range(-10, 10, 2) +for i in [0, 1, 3]: l.append(float(i)) l.append(i + 0.1) l.append(long(i)) @@ -206,18 +217,13 @@ l.append(i - 1j) l.append(1 + i * 1j) l.append(1 - i * 1j) -s = str(i) -l.append(s) -u = unicode(s) -l.append(u) +l.append((i,)) l.append(-0.0) l.append(None) l.append(True) l.append(False) -s = "s" -l.append(s) -s = u"s" -l.append(s) +l.append(()) +l.append(tuple([])) for i, a in enumerate(l): for b in l[i:]: @@ -228,21 +234,18 @@ def test_identity_vs_id_str(self): if self.appdirect: skip("cannot run this test as apptest") -import sys -l = range(-10, 10) -for i in range(10): -s = str(i) +l = [] +def add(s, u): l.append(s) l.append(self.unwrap_wrap_str(s)) -u = unicode(s) +l.append(s[:1] + s[1:]) l.append(u) l.append(self.unwrap_wrap_unicode(u)) -s = "s" -l.append(s) -l.append(self.unwrap_wrap_str(s)) -s = u"s" -l.append(s) -l.append(self.unwrap_wrap_unicode(s)) +l.append(u[:1] + u[1:]) +for i in range(3, 18): +add(str(i), unicode(i)) +add("s", u"s") +add("", u"") for i, a in enumerate(l): for b in l[i:]: diff --git a/pypy/objspace/std/tupleobject.py b/pypy/objspace/std/tupleobject.py --- a/pypy/objspace/std/tupleobject.py +++ b/pypy/objs
[pypy-commit] pypy default: Document the new behavior of 'id/is' on str/unicode/tuple.
Author: Armin Rigo Branch: Changeset: r85138:dbd7b8e24c1b Date: 2016-06-13 19:30 +0200 http://bitbucket.org/pypy/pypy/changeset/dbd7b8e24c1b/ Log:Document the new behavior of 'id/is' on str/unicode/tuple. 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,13 +315,26 @@ - ``complex`` + - ``str`` (empty or single-character strings only) + + - ``unicode`` (empty or single-character strings only) + + - ``tuple`` (empty tuples only) + This change requires some changes to ``id`` as well. ``id`` fulfills the following condition: ``x is y <=> id(x) == id(y)``. Therefore ``id`` of the 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. +Note that strings of length 2 or greater can be equal without being +identical. Similarly, ``x is (2,)`` is not necessarily true even if +``x`` contains a tuple and ``x == (2,)``. The uniqueness rules apply +only to the particular cases described above. The ``str``, ``unicode`` +and ``tuple`` rules were added in PyPy 5.4; before that, a test like +``if x is "?"`` or ``if x is ()`` could fail even if ``x`` was equal to +``"?"`` or ``()``. The new behavior added in PyPy 5.4 is closer to +CPython's, which caches precisely the empty string, unicode and tuple, +and (sometimes!) the single-character strings and unicodes. Note that for floats there "``is``" only one object per "bit pattern" of the float. So ``float('nan') is float('nan')`` is true on PyPy, ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Add id/is support to the empty frozenset, similar to the empty tuple
Author: Armin Rigo Branch: Changeset: r85139:b80452987110 Date: 2016-06-13 19:40 +0200 http://bitbucket.org/pypy/pypy/changeset/b80452987110/ Log:Add id/is support to the empty frozenset, similar to the empty tuple 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 @@ -321,6 +321,8 @@ - ``tuple`` (empty tuples only) + - ``frozenset`` (empty frozenset only) + This change requires some changes to ``id`` as well. ``id`` fulfills the following condition: ``x is y <=> id(x) == id(y)``. Therefore ``id`` of the above types will return a value that is computed from the argument, and can @@ -329,12 +331,13 @@ Note that strings of length 2 or greater can be equal without being identical. Similarly, ``x is (2,)`` is not necessarily true even if ``x`` contains a tuple and ``x == (2,)``. The uniqueness rules apply -only to the particular cases described above. The ``str``, ``unicode`` -and ``tuple`` rules were added in PyPy 5.4; before that, a test like -``if x is "?"`` or ``if x is ()`` could fail even if ``x`` was equal to -``"?"`` or ``()``. The new behavior added in PyPy 5.4 is closer to -CPython's, which caches precisely the empty string, unicode and tuple, -and (sometimes!) the single-character strings and unicodes. +only to the particular cases described above. The ``str``, ``unicode``, +``tuple`` and ``frozenset`` rules were added in PyPy 5.4; before that, a +test like ``if x is "?"`` or ``if x is ()`` could fail even if ``x`` was +equal to ``"?"`` or ``()``. The new behavior added in PyPy 5.4 is +closer to CPython's, which caches precisely the empty +string/unicode/tuple/frozenset, and (sometimes!) the single-character +strings and unicodes. Note that for floats there "``is``" only one object per "bit pattern" of the float. So ``float('nan') is float('nan')`` is true on PyPy, diff --git a/pypy/objspace/std/setobject.py b/pypy/objspace/std/setobject.py --- a/pypy/objspace/std/setobject.py +++ b/pypy/objspace/std/setobject.py @@ -6,6 +6,7 @@ from pypy.objspace.std.bytesobject import W_BytesObject from pypy.objspace.std.intobject import W_IntObject from pypy.objspace.std.unicodeobject import W_UnicodeObject +from pypy.objspace.std.util import IDTAG_SPECIAL, IDTAG_SHIFT from rpython.rlib.objectmodel import r_dict from rpython.rlib.objectmodel import iterkeys_with_hash, contains_with_hash @@ -575,6 +576,23 @@ class W_FrozensetObject(W_BaseSetObject): hash = 0 +def is_w(self, space, w_other): +if not isinstance(w_other, W_FrozensetObject): +return False +if self is w_other: +return True +if self.user_overridden_class or w_other.user_overridden_class: +return False +# empty frozensets are unique-ified +return 0 == w_other.length() == self.length() + +def immutable_unique_id(self, space): +if self.user_overridden_class or self.length() > 0: +return None +# empty frozenset: base value 259 +uid = (259 << IDTAG_SHIFT) | IDTAG_SPECIAL +return space.wrap(uid) + def _newobj(self, space, w_iterable): """Make a new frozenset by taking ownership of 'w_iterable'.""" if type(self) is W_FrozensetObject: diff --git a/pypy/objspace/std/test/test_obj.py b/pypy/objspace/std/test/test_obj.py --- a/pypy/objspace/std/test/test_obj.py +++ b/pypy/objspace/std/test/test_obj.py @@ -204,6 +204,14 @@ skip("cannot run this test as apptest") assert id(()) == (258 << 4) | 11 # always +def test_id_of_frozensets(self): +x = frozenset([4]) +assert id(x) != id(frozenset([4])) # no caching at all +if self.appdirect: +skip("cannot run this test as apptest") +assert id(frozenset()) == (259 << 4) | 11 # always +assert id(frozenset([])) == (259 << 4) | 11 # always + def test_identity_vs_id_primitives(self): import sys l = range(-10, 10, 2) @@ -218,12 +226,14 @@ l.append(1 + i * 1j) l.append(1 - i * 1j) l.append((i,)) +l.append(frozenset([i])) l.append(-0.0) l.append(None) l.append(True) l.append(False) l.append(()) l.append(tuple([])) +l.append(frozenset()) for i, a in enumerate(l): for b in l[i:]: 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 @@ -14,6 +14,7 @@ # 256: empty string # 257: empty unicode # 258: empty tuple + # 259: empty frozenset CMP_OPS = dict(lt='<', le='<=', eq='==', ne='!=', gt='>', ge='>=') BINARY_BITWISE_OPS = {'and': '&', 'lshift': '<<', 'or': '|', 'rshift': '>>', ___
[pypy-commit] pypy testing-cleanup: fix test_ndarrayobject: replace RPythonism with regular C
Author: Ronan Lamy Branch: testing-cleanup Changeset: r85140:bd32cf80bb35 Date: 2016-06-13 18:49 +0100 http://bitbucket.org/pypy/pypy/changeset/bd32cf80bb35/ Log:fix test_ndarrayobject: replace RPythonism with regular C 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 @@ -5,7 +5,7 @@ from rpython.rtyper.lltypesystem import rffi, lltype from pypy.module.micronumpy.ndarray import W_NDimArray from pypy.module.micronumpy.descriptor import get_dtype_cache -import pypy.module.micronumpy.constants as NPY +import pypy.module.micronumpy.constants as NPY def scalar(space): dtype = get_dtype_cache(space).w_float64dtype @@ -237,7 +237,7 @@ except: skip('numpy not importable') else: -numpy_incl = os.path.abspath(os.path.dirname(__file__) + +numpy_incl = os.path.abspath(os.path.dirname(__file__) + '/../include/_numpypy') assert os.path.exists(numpy_incl) cls.w_numpy_include = cls.space.wrap([numpy_incl]) @@ -273,7 +273,7 @@ { /* Should have failed */ Py_DECREF(obj1); -return NULL; +return NULL; } return obj1; ''' @@ -300,14 +300,14 @@ ), ("test_DescrFromType", "METH_O", """ -Signed typenum = PyInt_AsLong(args); +long typenum = PyInt_AsLong(args); return PyArray_DescrFromType(typenum); """ ), -], include_dirs=self.numpy_include, +], include_dirs=self.numpy_include, prologue=''' #ifdef PYPY_VERSION -#include +#include #endif #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION #include @@ -315,7 +315,7 @@ #define PyArray_FromObject _PyArray_FromObject #define PyArray_FromAny _PyArray_FromAny #endif -''', +''', more_init = ''' #ifndef PYPY_VERSION import_array(); @@ -349,14 +349,14 @@ Py_INCREF(obj); return obj; '''), -], include_dirs=self.numpy_include, +], include_dirs=self.numpy_include, prologue=''' #ifdef PYPY_VERSION -#include +#include #endif #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION #include -''', +''', more_init = ''' #ifndef PYPY_VERSION import_array(); @@ -403,14 +403,14 @@ void *array_data[] = {NULL, NULL}; return PyUFunc_FromFuncAndDataAndSignature(funcs, array_data, types, 1, 1, 1, PyUFunc_None, -"float_3x3", -"a ufunc that tests a more complicated signature", +"float_3x3", +"a ufunc that tests a more complicated signature", 0, "(m,m)->(m,m)"); """), -], include_dirs=self.numpy_include, +], include_dirs=self.numpy_include, prologue=''' #ifdef PYPY_VERSION -#include +#include #endif #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION #include @@ -480,7 +480,7 @@ res += +10; *((float *)args[1]) = res; }; - + ''', more_init = ''' #ifndef PYPY_VERSION import_array(); ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Mention this change in whatsnew-head
Author: Armin Rigo Branch: Changeset: r85141:66f63c100c7b Date: 2016-06-13 20:24 +0200 http://bitbucket.org/pypy/pypy/changeset/66f63c100c7b/ Log:Mention this change in whatsnew-head 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 @@ -5,6 +5,10 @@ .. this is a revision shortly after release-pypy2.7-v5.3 .. startrev: 873218a739f1 +.. 418b05f95db5 +Improve CPython compatibility for ``is``. Now code like ``if x is ():`` +works the same way as it does on CPython. See http://pypy.readthedocs.io/en/latest/cpython_differences.html#object-identity-of-primitive-values-is-and-id . + .. pull request #455 Add sys.{get,set}dlopenflags, for cpyext extensions. ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Fix test (after 4e4fa6046959, which gets rid of these unexpected
Author: Armin Rigo Branch: Changeset: r85142:8030d6268539 Date: 2016-06-13 21:06 +0200 http://bitbucket.org/pypy/pypy/changeset/8030d6268539/ Log:Fix test (after 4e4fa6046959, which gets rid of these unexpected getarrayitem_raw) diff --git a/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py b/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py --- a/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py +++ b/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py @@ -163,14 +163,10 @@ guard_not_invalidated(descr=...) i32 = float_ne(f31, 0.00) guard_true(i32, descr=...) -i34 = getarrayitem_raw_i(#, #, descr=) # XXX what are these? -guard_value(i34, #, descr=...) # XXX don't appear in -i35 = getarrayitem_raw_i(#, #, descr=) # XXX equiv test_zjit i36 = int_add(i24, 1) i37 = int_add(i29, 8) i38 = int_ge(i36, i30) guard_false(i38, descr=...) -guard_value(i35, #, descr=...) # XXX jump(..., descr=...) """) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: Remove state.ast_type double quotes to get old format back
Author: Raffael Tfirst Branch: py3.5 Changeset: r85143:6ed651b758f8 Date: 2016-06-13 21:05 +0200 http://bitbucket.org/pypy/pypy/changeset/6ed651b758f8/ Log:Remove state.ast_type double quotes to get old format back 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 @@ -204,7 +204,7 @@ _body = [stmt.from_object(space, w_item) for w_item in body_w] return Module(_body) -State.ast_type('Module', 'mod', ["'body'"]) +State.ast_type('Module', 'mod', ['body']) class Interactive(mod): @@ -237,7 +237,7 @@ _body = [stmt.from_object(space, w_item) for w_item in body_w] return Interactive(_body) -State.ast_type('Interactive', 'mod', ["'body'"]) +State.ast_type('Interactive', 'mod', ['body']) class Expression(mod): @@ -266,7 +266,7 @@ raise_required_value(space, w_node, 'body') return Expression(_body) -State.ast_type('Expression', 'mod', ["'body'"]) +State.ast_type('Expression', 'mod', ['body']) class Suite(mod): @@ -299,7 +299,7 @@ _body = [stmt.from_object(space, w_item) for w_item in body_w] return Suite(_body) -State.ast_type('Suite', 'mod', ["'body'"]) +State.ast_type('Suite', 'mod', ['body']) class stmt(AST): @@ -356,7 +356,7 @@ return Continue.from_object(space, w_node) raise oefmt(space.w_TypeError, "Expected stmt node, got %T", w_node) -State.ast_type('stmt', 'AST', None, ["'lineno'", "'col_offset'"]) +State.ast_type('stmt', 'AST', None, ['lineno', 'col_offset']) class FunctionDef(stmt): @@ -431,7 +431,7 @@ _col_offset = space.int_w(w_col_offset) return FunctionDef(_name, _args, _body, _decorator_list, _returns, _lineno, _col_offset) -State.ast_type('FunctionDef', 'stmt', ["'name'", "'args'", "'body'", "'decorator_list'", "'returns'"]) +State.ast_type('FunctionDef', 'stmt', ['name', 'args', 'body', 'decorator_list', 'returns']) class ClassDef(stmt): @@ -516,7 +516,7 @@ _col_offset = space.int_w(w_col_offset) return ClassDef(_name, _bases, _keywords, _body, _decorator_list, _lineno, _col_offset) -State.ast_type('ClassDef', 'stmt', ["'name'", "'bases'", "'keywords'", "'body'", "'decorator_list'"]) +State.ast_type('ClassDef', 'stmt', ['name', 'bases', 'keywords', 'body', 'decorator_list']) class Return(stmt): @@ -553,7 +553,7 @@ _col_offset = space.int_w(w_col_offset) return Return(_value, _lineno, _col_offset) -State.ast_type('Return', 'stmt', ["'value'"]) +State.ast_type('Return', 'stmt', ['value']) class Delete(stmt): @@ -595,7 +595,7 @@ _col_offset = space.int_w(w_col_offset) return Delete(_targets, _lineno, _col_offset) -State.ast_type('Delete', 'stmt', ["'targets'"]) +State.ast_type('Delete', 'stmt', ['targets']) class Assign(stmt): @@ -645,7 +645,7 @@ _col_offset = space.int_w(w_col_offset) return Assign(_targets, _value, _lineno, _col_offset) -State.ast_type('Assign', 'stmt', ["'targets'", "'value'"]) +State.ast_type('Assign', 'stmt', ['targets', 'value']) class AugAssign(stmt): @@ -698,7 +698,7 @@ _col_offset = space.int_w(w_col_offset) return AugAssign(_target, _op, _value, _lineno, _col_offset) -State.ast_type('AugAssign', 'stmt', ["'target'", "'op'", "'value'"]) +State.ast_type('AugAssign', 'stmt', ['target', 'op', 'value']) class For(stmt): @@ -768,7 +768,7 @@ _col_offset = space.int_w(w_col_offset) return For(_target, _iter, _body, _orelse, _lineno, _col_offset) -State.ast_type('For', 'stmt', ["'target'", "'iter'", "'body'", "'orelse'"]) +State.ast_type('For', 'stmt', ['target', 'iter', 'body', 'orelse']) class While(stmt): @@ -830,7 +830,7 @@ _col_offset = space.int_w(w_col_offset) return While(_test, _body, _orelse, _lineno, _col_offset) -State.ast_type('While', 'stmt', ["'test'", "'body'", "'orelse'"]) +State.ast_type('While', 'stmt', ['test', 'body', 'orelse']) class If(stmt): @@ -892,7 +892,7 @@ _col_offset = space.int_w(w_col_offset) return If(_test, _body, _orelse, _lineno, _col_offset) -State.ast_type('If', 'stmt', ["'test'", "'body'", "'orelse'"]) +State.ast_type('If', 'stmt', ['test', 'body', 'orelse']) class With(stmt): @@ -946,7 +946,7 @@ _col_offset = space.int_w(w_col_offset) return With(_items, _body, _lineno, _col_offset) -State.ast_type('With', 'stmt', ["'items'", "'body'"]) +State.ast_type('With', 'stmt', ['items', 'body']) class Raise(stmt): @@ -990,7 +990,7 @@ _col_offset = space.int_w(w_col_offset) return Raise(_exc, _cause, _lineno, _col_offset) -State.ast_type('Raise', 'stmt', ["'exc'", "'cause'"]) +State.ast_type('Raise', 'stmt', ['exc', 'cause']) class Try(stmt): @@ -1068,7 +1068,7 @@ _col_offset = space.int_w(w_col_of
[pypy-commit] pypy py3.5: Better way to fix the double quotes
Author: Raffael Tfirst Branch: py3.5 Changeset: r85144:caaa5d28bdd6 Date: 2016-06-13 21:21 +0200 http://bitbucket.org/pypy/pypy/changeset/caaa5d28bdd6/ Log:Better way to fix the double quotes 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 @@ -102,7 +102,7 @@ self.emit("raise oefmt(space.w_TypeError,", 2) self.emit("\"Expected %s node, got %%T\", w_node)" % (base,), 2) self.emit("State.ast_type(%r, 'AST', None, %s)" % - (base, [repr(attr.name)[1:-1] for attr in sum.attributes])) + (base, [attr.name for attr in sum.attributes])) self.emit("") for cons in sum.types: self.visit(cons, base, sum.attributes) @@ -119,7 +119,7 @@ self.emit("") self.make_converters(product.fields, name) self.emit("State.ast_type(%r, 'AST', %s)" % - (name, [repr(f.name)[1:-1] for f in product.fields])) + (name, [f.name for f in product.fields])) self.emit("") def get_value_converter(self, field, value): @@ -263,7 +263,7 @@ self.make_mutate_over(cons, cons.name) self.make_converters(cons.fields, cons.name, extra_attributes) self.emit("State.ast_type(%r, '%s', %s)" % - (cons.name, base, [repr(f.name)[1:-1] for f in cons.fields])) + (cons.name, base, [f.name for f in cons.fields])) self.emit("") def visitField(self, field): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Found a way in CPython to have several empty string objects.
Author: Armin Rigo Branch: Changeset: r85145:9417f63e9eff Date: 2016-06-13 21:29 +0200 http://bitbucket.org/pypy/pypy/changeset/9417f63e9eff/ Log:Found a way in CPython to have several empty string objects. 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 @@ -335,9 +335,8 @@ ``tuple`` and ``frozenset`` rules were added in PyPy 5.4; before that, a test like ``if x is "?"`` or ``if x is ()`` could fail even if ``x`` was equal to ``"?"`` or ``()``. The new behavior added in PyPy 5.4 is -closer to CPython's, which caches precisely the empty -string/unicode/tuple/frozenset, and (sometimes!) the single-character -strings and unicodes. +closer to CPython's, which caches precisely the empty tuple/frozenset, +and (generally but not always) the strings and unicodes of length <= 1. Note that for floats there "``is``" only one object per "bit pattern" of the float. So ``float('nan') is float('nan')`` is true on PyPy, ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: Return an arg (instead of identifier value) in handle arguments for STAR and DOUBLESTAR
Author: Raffael Tfirst Branch: py3.5 Changeset: r85146:4ed7839a6bd6 Date: 2016-06-13 21:51 +0200 http://bitbucket.org/pypy/pypy/changeset/4ed7839a6bd6/ Log:Return an arg (instead of identifier value) in handle arguments for STAR and DOUBLESTAR diff --git a/pypy/interpreter/astcompiler/astbuilder.py b/pypy/interpreter/astcompiler/astbuilder.py --- a/pypy/interpreter/astcompiler/astbuilder.py +++ b/pypy/interpreter/astcompiler/astbuilder.py @@ -570,9 +570,7 @@ kwonly = [] if n_kwdonly else None kwdefaults = [] kwarg = None -kwargann = None vararg = None -varargann = None if n_pos + n_kwdonly > 255: self.error("more than 255 arguments", arguments_node) # process args @@ -604,11 +602,7 @@ i = self.handle_keywordonly_args(arguments_node, i, kwonly, kwdefaults) else: -vararg = name_node.get_child(0).get_value() -vararg = self.new_identifier(vararg) -self.check_forbidden_name(vararg, name_node) -if name_node.num_children() > 1: -varargann = self.handle_expr(name_node.get_child(2)) +vararg = self.handle_arg(name_node) i += 3 if i < child_count: next_arg_type = arguments_node.get_child(i).type @@ -618,11 +612,7 @@ kwonly, kwdefaults) elif arg_type == tokens.DOUBLESTAR: name_node = arguments_node.get_child(i + 1) -kwarg = name_node.get_child(0).get_value() -kwarg = self.new_identifier(kwarg) -self.check_forbidden_name(kwarg, name_node) -if name_node.num_children() > 1: -kwargann = self.handle_expr(name_node.get_child(2)) +kwarg = self.handle_arg(name_node) i += 3 else: raise AssertionError("unknown node in argument list") ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: Remove vararg- and kwargannotation checks in visit_annotation for symtable
Author: Raffael Tfirst Branch: py3.5 Changeset: r85147:8cd46370914c Date: 2016-06-13 22:05 +0200 http://bitbucket.org/pypy/pypy/changeset/8cd46370914c/ Log:Remove vararg- and kwargannotation checks in visit_annotation for symtable 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 @@ -532,10 +532,6 @@ assert isinstance(args, ast.arguments) if args.args: self._visit_arg_annotations(args.args) -if args.varargannotation: -args.varargannotation.walkabout(self) -if args.kwargannotation: -args.kwargannotation.walkabout(self) if args.kwonlyargs: self._visit_arg_annotations(args.kwonlyargs) if func.returns: ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: Fix errors of identifier->arg change, remove more obsolete annotation checks
Author: Raffael Tfirst Branch: py3.5 Changeset: r85148:7297e4bad09b Date: 2016-06-13 22:34 +0200 http://bitbucket.org/pypy/pypy/changeset/7297e4bad09b/ Log:Fix errors of identifier->arg change, remove more obsolete annotation checks 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 @@ -352,13 +352,7 @@ space = self.space names = [] self._visit_arg_annotations(args.args, names) -if args.varargannotation: -self._visit_arg_annotation(args.vararg, args.varargannotation, - names) self._visit_arg_annotations(args.kwonlyargs, names) -if args.kwargannotation: -self._visit_arg_annotation(args.kwarg, args.kwargannotation, - names) self._visit_arg_annotation("return", returns, names) l = len(names) if l: 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 @@ -516,10 +516,10 @@ if arguments.kwonlyargs: self._handle_params(arguments.kwonlyargs, True) if arguments.vararg: -self.note_symbol(arguments.vararg, SYM_PARAM) +self.note_symbol(arguments.vararg.arg, SYM_PARAM) scope.note_variable_arg(arguments.vararg) if arguments.kwarg: -self.note_symbol(arguments.kwarg, SYM_PARAM) +self.note_symbol(arguments.kwarg.arg, SYM_PARAM) scope.note_keywords_arg(arguments.kwarg) def _handle_params(self, params, is_toplevel): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy gc-forkfriendly: Move some GC flags the JIT needs into where the JIT needs them (i.e. not remote_flags)
Author: Devin Jeanpierre Branch: gc-forkfriendly Changeset: r85149:bc8241225da0 Date: 2016-06-13 15:35 -0700 http://bitbucket.org/pypy/pypy/changeset/bc8241225da0/ Log:Move some GC flags the JIT needs into where the JIT needs them (i.e. not remote_flags) diff --git a/rpython/memory/gc/incminimark_remoteheader.py b/rpython/memory/gc/incminimark_remoteheader.py --- a/rpython/memory/gc/incminimark_remoteheader.py +++ b/rpython/memory/gc/incminimark_remoteheader.py @@ -8,6 +8,16 @@ SIGNEDP = lltype.Ptr(lltype.FixedSizeArray(lltype.Signed, 1)) +# HACK: because GCFLAG_CARDS_SET is checked in some ugly assembler, and the +# assembler is hardcoded to check the tid field. We special case that flag +# alone so that it can still be stored in tid! +# This should not really impact memory, because if a card is set, then the +# page was already mutated to add a young ptr, so there is no harm. It +# might mess with performance a little though. :) +# TODO: but why GCFLAG_TRACK_YOUNG_PTRS? +# (Only figured that one out by trial/error +NONREMOTE_FLAGS = incminimark.GCFLAG_TRACK_YOUNG_PTRS | incminimark.GCFLAG_CARDS_SET + class IncrementalMiniMarkRemoteHeaderGC(incminimark.IncrementalMiniMarkGCBase): # The GC header is similar to incminimark, except that the flags can be # placed anywhere, not just in the bits of tid. @@ -96,19 +106,29 @@ def get_flags(self, obj): self.__lazy_init_flags(obj) -return self.header(obj).remote_flags[0] +hdr = self.header(obj) +return hdr.remote_flags[0] | (hdr.tid & NONREMOTE_FLAGS) def set_flags(self, obj, flags): self.__lazy_init_flags(obj) -self.header(obj).remote_flags[0] = flags +hdr = self.header(obj) +hdr.remote_flags[0] = flags & ~incminimark.GCFLAG_CARDS_SET +if flags & NONREMOTE_FLAGS: +hdr.tid = (hdr.tid & ~NONREMOTE_FLAGS ) | (flags & NONREMOTE_FLAGS ) def add_flags(self, obj, flags): self.__lazy_init_flags(obj) -self.header(obj).remote_flags[0] |= flags +hdr = self.header(obj) +hdr.remote_flags[0] |= flags +if flags & NONREMOTE_FLAGS: +self.header(obj).tid |= (flags & NONREMOTE_FLAGS ) def remove_flags(self, obj, flags): self.__lazy_init_flags(obj) -self.header(obj).remote_flags[0] &= ~flags +hdr = self.header(obj) +hdr.remote_flags[0] &= ~flags +if flags & NONREMOTE_FLAGS: +self.header(obj).tid &= ~(flags & NONREMOTE_FLAGS ) def _free_flags_if_finalized(adr, unused_arg): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit