[pypy-commit] pypy default: Fix the test (shows up on big-endian machines)
Author: Armin Rigo Branch: Changeset: r84569:bf3e92056fa4 Date: 2016-05-22 11:32 +0200 http://bitbucket.org/pypy/pypy/changeset/bf3e92056fa4/ Log:Fix the test (shows up on big-endian machines) diff --git a/pypy/module/cpyext/test/test_typeobject.py b/pypy/module/cpyext/test/test_typeobject.py --- a/pypy/module/cpyext/test/test_typeobject.py +++ b/pypy/module/cpyext/test/test_typeobject.py @@ -744,7 +744,7 @@ int intval; PyObject *name; -if (!PyArg_ParseTuple(args, "l", &intval)) +if (!PyArg_ParseTuple(args, "i", &intval)) return NULL; IntLike_Type.tp_flags |= Py_TPFLAGS_DEFAULT; ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy guard-compatible: in-progress
Author: Armin Rigo Branch: guard-compatible Changeset: r84570:69e54b3e516d Date: 2016-05-22 13:42 +0200 http://bitbucket.org/pypy/pypy/changeset/69e54b3e516d/ Log:in-progress diff --git a/rpython/jit/backend/x86/guard_compat.py b/rpython/jit/backend/x86/guard_compat.py --- a/rpython/jit/backend/x86/guard_compat.py +++ b/rpython/jit/backend/x86/guard_compat.py @@ -1,14 +1,13 @@ from rpython.rlib import rgc -from rpython.rlib.objectmodel import we_are_translated +from rpython.rlib.objectmodel import specialize from rpython.rlib.rarithmetic import r_uint -from rpython.rtyper.lltypesystem import lltype, rffi -from rpython.jit.backend.x86.arch import WORD, IS_X86_32, IS_X86_64 -from rpython.jit.backend.x86 import rx86, codebuf, valgrind -from rpython.jit.backend.x86.regloc import X86_64_SCRATCH_REG, imm, eax, edx -from rpython.jit.backend.llsupport.asmmemmgr import MachineDataBlockWrapper -from rpython.jit.backend.llsupport.jitframe import GCMAP +from rpython.rtyper.lltypesystem import lltype, llmemory, rffi +from rpython.rtyper.lltypesystem.lloperation import llop +from rpython.rtyper.annlowlevel import cast_instance_to_gcref +from rpython.rtyper.annlowlevel import cast_gcref_to_instance +from rpython.translator.tool.cbuild import ExternalCompilationInfo +from rpython.jit.backend.llsupport import jitframe from rpython.jit.metainterp.compile import GuardCompatibleDescr -from rpython.jit.metainterp.history import BasicFailDescr # @@ -154,17 +153,75 @@ # -PAIR = lltype.Struct('PAIR', ('gcref', llmemory.GCREF, - 'asmaddr', lltype.Signed)) +PAIR = lltype.Struct('PAIR', ('gcref', llmemory.GCREF), + ('asmaddr', lltype.Signed)) BACKEND_CHOICES = lltype.GcStruct('BACKEND_CHOICES', ('bc_gcmap', lltype.Ptr(jitframe.GCMAP)), ('bc_faildescr', llmemory.GCREF), ('bc_most_recent', PAIR), ('bc_list', lltype.Array(PAIR))) +@specialize.memo() +def getofs(name): +return llmemory.offsetof(BACKEND_CHOICES, name) +BCLISTLENGTHOFS = llmemory.arraylengthoffset(BACKEND_CHOICES.bc_list) +BCLISTITEMSOFS = llmemory.itemoffsetof(BACKEND_CHOICES.bc_list, 0) +PAIRSIZE = llmemory.sizeof(PAIR) + +def _real_number(ofs):# hack +return rffi.cast(lltype.Signed, rffi.cast(lltype.Unsigned, ofs)) + +def bchoices_pair(gc, pair_addr, callback, arg): +gcref_addr = pair_addr + llmemory.offsetof(PAIR, 'gcref') +old = gcref_addr.unsigned[0] +if old != r_uint(-1): +gc._trace_callback(callback, arg, gcref_addr) +new = gcref_addr.unsigned[0] +return old != new + +def bchoices_trace(gc, obj_addr, callback, arg): +gc._trace_callback(callback, arg, obj_addr + getofs('bc_faildescr')) +bchoices_pair(gc, obj_addr + getofs('bc_most_recent'), callback, arg) +length = (obj_addr + getofs('bc_list') + BCLISTLENGTHOFS).signed[0] +array_addr = obj_addr + getofs('bc_list') + BCLISTITEMSOFS +item_addr = array_addr +i = 0 +changes = False +while i < length: +changes |= bchoices_pair(gc, item_addr, callback, arg) +item_addr += PAIRSIZE +if changes: +pairs_quicksort(array_addr, length) +lambda_bchoices_trace = lambda: bchoices_trace + +eci = ExternalCompilationInfo(separate_module_sources=[""" + +static int _pairs_compare(const void *p1, const void *p2) +{ +if (*(Unsigned *const *)p1 < *(Unsigned *const *)p2) +return -1; +else if (*(Unsigned *const *)p1 == *(Unsigned *const *)p2) +return 0; +else +return 1; +} +RPY_EXTERN +void pypy_pairs_quicksort(void *base_addr, Signed length) +{ +qsort(base_addr, length, 2 * sizeof(void *), _pairs_compare); +} +"""]) +pairs_quicksort = rffi.llexternal('pypy_pairs_quicksort', + [llmemory.Address, lltype.Signed], + lltype.Void, + sandboxsafe=True, + _nowrapper=True, + compilation_info=eci) + def invoke_find_compatible(bchoices, new_gcref): descr = bchoices.bc_faildescr +descr = cast_gcref_to_instance(GuardCompatibleDescr, descr) try: result = descr.find_compatible(cpu, new_gcref) if result == 0: @@ -181,10 +238,17 @@ return descr._backend_failure_recovery def add_in_tree(bchoices, new_gcref, new_asmaddr): +rgc.register_custom_trace_hook(BACKEND_CHOICES, lambda_bchoices_trace) length = len(bchoices.bc_list) -if bchoices.bc_list[length - 1] != -1: +# +gcref_base = lltype.cast_opaque_ptr(llmemory.GCREF, bchoices) +ofs = getofs('bc_list') + BCLISTITEMSOFS +ofs += (length - 1) * llmemory.sizeof(PAIR) +ofs = _real_number(ofs) +if llop.raw_load(lltype.Unsigned, gcref_base, ofs) != r_uint(-1): # reallocate -new_bc
[pypy-commit] pypy guard-compatible: Implement search_tree
Author: Armin Rigo Branch: guard-compatible Changeset: r84571:d0ffd51b5d0b Date: 2016-05-22 16:41 +0200 http://bitbucket.org/pypy/pypy/changeset/d0ffd51b5d0b/ Log:Implement search_tree diff --git a/rpython/jit/backend/x86/guard_compat.py b/rpython/jit/backend/x86/guard_compat.py --- a/rpython/jit/backend/x86/guard_compat.py +++ b/rpython/jit/backend/x86/guard_compat.py @@ -3,11 +3,14 @@ from rpython.rlib.rarithmetic import r_uint from rpython.rtyper.lltypesystem import lltype, llmemory, rffi from rpython.rtyper.lltypesystem.lloperation import llop -from rpython.rtyper.annlowlevel import cast_instance_to_gcref +from rpython.rtyper.annlowlevel import cast_instance_to_gcref, llhelper from rpython.rtyper.annlowlevel import cast_gcref_to_instance from rpython.translator.tool.cbuild import ExternalCompilationInfo +from rpython.jit.metainterp.compile import GuardCompatibleDescr from rpython.jit.backend.llsupport import jitframe -from rpython.jit.metainterp.compile import GuardCompatibleDescr +from rpython.jit.backend.x86 import rx86, codebuf, regloc +from rpython.jit.backend.x86.regalloc import gpr_reg_mgr_cls +from rpython.jit.backend.x86.arch import WORD, DEFAULT_FRAME_BYTES # @@ -22,10 +25,10 @@ # JNE slow_case # JMP *[reg2 + bc_most_recent + 8] # slow_case: +# PUSH RDX# save # PUSH RAX# save -# PUSH RDX# save -# MOV RAX, reg# the value to search for -# MOV RDX, reg2 # _backend_choices object +# MOV RDX=reg2, RAX=reg +#RDX is the _backend_choices object, RAX is the value to search for # JMP search_tree# see below # sequel: # @@ -96,7 +99,7 @@ # JNE left # # found: -# MOV R11, [RDX + 8] +# MOV R11, [RDX + 8*R11] # MOV RDX, [RSP+16] # MOV [RDX + bc_most_recent], RAX # MOV [RDX + bc_most_recent + 8], R11 @@ -107,10 +110,10 @@ # not_found: # -# MOV RDX, [RSP] -# MOV R11, [RDX + bc_gcmap] +# MOV RDI, [RSP] +# MOV R11, [RDI + bc_gcmap] # MOV [RBP + jf_gcmap], R11 -# +# # <_reload_frame_if_necessary> # MOV R11, RAX # @@ -161,9 +164,13 @@ ('bc_most_recent', PAIR), ('bc_list', lltype.Array(PAIR))) -@specialize.memo() -def getofs(name): +def _getofs(name): return llmemory.offsetof(BACKEND_CHOICES, name) +BCGCMAP = _getofs('bc_gcmap') +BCFAILDESCR = _getofs('bc_faildescr') +BCMOSTRECENT = _getofs('bc_most_recent') +BCLIST = _getofs('bc_list') +del _getofs BCLISTLENGTHOFS = llmemory.arraylengthoffset(BACKEND_CHOICES.bc_list) BCLISTITEMSOFS = llmemory.itemoffsetof(BACKEND_CHOICES.bc_list, 0) PAIRSIZE = llmemory.sizeof(PAIR) @@ -180,10 +187,10 @@ return old != new def bchoices_trace(gc, obj_addr, callback, arg): -gc._trace_callback(callback, arg, obj_addr + getofs('bc_faildescr')) -bchoices_pair(gc, obj_addr + getofs('bc_most_recent'), callback, arg) -length = (obj_addr + getofs('bc_list') + BCLISTLENGTHOFS).signed[0] -array_addr = obj_addr + getofs('bc_list') + BCLISTITEMSOFS +gc._trace_callback(callback, arg, obj_addr + BCFAILDESCR) +bchoices_pair(gc, obj_addr + BCMOSTRECENT, callback, arg) +length = (obj_addr + BCLIST + BCLISTLENGTHOFS).signed[0] +array_addr = obj_addr + BCLIST + BCLISTITEMSOFS item_addr = array_addr i = 0 changes = False @@ -219,10 +226,15 @@ compilation_info=eci) +INVOKE_FIND_COMPATIBLE_FUNC = lltype.Ptr(lltype.FuncType( +[lltype.Ptr(BACKEND_CHOICES), llmemory.GCREF], +lltype.Signed)) + def invoke_find_compatible(bchoices, new_gcref): descr = bchoices.bc_faildescr descr = cast_gcref_to_instance(GuardCompatibleDescr, descr) try: +xxx # temp result = descr.find_compatible(cpu, new_gcref) if result == 0: result = descr._backend_failure_recovery @@ -235,6 +247,9 @@ bchoices.bc_most_recent.asmaddr = result return result except: # oops! +if not we_are_translated(): +import sys, pdb +pdb.post_mortem(sys.exc_info()[2]) return descr._backend_failure_recovery def add_in_tree(bchoices, new_gcref, new_asmaddr): @@ -242,7 +257,7 @@ length = len(bchoices.bc_list) # gcref_base = lltype.cast_opaque_ptr(llmemory.GCREF, bchoices) -ofs = getofs('bc_list') + BCLISTITEMSOFS +ofs = BCLIST + BCLISTITEMSOFS ofs += (length - 1) * llmemory.sizeof(PAIR) ofs = _real_number(ofs) if llop.raw_load(lltype.Unsigned, gcref_base, ofs) != r_uint(-1): @@ -273,7 +288,7 @@ bchoices.bc_list[length - 1].asmaddr = new_asmaddr # --- no GC above --- addr = llmemory.cast_ptr_to_adr(bchoices) -addr += getofs('bc_list') + BCLISTITEMSOFS +addr += BCLIST + BCLISTITEMSOFS pairs_quicksort(addr, length) return bchoices @@ -307,11 +322,98 @@ def invalidate_cache(bchoice
[pypy-commit] pypy guard-compatible: uh?
Author: Armin Rigo Branch: guard-compatible Changeset: r84573:4ce2abacffb0 Date: 2016-05-22 17:46 +0200 http://bitbucket.org/pypy/pypy/changeset/4ce2abacffb0/ Log:uh? diff --git a/rpython/jit/metainterp/resoperation.py b/rpython/jit/metainterp/resoperation.py --- a/rpython/jit/metainterp/resoperation.py +++ b/rpython/jit/metainterp/resoperation.py @@ -330,7 +330,7 @@ if descr is DONT_CHANGE: descr = None return ResOperation(opnum, args, descr) -newop.rpyfunc = self.rpyfunc +newop.rpyfunc = self.rpyfunc # XXX after 'return'? really? def repr(self, memo, graytext=False): # RPython-friendly version ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy guard-compatible: Remove outdated code
Author: Armin Rigo Branch: guard-compatible Changeset: r84572:0814411c063a Date: 2016-05-22 16:49 +0200 http://bitbucket.org/pypy/pypy/changeset/0814411c063a/ Log:Remove outdated code diff --git a/rpython/jit/backend/x86/guard_compat.py b/rpython/jit/backend/x86/guard_compat.py --- a/rpython/jit/backend/x86/guard_compat.py +++ b/rpython/jit/backend/x86/guard_compat.py @@ -408,217 +408,3 @@ mc.JMP_r(r11) # JMP *R11 assembler.guard_compat_search_tree = mc.materialize(assembler.cpu, []) - - - - - -# - -def generate_guard_compatible(assembler, guard_token, loc_reg, initial_value): -# fast-path check -mc = assembler.mc -if IS_X86_64: -mc.MOV_ri64(X86_64_SCRATCH_REG.value, initial_value) -rel_pos_compatible_imm = mc.get_relative_pos() -mc.CMP_rr(loc_reg.value, X86_64_SCRATCH_REG.value) -elif IS_X86_32: -mc.CMP_ri32(loc_reg.value, initial_value) -rel_pos_compatible_imm = mc.get_relative_pos() -mc.J_il8(rx86.Conditions['E'], 0) -je_location = mc.get_relative_pos() - -# fast-path failed, call the slow-path checker -checker = get_or_build_checker(assembler, loc_reg.value) - -# initialize 'compatinfo' with only 'initial_value' in it -compatinfoaddr = assembler.datablockwrapper.malloc_aligned( -3 * WORD, alignment=WORD) -compatinfo = rffi.cast(rffi.SIGNEDP, compatinfoaddr) -compatinfo[1] = initial_value -compatinfo[2] = -1 - -if IS_X86_64: -mc.MOV_ri64(X86_64_SCRATCH_REG.value, compatinfoaddr) # patchable -guard_token.pos_compatinfo_offset = mc.get_relative_pos() - WORD -mc.PUSH_r(X86_64_SCRATCH_REG.value) -elif IS_X86_32: -mc.PUSH_i32(compatinfoaddr) # patchable -guard_token.pos_compatinfo_offset = mc.get_relative_pos() - WORD -mc.CALL(imm(checker)) -mc.stack_frame_size_delta(-WORD) - -small_ofs = rel_pos_compatible_imm - mc.get_relative_pos() -assert -128 <= small_ofs < 128 -compatinfo[0] = small_ofs & 0xFF - -assembler.guard_success_cc = rx86.Conditions['Z'] -assembler.implement_guard(guard_token) -# -# patch the JE above -offset = mc.get_relative_pos() - je_location -assert 0 < offset <= 127 -mc.overwrite(je_location-1, chr(offset)) - - -def patch_guard_compatible(rawstart, tok): -descr = tok.faildescr -if not we_are_translated() and isinstance(descr, BasicFailDescr): -pass# for tests -else: -assert isinstance(descr, GuardCompatibleDescr) -descr._backend_compatinfo = rawstart + tok.pos_compatinfo_offset - - -def grow_switch(cpu, compiled_loop_token, guarddescr, gcref): -# XXX is it ok to force gcref to be non-movable? -if not rgc._make_sure_does_not_move(gcref): -raise AssertionError("oops") -new_value = rffi.cast(lltype.Signed, gcref) - -# XXX related to the above: for now we keep alive the gcrefs forever -# in the compiled_loop_token -if compiled_loop_token._keepalive_extra is None: -compiled_loop_token._keepalive_extra = [] -compiled_loop_token._keepalive_extra.append(gcref) - -if not we_are_translated() and isinstance(guarddescr, BasicFailDescr): -pass# for tests -else: -assert isinstance(guarddescr, GuardCompatibleDescr) -compatinfop = rffi.cast(rffi.VOIDPP, guarddescr._backend_compatinfo) -compatinfo = rffi.cast(rffi.SIGNEDP, compatinfop[0]) -length = 3 -while compatinfo[length - 1] != -1: -length += 1 - -allblocks = compiled_loop_token.get_asmmemmgr_blocks() -datablockwrapper = MachineDataBlockWrapper(cpu.asmmemmgr, allblocks) -newcompatinfoaddr = datablockwrapper.malloc_aligned( -(length + 1) * WORD, alignment=WORD) -datablockwrapper.done() - -newcompatinfo = rffi.cast(rffi.SIGNEDP, newcompatinfoaddr) -newcompatinfo[0] = compatinfo[0] - -if GROW_POSITION == 0: -newcompatinfo[1] = new_value -for i in range(1, length): -newcompatinfo[i + 1] = compatinfo[i] -elif GROW_POSITION == 1: -for i in range(1, length - 2): -newcompatinfo[i] = compatinfo[i] -newcompatinfo[length - 2] = new_value -newcompatinfo[length - 1] = compatinfo[length - 2] -newcompatinfo[length] = -1# == compatinfo[length - 1] -else: -for i in range(1, length - 1): -newcompatinfo[i] = compatinfo[i] -newcompatinfo[length - 1] = new_value -newcompatinfo[length] = -1# == compatinfo[length - 1] - -# the old 'compatinfo' is not used any more, but will only be freed -# when the looptoken is freed -compatinfop[0] = rffi.cast(rffi.VOIDP, newcompatinfo) -valgrind.discard_translations(rffi.cast(lltype.Signed, compatinfop), WORD) - -# the machine code is not updated here. We leave it to the actual -# guard_compatible to update it if needed. - -
[pypy-commit] pypy fix-gen-dfa: refactored output function to be tested more easily
Author: Richard Plangger Branch: fix-gen-dfa Changeset: r84574:fa9847af949c Date: 2016-05-22 18:27 +0200 http://bitbucket.org/pypy/pypy/changeset/fa9847af949c/ Log:refactored output function to be tested more easily added not yet complete test for the same function diff --git a/pypy/interpreter/pyparser/genpytokenize.py b/pypy/interpreter/pyparser/genpytokenize.py --- a/pypy/interpreter/pyparser/genpytokenize.py +++ b/pypy/interpreter/pyparser/genpytokenize.py @@ -265,20 +265,25 @@ def output(name, dfa_class, dfa): import textwrap +lines = [] i = 0 for line in textwrap.wrap(repr(dfa.accepts), width = 50): if i == 0: -print "accepts =", line +lines.append("accepts = ") else: -print " ", line +lines.append(" ") +lines.append(line) +lines.append("\n") i += 1 import StringIO -print "states = [" +lines.append("states = [\n") for numstate, state in enumerate(dfa.states): -print "#", numstate +lines.append("#") +lines.append(str(numstate)) +lines.append('\n') s = StringIO.StringIO() i = 0 -for k, v in sorted(state.items()): +for k, v in enumerate(state): i += 1 if k == '\x00default': k = "automata.DEFAULT" @@ -298,22 +303,24 @@ for line in text: line = line.replace('::', ': ') if i == 0: -print '{' + line +lines.append('{') else: -print ' ' + line +lines.append(' ') +lines.append(line) +lines.append('\n') i += 1 -print "]" -print "%s = automata.%s(states, accepts)" % (name, dfa_class) -print +lines.append("]\n") +lines.append("%s = automata.%s(states, accepts)\n\n" % (name, dfa_class)) +return ''.join(lines) def main (): pseudoDFA = makePyPseudoDFA() -output("pseudoDFA", "DFA", pseudoDFA) +print output("pseudoDFA", "DFA", pseudoDFA) endDFAMap = makePyEndDFAMap() -output("double3DFA", "NonGreedyDFA", endDFAMap['"""']) -output("single3DFA", "NonGreedyDFA", endDFAMap["'''"]) -output("singleDFA", "DFA", endDFAMap["'"]) -output("doubleDFA", "DFA", endDFAMap['"']) +print output("double3DFA", "NonGreedyDFA", endDFAMap['"""']) +print output("single3DFA", "NonGreedyDFA", endDFAMap["'''"]) +print output("singleDFA", "DFA", endDFAMap["'"]) +print output("doubleDFA", "DFA", endDFAMap['"']) # __ diff --git a/pypy/interpreter/pyparser/test/test_gendfa.py b/pypy/interpreter/pyparser/test/test_gendfa.py new file mode 100644 --- /dev/null +++ b/pypy/interpreter/pyparser/test/test_gendfa.py @@ -0,0 +1,12 @@ +from pypy.interpreter.pyparser.automata import DFA, DEFAULT +from pypy.interpreter.pyparser.genpytokenize import output + +def test_states(): +d = DFA([{"\x00": 1}, {"\x01": 0}], [False, True]) +assert output('test', DFA, d) == """\ +accepts = [False, True] +states = [ +] +test = automata.pypy.interpreter.pyparser.automata.DFA(states, accepts) + +""" ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy fix-gen-dfa: completed minimal test, refactored output to take the previously generated states and reuse them.
Author: Richard Plangger Branch: fix-gen-dfa Changeset: r84575:fb294db3a207 Date: 2016-05-22 19:09 +0200 http://bitbucket.org/pypy/pypy/changeset/fb294db3a207/ Log:completed minimal test, refactored output to take the previously generated states and reuse them. that is much easier than reextracting the state from the string that is generated in DFA diff --git a/pypy/interpreter/pyparser/genpytokenize.py b/pypy/interpreter/pyparser/genpytokenize.py --- a/pypy/interpreter/pyparser/genpytokenize.py +++ b/pypy/interpreter/pyparser/genpytokenize.py @@ -191,7 +191,7 @@ newArcPair(states, EMPTY), pseudoExtras, number, funny, contStr, name)) dfaStates, dfaAccepts = nfaToDfa(states, *pseudoToken) -return DFA(dfaStates, dfaAccepts) +return DFA(dfaStates, dfaAccepts), dfaStates # __ @@ -205,7 +205,9 @@ newArcPair(states, DEFAULT), any(states, notGroupStr(states, "'\\", newArcPair(states, "'")) -singleDFA = DFA(*nfaToDfa(states, *single)) +states, accepts = nfaToDfa(states, *single) +singleDFA = DFA(states, accepts) +states_singleDFA = states states = [] double = chain(states, any(states, notGroupStr(states, '"\\')), @@ -215,7 +217,9 @@ newArcPair(states, DEFAULT), any(states, notGroupStr(states, '"\\', newArcPair(states, '"')) -doubleDFA = DFA(*nfaToDfa(states, *double)) +states, accepts = nfaToDfa(states, *double) +doubleDFA = DFA(states, accepts) +states_doubleDFA = states states = [] single3 = chain(states, any(states, notGroupStr(states, "'\\")), @@ -230,7 +234,9 @@ notChainStr(states, "''"))), any(states, notGroupStr(states, "'\\", chainStr(states, "'''")) -single3DFA = NonGreedyDFA(*nfaToDfa(states, *single3)) +states, accepts = nfaToDfa(states, *single3) +single3DFA = NonGreedyDFA(states, accepts) +states_single3DFA = states states = [] double3 = chain(states, any(states, notGroupStr(states, '"\\')), @@ -245,9 +251,11 @@ notChainStr(states, '""'))), any(states, notGroupStr(states, '"\\', chainStr(states, '"""')) -double3DFA = NonGreedyDFA(*nfaToDfa(states, *double3)) -map = {"'" : singleDFA, - '"' : doubleDFA, +states, accepts = nfaToDfa(states, *double3) +double3DFA = NonGreedyDFA(states, accepts) +states_double3DFA = states +map = {"'" : (singleDFA, states_singleDFA), + '"' : (doubleDFA, states_doubleDFA), "r" : None, "R" : None, "u" : None, @@ -257,13 +265,13 @@ for uniPrefix in ("", "u", "U", "b", "B", ): for rawPrefix in ("", "r", "R"): prefix = uniPrefix + rawPrefix -map[prefix + "'''"] = single3DFA -map[prefix + '"""'] = double3DFA +map[prefix + "'''"] = (single3DFA, states_single3DFA) +map[prefix + '"""'] = (double3DFA, states_doubleDFA) return map # __ -def output(name, dfa_class, dfa): +def output(name, dfa_class, dfa, states): import textwrap lines = [] i = 0 @@ -277,13 +285,13 @@ i += 1 import StringIO lines.append("states = [\n") -for numstate, state in enumerate(dfa.states): +for numstate, state in enumerate(states): lines.append("#") lines.append(str(numstate)) lines.append('\n') s = StringIO.StringIO() i = 0 -for k, v in enumerate(state): +for k, v in sorted(state.items()): i += 1 if k == '\x00default': k = "automata.DEFAULT" @@ -314,13 +322,17 @@ return ''.join(lines) def main (): -pseudoDFA = makePyPseudoDFA() -print output("pseudoDFA", "DFA", pseudoDFA) +pseudoDFA, states_pseudoDFA = makePyPseudoDFA() +print output("pseudoDFA", "DFA", pseudoDFA, states_pseudoDFA) endDFAMap = makePyEndDFAMap() -print output("double3DFA", "NonGreedyDFA", endDFAMap['"""']) -print output("single3DFA", "NonGreedyDFA", endDFAMap["'''"]) -print output("singleDFA", "DFA", endDFAMap["'"]) -print output("doubleDFA", "DFA", endDFAMap['"']) +dfa, states = endDFAMap['"""'] +print output("double3DFA", "NonGreedyDFA", dfa, states) +dfa, states = endDFAMap["'''"] +print output("single3DFA", "NonGreedyDFA", dfa, states) +dfa, states = endDFAMap["'"] +print output("singleDFA", "DFA", dfa, states) +dfa, states = en
[pypy-commit] pypy py3k: Apply gendfa patch from fix-gen-dfa (rev 84575) of Richard Plangger to py3k
Author: Raffael Tfirst Branch: py3k Changeset: r84576:a4fedb1664ee Date: 2016-05-22 19:54 +0200 http://bitbucket.org/pypy/pypy/changeset/a4fedb1664ee/ Log:Apply gendfa patch from fix-gen-dfa (rev 84575) of Richard Plangger to py3k diff --git a/pypy/interpreter/pyparser/gendfa.py b/pypy/interpreter/pyparser/gendfa.py --- a/pypy/interpreter/pyparser/gendfa.py +++ b/pypy/interpreter/pyparser/gendfa.py @@ -202,7 +202,7 @@ newArcPair(states, EMPTY), pseudoExtras, number, funny, contStr, name)) dfaStates, dfaAccepts = nfaToDfa(states, *pseudoToken) -return DFA(dfaStates, dfaAccepts) +return DFA(dfaStates, dfaAccepts), dfaStates # __ @@ -216,7 +216,9 @@ newArcPair(states, DEFAULT), any(states, notGroupStr(states, "'\\", newArcPair(states, "'")) -singleDFA = DFA(*nfaToDfa(states, *single)) +states, accepts = nfaToDfa(states, *single) +singleDFA = DFA(states, accepts) +states_singleDFA = states states = [] double = chain(states, any(states, notGroupStr(states, '"\\')), @@ -226,7 +228,9 @@ newArcPair(states, DEFAULT), any(states, notGroupStr(states, '"\\', newArcPair(states, '"')) -doubleDFA = DFA(*nfaToDfa(states, *double)) +states, accepts = nfaToDfa(states, *double) +doubleDFA = DFA(states, accepts) +states_doubleDFA = states states = [] single3 = chain(states, any(states, notGroupStr(states, "'\\")), @@ -241,7 +245,9 @@ notChainStr(states, "''"))), any(states, notGroupStr(states, "'\\", chainStr(states, "'''")) -single3DFA = NonGreedyDFA(*nfaToDfa(states, *single3)) +states, accepts = nfaToDfa(states, *single3) +single3DFA = NonGreedyDFA(states, accepts) +states_single3DFA = states states = [] double3 = chain(states, any(states, notGroupStr(states, '"\\')), @@ -256,27 +262,34 @@ notChainStr(states, '""'))), any(states, notGroupStr(states, '"\\', chainStr(states, '"""')) -double3DFA = NonGreedyDFA(*nfaToDfa(states, *double3)) -return {"'" : singleDFA, -'"' : doubleDFA, -"'''": single3DFA, -'"""': double3DFA} +states, accepts = nfaToDfa(states, *double3) +double3DFA = NonGreedyDFA(states, accepts) +states_double3DFA = states +return {"'" : (singleDFA, states_singleDFA), +'"' : (doubleDFA, states_doubleDFA), +"'''": (single3DFA, states_single3DFA), +'"""': (double3DFA, states_doubleDFA)} # __ -def output(name, dfa_class, dfa): +def output(name, dfa_class, dfa, states): import textwrap +lines = [] i = 0 for line in textwrap.wrap(repr(dfa.accepts), width = 50): if i == 0: -print "accepts =", line +lines.append("accepts = ") else: -print " ", line +lines.append(" ") +lines.append(line) +lines.append("\n") i += 1 import StringIO -print "states = [" -for numstate, state in enumerate(dfa.states): -print "#", numstate +lines.append("states = [\n") +for numstate, state in enumerate(states): +lines.append("#") +lines.append(str(numstate)) +lines.append("\n") s = StringIO.StringIO() i = 0 for k, v in sorted(state.items()): @@ -299,13 +312,15 @@ for line in text: line = line.replace('::', ': ') if i == 0: -print '{' + line +lines.append('{') else: -print ' ' + line +lines.append(' ') +lines.append(line) +lines.append('\n') i += 1 -print "]" -print "%s = automata.%s(states, accepts)" % (name, dfa_class) -print +lines.append("]\n") +lines.append("%s = automata.%s(states, accepts)\n\n" % (name, dfa_class)) +return ''.join(lines) def main (): print "# THIS FILE IS AUTOMATICALLY GENERATED BY gendfa.py" @@ -314,13 +329,17 @@ print "# python gendfa.py > dfa_generated.py" print print "from pypy.interpreter.pyparser import automata" -pseudoDFA = makePyPseudoDFA() -output("pseudoDFA", "DFA", pseudoDFA) +pseudoDFA, states_pseudoDFA = makePyPseudoDFA() +print output("pseudoDFA", "DFA", pseudoDFA, states_pseudoDFA) endDFAMap = makePyEndDFAMap() -output("double
[pypy-commit] pypy default: space.is_true/space.issubtype -> space.issubtype_w
Author: Philip Jenvey Branch: Changeset: r84579:06912e6047af Date: 2016-05-22 11:17 -0700 http://bitbucket.org/pypy/pypy/changeset/06912e6047af/ Log:space.is_true/space.issubtype -> space.issubtype_w 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 @@ -1215,7 +1215,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)'. @@ -1237,16 +1237,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__/descriptor.py b/pypy/module/__builtin__/descriptor.py --- a/pypy/module/__builtin__/descriptor.py +++ b/pypy/module/__builtin__/descriptor.py @@ -59,12 +59,12 @@ """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 +space.issubtype_w(w_obj_or_type, w_starttype)): # special case for class methods return w_obj_or_type -if space.is_true(space.issubtype(w_objtype, w_starttype)): +if space.issubtype_w(w_objtype, w_starttype): # normal case return w_objtype @@ -75,7 +75,7 @@ raise w_type = w_objtype -if space.is_true(space.issubtype(w_type, w_starttype)): +if space.issubtype_w(w_type, w_starttype): return w_type raise oefmt(space.w_TypeError, "super(type, obj): obj must be an instance or subtype of type") 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 @@ -706,7 +706,7 @@ w_obj_type = space.type(w_obj) w_type = get_w_type(space) return (space.is_w(w_obj_type, w_type) or -space.is_true(space.issubtype(w_obj_type, w_type))) +space.issubtype_w(w_obj_type, w_type)) def check_exact(space, w_obj): "Implements the Py_Xxx_CheckExact function" w_obj_type = space.type(w_obj) diff --git a/pypy/module/cpyext/modsupport.py b/pypy/module/cpyext/modsupport.py --- a/pypy/module/cpyext/modsupport.py +++ b/pypy/module/cpyext/modsupport.py @@ -113,7 +113,7 @@ w_type = space.gettypeobject(Module.typedef) w_obj_type = space.type(w_obj) return int(space.is_w(w_type, w_obj_type) or - space.is_true(space.issubtype(w_obj_type, w_type))) + space.issubtype_w(w_obj_type, w_type)) @cpython_api([PyObject], PyObject, result_borrowed=True) def PyModule_GetDict(space, w_mod): diff --git a/pypy/module/cpyext/ndarrayobject.py b/pypy/module/cpyext/ndarrayobject.py --- a/pypy/module/cpyext/ndarrayobject.py +++ b/pypy/module/cpyext/ndarrayobject.py @@ -35,7 +35,7 @@ w_obj_type = space.type(w_obj) w_type = space.gettypeobject(W_NDimArray.typedef) return (space.is_w(w_obj_type, w_type) or -space.is_true(space.issubtype(w_obj_type, w_type))) +space.issubtype_w(w_obj_type, w_type)) @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL, header=HEADER) def _PyArray_CheckExact(space, w_obj): diff --git a/pypy/module/cpyext/slotd
[pypy-commit] pypy default: avoid a couple wrap()s
Author: Philip Jenvey Branch: Changeset: r84580:bc76e36e50a4 Date: 2016-05-22 11:17 -0700 http://bitbucket.org/pypy/pypy/changeset/bc76e36e50a4/ Log:avoid a couple wrap()s 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 @@ -76,11 +76,10 @@ w_pretendtype = space.getattr(w_obj, space.wrap('__class__')) 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 @@ -137,11 +136,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 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: add space.issubtype_w
Author: Philip Jenvey Branch: Changeset: r84578:a9c6fa0a813c Date: 2016-05-22 11:16 -0700 http://bitbucket.org/pypy/pypy/changeset/a9c6fa0a813c/ Log:add space.issubtype_w diff --git a/pypy/objspace/descroperation.py b/pypy/objspace/descroperation.py --- a/pypy/objspace/descroperation.py +++ b/pypy/objspace/descroperation.py @@ -495,8 +495,11 @@ "coercion should return None or 2-tuple") return w_res +def issubtype_w(space, w_sub, w_type): +return space._type_issubtype(w_sub, w_type) + def issubtype(space, w_sub, w_type): -return space._type_issubtype(w_sub, w_type) +return space.wrap(space._type_issubtype(w_sub, w_type)) @specialize.arg_or_var(2) def isinstance_w(space, w_inst, w_type): 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 @@ -617,7 +617,7 @@ def _type_issubtype(self, w_sub, w_type): if isinstance(w_sub, W_TypeObject) and isinstance(w_type, W_TypeObject): -return self.wrap(w_sub.issubtype(w_type)) +return w_sub.issubtype(w_type) raise oefmt(self.w_TypeError, "need type objects") @specialize.arg_or_var(2) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: rename
Author: Philip Jenvey Branch: Changeset: r84577:b11052404cd6 Date: 2016-05-22 11:16 -0700 http://bitbucket.org/pypy/pypy/changeset/b11052404cd6/ Log:rename 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 @@ -18,7 +18,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 @@ -55,7 +55,7 @@ # fallback to object.__getattribute__() return space.call_function(object_getattribute(space), self, w_name) -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) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: space.is_true/space.issubtype -> space.issubtype_w
Author: Philip Jenvey Branch: py3k Changeset: r84582:840c490bfb73 Date: 2016-05-22 11:21 -0700 http://bitbucket.org/pypy/pypy/changeset/840c490bfb73/ Log:space.is_true/space.issubtype -> space.issubtype_w diff --git a/pypy/objspace/descroperation.py b/pypy/objspace/descroperation.py --- a/pypy/objspace/descroperation.py +++ b/pypy/objspace/descroperation.py @@ -582,7 +582,7 @@ # if the type is the same, then don't reverse: try # left first, right next. pass -elif space.is_true(space.issubtype(w_typ2, w_typ1)): +elif space.issubtype_w(w_typ2, w_typ1): # if typ2 is a subclass of typ1. w_obj1, w_obj2 = w_obj2, w_obj1 w_left_impl, w_right_impl = w_right_impl, w_left_impl 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 @@ -50,7 +50,7 @@ def getitem(self, w_dict, w_key): space = self.space w_lookup_type = space.type(w_key) -if space.is_true(space.issubtype(w_lookup_type, space.w_unicode)): +if space.issubtype_w(w_lookup_type, space.w_unicode): return self.getitem_str(w_dict, space.str_w(w_key)) else: return None 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 @@ -710,9 +710,9 @@ w_winner = w_metaclass for base in bases_w: w_typ = space.type(base) -if space.is_true(space.issubtype(w_winner, w_typ)): +if space.issubtype_w(w_winner, w_typ): continue -if space.is_true(space.issubtype(w_typ, w_winner)): +if space.issubtype_w(w_typ, w_winner): w_winner = w_typ continue msg = ("metaclass conflict: the metaclass of a derived class must be " ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: merge default
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 +space.issubtype_w(w_obj_or_type, w_starttype)):
[pypy-commit] pypy py3k: rearrange
Author: Philip Jenvey Branch: py3k Changeset: r84583:f9912e70c5a9 Date: 2016-05-22 11:24 -0700 http://bitbucket.org/pypy/pypy/changeset/f9912e70c5a9/ Log:rearrange 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 @@ -15,7 +15,9 @@ 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) +frame = space.getexecutioncontext().gettopframe() +w_starttype, w_obj_or_type = _super_from_frame(space, frame) + if space.is_none(w_obj_or_type): w_type = None # unbound super object w_obj_or_type = space.w_None @@ -57,11 +59,10 @@ # fallback to object.__getattribute__() return space.call_function(object_getattribute(space), self, w_name) -def _super_from_frame(space): +def _super_from_frame(space, frame): """super() without args -- fill in from __class__ and first local variable on the stack. """ -frame = space.getexecutioncontext().gettopframe() code = frame.pycode if not code: raise oefmt(space.w_RuntimeError, "super(): no code object") @@ -70,8 +71,9 @@ w_obj = frame.locals_cells_stack_w[0] if not w_obj: raise oefmt(space.w_RuntimeError, "super(): arg[0] deleted") + for index, name in enumerate(code.co_freevars): -if name == "__class__": +if name == '__class__': break else: raise oefmt(space.w_RuntimeError, "super(): __class__ cell not found") ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: Merge
Author: Raffael Tfirst Branch: py3k Changeset: r84585:69f43473014e Date: 2016-05-22 20:57 +0200 http://bitbucket.org/pypy/pypy/changeset/69f43473014e/ Log:Merge diff --git a/pypy/interpreter/pyparser/gendfa.py b/pypy/interpreter/pyparser/gendfa.py --- a/pypy/interpreter/pyparser/gendfa.py +++ b/pypy/interpreter/pyparser/gendfa.py @@ -280,14 +280,14 @@ if i == 0: lines.append("accepts = ") else: -lines.append(" ") +lines.append(" ") lines.append(line) lines.append("\n") i += 1 import StringIO lines.append("states = [\n") for numstate, state in enumerate(states): -lines.append("#") +lines.append("# ") lines.append(str(numstate)) lines.append("\n") s = StringIO.StringIO() ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: Fix whitespaces printed in gendfa
Author: Raffael Tfirst Branch: py3k Changeset: r84584:d6417229021c Date: 2016-05-22 20:54 +0200 http://bitbucket.org/pypy/pypy/changeset/d6417229021c/ Log:Fix whitespaces printed in gendfa diff --git a/pypy/interpreter/pyparser/gendfa.py b/pypy/interpreter/pyparser/gendfa.py --- a/pypy/interpreter/pyparser/gendfa.py +++ b/pypy/interpreter/pyparser/gendfa.py @@ -280,14 +280,14 @@ if i == 0: lines.append("accepts = ") else: -lines.append(" ") +lines.append(" ") lines.append(line) lines.append("\n") i += 1 import StringIO lines.append("states = [\n") for numstate, state in enumerate(states): -lines.append("#") +lines.append("# ") lines.append(str(numstate)) lines.append("\n") s = StringIO.StringIO() ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy fix-gen-dfa: Fix whitespaces printed in genpytokenize
Author: Raffael Tfirst Branch: fix-gen-dfa Changeset: r84586:7fa2b28336bf Date: 2016-05-22 21:16 +0200 http://bitbucket.org/pypy/pypy/changeset/7fa2b28336bf/ Log:Fix whitespaces printed in genpytokenize diff --git a/pypy/interpreter/pyparser/genpytokenize.py b/pypy/interpreter/pyparser/genpytokenize.py --- a/pypy/interpreter/pyparser/genpytokenize.py +++ b/pypy/interpreter/pyparser/genpytokenize.py @@ -279,14 +279,14 @@ if i == 0: lines.append("accepts = ") else: -lines.append(" ") +lines.append(" ") lines.append(line) lines.append("\n") i += 1 import StringIO lines.append("states = [\n") for numstate, state in enumerate(states): -lines.append("#") +lines.append("# ") lines.append(str(numstate)) lines.append('\n') s = StringIO.StringIO() ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: missing 3 in states_double3DFA
Author: Richard Plangger Branch: py3k Changeset: r84587:b5040274c15f Date: 2016-05-22 21:39 +0200 http://bitbucket.org/pypy/pypy/changeset/b5040274c15f/ Log:missing 3 in states_double3DFA diff --git a/pypy/interpreter/pyparser/gendfa.py b/pypy/interpreter/pyparser/gendfa.py --- a/pypy/interpreter/pyparser/gendfa.py +++ b/pypy/interpreter/pyparser/gendfa.py @@ -268,7 +268,7 @@ return {"'" : (singleDFA, states_singleDFA), '"' : (doubleDFA, states_doubleDFA), "'''": (single3DFA, states_single3DFA), -'"""': (double3DFA, states_doubleDFA)} +'"""': (double3DFA, states_double3DFA)} # __ @@ -319,7 +319,7 @@ lines.append('\n') i += 1 lines.append("]\n") -lines.append("%s = automata.%s(states, accepts)\n\n" % (name, dfa_class)) +lines.append("%s = automata.%s(states, accepts)\n" % (name, dfa_class)) return ''.join(lines) def main (): @@ -338,7 +338,7 @@ print output("single3DFA", "NonGreedyDFA", dfa, states) dfa, states = endDFAMap["'"] print output("singleDFA", "DFA", dfa, states) -dfa, states = endDFAMap["\""] +dfa, states = endDFAMap['"'] print output("doubleDFA", "DFA", dfa, states) # __ ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy fix-gen-dfa: same checkin as in py3k. missing 3 in states_double3DFA
Author: Richard Plangger Branch: fix-gen-dfa Changeset: r84588:68e08ed54197 Date: 2016-05-22 21:53 +0200 http://bitbucket.org/pypy/pypy/changeset/68e08ed54197/ Log:same checkin as in py3k. missing 3 in states_double3DFA diff --git a/pypy/interpreter/pyparser/genpytokenize.py b/pypy/interpreter/pyparser/genpytokenize.py --- a/pypy/interpreter/pyparser/genpytokenize.py +++ b/pypy/interpreter/pyparser/genpytokenize.py @@ -266,7 +266,7 @@ for rawPrefix in ("", "r", "R"): prefix = uniPrefix + rawPrefix map[prefix + "'''"] = (single3DFA, states_single3DFA) -map[prefix + '"""'] = (double3DFA, states_doubleDFA) +map[prefix + '"""'] = (double3DFA, states_double3DFA) return map # __ @@ -318,7 +318,7 @@ lines.append('\n') i += 1 lines.append("]\n") -lines.append("%s = automata.%s(states, accepts)\n\n" % (name, dfa_class)) +lines.append("%s = automata.%s(states, accepts)\n" % (name, dfa_class)) return ''.join(lines) def main (): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy guard-compatible: emulate the x86's behavior wrt always caching the most recent result of
Author: Armin Rigo Branch: guard-compatible Changeset: r84589:802f122fcc75 Date: 2016-05-22 21:53 +0200 http://bitbucket.org/pypy/pypy/changeset/802f122fcc75/ Log:emulate the x86's behavior wrt always caching the most recent result of find_compatible(), even if that was a return of 0. 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 @@ -364,6 +364,10 @@ if not isinstance(faildescr, GuardCompatibleDescr): # don't patch GuardCompatibleDescr faildescr._llgraph_bridge = lltrace +else: +# invalidate the cache +if hasattr(faildescr, '_guard_compatible_llgraph_lst'): +faildescr._guard_compatible_llgraph_lst[0] = (None, None) clt._llgraph_alltraces.append(lltrace) self._record_labels(lltrace) return LLAsmInfo(lltrace) @@ -1159,6 +1163,7 @@ if force_bridge is None: force_bridge = getattr(descr, '_llgraph_bridge', None) if force_bridge is not None: +assert isinstance(force_bridge, LLTrace) if propagate_exception: assert (force_bridge.operations[0].opnum in (rop.SAVE_EXC_CLASS, rop.GUARD_EXCEPTION, @@ -1294,22 +1299,30 @@ try: lst = descr._guard_compatible_llgraph_lst except AttributeError: -lst = descr._guard_compatible_llgraph_lst = [] +lst = descr._guard_compatible_llgraph_lst = [(None, None)] for ref, target in lst: -if ref == arg1: +if ref is not None and ref == arg1: break else: target = descr.find_compatible(self.cpu, arg1) -if target == 0: -self.fail_guard(descr, extra_value=arg1) -assert 0, "fail_guard should raise" -descr._guard_compatible_llgraph_lst.append((arg1, target)) +# we use list item 0 as the cache, which caches +# the most recent find_compatible() result even if +# it returned zero. For non-zero results, we also +# save them away in another non-overwritable entry. +pair = (arg1, target) +descr._guard_compatible_llgraph_lst[0] = pair +if target != 0: +descr._guard_compatible_llgraph_lst.append(pair) # if target == -1: return +elif target == 0: +self.fail_guard(descr, extra_value=arg1) +assert 0, "fail_guard should raise" else: self.fail_guard(descr, extra_value='should not be used', force_bridge=target) +assert 0, "fail_guard should raise" def execute_int_add_ovf(self, _, x, y): try: diff --git a/rpython/jit/backend/test/runner_test.py b/rpython/jit/backend/test/runner_test.py --- a/rpython/jit/backend/test/runner_test.py +++ b/rpython/jit/backend/test/runner_test.py @@ -257,8 +257,11 @@ self.cpu.compile_loop(loop.inputargs, loop.operations, looptoken) assert seen == [] -t_list = [t1_box._resref, t2_box._resref, t3_box._resref] +t_list = [t1_box._resref, t1_box._resref, + t2_box._resref, t2_box._resref, + t3_box._resref, t3_box._resref] expected = [] +prev_t = None for t in t_list * 2: # find_compatible() returns 0: the guard fails deadframe = self.cpu.execute_token(looptoken, t) @@ -267,8 +270,12 @@ assert fail.identifier == 2 else: assert fail.identifier == 1 -expected.append(t) # never cache returns of 0 +# returns of 0 are only cached if they are the most recent +# return, not longer +if t != prev_t: +expected.append(t) assert seen == expected +prev_t = t def test_extend_guard_compatible_3(self): seen = [] ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy guard-compatible: test_guard_compatible_1 passes
Author: Armin Rigo Branch: guard-compatible Changeset: r84590:7e31edfc6cc7 Date: 2016-05-22 21:54 +0200 http://bitbucket.org/pypy/pypy/changeset/7e31edfc6cc7/ Log:test_guard_compatible_1 passes diff --git a/rpython/jit/backend/llsupport/rewrite.py b/rpython/jit/backend/llsupport/rewrite.py --- a/rpython/jit/backend/llsupport/rewrite.py +++ b/rpython/jit/backend/llsupport/rewrite.py @@ -371,6 +371,9 @@ if OpHelpers.is_call_assembler(op.getopnum()): self.handle_call_assembler(op) continue +if op.getopnum() == rop.GUARD_COMPATIBLE: +self.handle_guard_compatible(op) +continue if op.getopnum() == rop.JUMP or op.getopnum() == rop.FINISH: self.emit_pending_zeros() # @@ -985,3 +988,16 @@ self._newops.append(load_op) self.gcrefs_recently_loaded[index] = load_op return load_op + +def handle_guard_compatible(self, op): +from rpython.jit.backend.x86 import guard_compat# XXX +c = op.getarg(1) +assert isinstance(c, ConstPtr) +descr = op.getdescr() +bchoices = guard_compat.initial_bchoices(descr, c.value) +bcindex = len(self.gcrefs_output_list) +gcref = lltype.cast_opaque_ptr(llmemory.GCREF, bchoices) +self.gcrefs_output_list.append(gcref) +new_op = op.copy_and_change(rop.GUARD_COMPATIBLE, +[op.getarg(0), ConstInt(bcindex)]) +self.emit_op(new_op) diff --git a/rpython/jit/backend/x86/assembler.py b/rpython/jit/backend/x86/assembler.py --- a/rpython/jit/backend/x86/assembler.py +++ b/rpython/jit/backend/x86/assembler.py @@ -743,6 +743,10 @@ clt = self.current_clt for tok in self.pending_guard_tokens: addr = rawstart + tok.pos_jump_offset +if tok.guard_compatible(): +guard_compat.patch_guard_compatible(tok, addr, +self.gc_table_addr) +continue tok.faildescr.adr_jump_offset = addr descr = tok.faildescr if descr.loop_version(): @@ -754,8 +758,6 @@ mc = codebuf.MachineCodeBlockWrapper() mc.writeimm32(relative_target) mc.copy_to_raw_memory(addr) -if tok.guard_compatible(): -guard_compat.patch_guard_compatible(rawstart, tok) else: # GUARD_NOT_INVALIDATED, record an entry in # clt.invalidate_positions of the form: @@ -854,6 +856,9 @@ return res def patch_jump_for_descr(self, faildescr, adr_new_target): +if isinstance(faildescr, guard_compat.GuardCompatibleDescr): +xx +return adr_jump_offset = faildescr.adr_jump_offset assert adr_jump_offset != 0 offset = adr_new_target - (adr_jump_offset + 4) @@ -1433,14 +1438,24 @@ assert IS_X86_32 return self.gc_table_addr + index * WORD +def load_reg_from_gc_table(self, resvalue, index): +if IS_X86_64: +self.mc.MOV_rp(resvalue, 0)# %rip-relative +self._patch_load_from_gc_table(index) +elif IS_X86_32: +self.mc.MOV_rj(resvalue, self._addr_from_gc_table(index)) + +def push_from_gc_table(self, index): +if IS_X86_64: +self.mc.PUSH_p(0) # %rip-relative +self._patch_load_from_gc_table(index) +elif IS_X86_32: +self.mc.PUSH_j(self._addr_from_gc_table(index)) + def genop_load_from_gc_table(self, op, arglocs, resloc): index = op.getarg(0).getint() assert isinstance(resloc, RegLoc) -if IS_X86_64: -self.mc.MOV_rp(resloc.value, 0)# %rip-relative -self._patch_load_from_gc_table(index) -elif IS_X86_32: -self.mc.MOV_rj(resloc.value, self._addr_from_gc_table(index)) +self._load_reg_from_gc_table(resloc.value, index) def genop_int_force_ge_zero(self, op, arglocs, resloc): self.mc.TEST(arglocs[0], arglocs[0]) @@ -1810,13 +1825,14 @@ self.implement_guard(guard_token) def genop_guard_guard_compatible(self, guard_op, guard_token, locs, ign): -assert guard_op.getarg(0).type == REF# only supported case for now -assert guard_op.getarg(1).type == REF -loc_reg, loc_imm = locs +loc_reg, loc_imm, loc_reg2 = locs assert isinstance(loc_reg, RegLoc) -assert isinstance(loc_imm, ImmedLoc) +assert isinstance(loc_imm, ImmedLoc)# index of 'backend_choices' +assert isinstance(loc_reg2, RegLoc) +self.load_reg_from_gc_table(loc_reg2.value, loc_imm.value) guard_compat.generate_guard_compatible(self, guard_token, - loc_reg, loc_imm.value) +
[pypy-commit] pypy guard-compatible: Fix for guard_compatible_2
Author: Armin Rigo Branch: guard-compatible Changeset: r84591:26d214acc8c3 Date: 2016-05-22 22:01 +0200 http://bitbucket.org/pypy/pypy/changeset/26d214acc8c3/ Log:Fix for guard_compatible_2 diff --git a/rpython/jit/backend/x86/assembler.py b/rpython/jit/backend/x86/assembler.py --- a/rpython/jit/backend/x86/assembler.py +++ b/rpython/jit/backend/x86/assembler.py @@ -742,11 +742,11 @@ # the field in question to point (initially) to the recovery stub clt = self.current_clt for tok in self.pending_guard_tokens: -addr = rawstart + tok.pos_jump_offset if tok.guard_compatible(): -guard_compat.patch_guard_compatible(tok, addr, +guard_compat.patch_guard_compatible(tok, rawstart, self.gc_table_addr) continue +addr = rawstart + tok.pos_jump_offset tok.faildescr.adr_jump_offset = addr descr = tok.faildescr if descr.loop_version(): diff --git a/rpython/jit/backend/x86/guard_compat.py b/rpython/jit/backend/x86/guard_compat.py --- a/rpython/jit/backend/x86/guard_compat.py +++ b/rpython/jit/backend/x86/guard_compat.py @@ -308,11 +308,12 @@ # bchoices.bc_list[0].asmaddr: patch_guard_compatible() return bchoices -def patch_guard_compatible(guard_token, sequel_label, gc_table_addr): +def patch_guard_compatible(guard_token, rawstart, gc_table_addr): # go to the address in the gctable, number 'bindex' bindex = guard_token.guard_compat_bindex choices_addr = gc_table_addr + WORD * bindex -failure_recovery = guard_token.pos_recovery_stub +sequel_label = rawstart + guard_token.pos_jump_offset +failure_recovery = rawstart + guard_token.pos_recovery_stub gcmap = guard_token.gcmap # choices_addr: points to bchoices in the GC table # sequel_label: "sequel:" label above ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy guard-compatible: Fix for guard_compatible_3
Author: Armin Rigo Branch: guard-compatible Changeset: r84592:c1979bc4a504 Date: 2016-05-22 22:08 +0200 http://bitbucket.org/pypy/pypy/changeset/c1979bc4a504/ Log:Fix for guard_compatible_3 diff --git a/rpython/jit/backend/x86/assembler.py b/rpython/jit/backend/x86/assembler.py --- a/rpython/jit/backend/x86/assembler.py +++ b/rpython/jit/backend/x86/assembler.py @@ -742,12 +742,12 @@ # the field in question to point (initially) to the recovery stub clt = self.current_clt for tok in self.pending_guard_tokens: +addr = rawstart + tok.pos_jump_offset +tok.faildescr.adr_jump_offset = addr if tok.guard_compatible(): guard_compat.patch_guard_compatible(tok, rawstart, self.gc_table_addr) continue -addr = rawstart + tok.pos_jump_offset -tok.faildescr.adr_jump_offset = addr descr = tok.faildescr if descr.loop_version(): continue # patch them later @@ -857,7 +857,12 @@ def patch_jump_for_descr(self, faildescr, adr_new_target): if isinstance(faildescr, guard_compat.GuardCompatibleDescr): -xx +# We must not patch the failure recovery stub of a +# GUARD_COMPATIBLE. Instead, the new bridge just compiled +# is not attached, but will be later returned by a call to +# find_compatible(). Here, we must only invalidate the +# cache in the guard's bchoices. +guard_compat.invalidate_cache(faildescr) return adr_jump_offset = faildescr.adr_jump_offset assert adr_jump_offset != 0 diff --git a/rpython/jit/backend/x86/guard_compat.py b/rpython/jit/backend/x86/guard_compat.py --- a/rpython/jit/backend/x86/guard_compat.py +++ b/rpython/jit/backend/x86/guard_compat.py @@ -308,6 +308,14 @@ # bchoices.bc_list[0].asmaddr: patch_guard_compatible() return bchoices +def descr_to_bchoices(descr): +assert isinstance(descr, GuardCompatibleDescr) +# ---no GC operation--- +bchoices = llop.raw_load(lltype.Signed, descr._backend_choices_addr, 0) +bchoices = rffi.cast(lltype.Ptr(BACKEND_CHOICES), bchoices) +# ---no GC operation end--- +return bchoices + def patch_guard_compatible(guard_token, rawstart, gc_table_addr): # go to the address in the gctable, number 'bindex' bindex = guard_token.guard_compat_bindex @@ -323,10 +331,8 @@ guard_compat_descr._backend_choices_addr = choices_addr guard_compat_descr._backend_sequel_label = sequel_label guard_compat_descr._backend_failure_recovery = failure_recovery -# ---no GC operation--- -bchoices = llop.raw_load(lltype.Signed, choices_addr, 0) -bchoices = rffi.cast(lltype.Ptr(BACKEND_CHOICES), bchoices) -# ---no GC operation end--- +# +bchoices = descr_to_bchoices(guard_compat_descr) assert len(bchoices.bc_list) == 1 assert (cast_gcref_to_instance(GuardCompatibleDescr, bchoices.bc_faildescr) is guard_compat_descr) @@ -339,8 +345,9 @@ llop.raw_store(lltype.Void, gcref_base, _real_number(pair_ofs), r_uint(-1)) llop.raw_store(lltype.Void, gcref_base, _real_number(pair_ofs), r_uint(-1)) -def invalidate_cache(bchoices): +def invalidate_cache(faildescr): """Write -1 inside bchoices.bc_most_recent.gcref.""" +bchoices = descr_to_bchoices(faildescr) invalidate_pair(bchoices, BCMOSTRECENT) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy guard-compatible: Fix the test
Author: Armin Rigo Branch: guard-compatible Changeset: r84594:4d84fbd00118 Date: 2016-05-22 22:08 +0200 http://bitbucket.org/pypy/pypy/changeset/4d84fbd00118/ Log:Fix the test diff --git a/rpython/jit/backend/x86/test/test_guard_compat.py b/rpython/jit/backend/x86/test/test_guard_compat.py --- a/rpython/jit/backend/x86/test/test_guard_compat.py +++ b/rpython/jit/backend/x86/test/test_guard_compat.py @@ -3,7 +3,7 @@ def test_invalidate_cache(): b = lltype.malloc(BACKEND_CHOICES, 4) -invalidate_cache(b) +invalidate_pair(b, BCMOSTRECENT) x = b.bc_most_recent.gcref assert rffi.cast(lltype.Unsigned, x) == r_uint(-1) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: Fix test_gendfa with correct whitespaces
Author: Raffael Tfirst Branch: py3k Changeset: r84593:3dd3cbeb6e54 Date: 2016-05-22 22:07 +0200 http://bitbucket.org/pypy/pypy/changeset/3dd3cbeb6e54/ Log:Fix test_gendfa with correct whitespaces diff --git a/pypy/interpreter/pyparser/test/test_gendfa.py b/pypy/interpreter/pyparser/test/test_gendfa.py --- a/pypy/interpreter/pyparser/test/test_gendfa.py +++ b/pypy/interpreter/pyparser/test/test_gendfa.py @@ -7,11 +7,10 @@ assert output('test', DFA, d, states) == """\ accepts = [False, True] states = [ -#0 +# 0 {'\\x00': 1}, -#1 +# 1 {'\\x01': 0}, ] test = automata.pypy.interpreter.pyparser.automata.DFA(states, accepts) - """ ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy fix-gen-dfa: Fix test_gendfa with correct whitespaces
Author: Raffael Tfirst Branch: fix-gen-dfa Changeset: r84595:9ff8e76bcec8 Date: 2016-05-22 22:10 +0200 http://bitbucket.org/pypy/pypy/changeset/9ff8e76bcec8/ Log:Fix test_gendfa with correct whitespaces diff --git a/pypy/interpreter/pyparser/test/test_gendfa.py b/pypy/interpreter/pyparser/test/test_gendfa.py --- a/pypy/interpreter/pyparser/test/test_gendfa.py +++ b/pypy/interpreter/pyparser/test/test_gendfa.py @@ -7,11 +7,10 @@ assert output('test', DFA, d, states) == """\ accepts = [False, True] states = [ -#0 +# 0 {'\\x00': 1}, -#1 +# 1 {'\\x01': 0}, ] test = automata.pypy.interpreter.pyparser.automata.DFA(states, accepts) - """ ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: Add fixed gendfa from py3k to py3.5
Author: Raffael Tfirst Branch: py3.5 Changeset: r84596:342b00f71058 Date: 2016-05-22 22:16 +0200 http://bitbucket.org/pypy/pypy/changeset/342b00f71058/ Log:Add fixed gendfa from py3k to py3.5 diff --git a/dfa_generated.py b/dfa_generated.py new file mode 100644 diff --git a/pypy/interpreter/pyparser/gendfa.py b/pypy/interpreter/pyparser/gendfa.py --- a/pypy/interpreter/pyparser/gendfa.py +++ b/pypy/interpreter/pyparser/gendfa.py @@ -202,7 +202,7 @@ newArcPair(states, EMPTY), pseudoExtras, number, funny, contStr, name)) dfaStates, dfaAccepts = nfaToDfa(states, *pseudoToken) -return DFA(dfaStates, dfaAccepts) +return DFA(dfaStates, dfaAccepts), dfaStates # __ @@ -216,7 +216,9 @@ newArcPair(states, DEFAULT), any(states, notGroupStr(states, "'\\", newArcPair(states, "'")) -singleDFA = DFA(*nfaToDfa(states, *single)) +states, accepts = nfaToDfa(states, *single) +singleDFA = DFA(states, accepts) +states_singleDFA = states states = [] double = chain(states, any(states, notGroupStr(states, '"\\')), @@ -226,7 +228,9 @@ newArcPair(states, DEFAULT), any(states, notGroupStr(states, '"\\', newArcPair(states, '"')) -doubleDFA = DFA(*nfaToDfa(states, *double)) +states, accepts = nfaToDfa(states, *double) +doubleDFA = DFA(states, accepts) +states_doubleDFA = states states = [] single3 = chain(states, any(states, notGroupStr(states, "'\\")), @@ -241,7 +245,9 @@ notChainStr(states, "''"))), any(states, notGroupStr(states, "'\\", chainStr(states, "'''")) -single3DFA = NonGreedyDFA(*nfaToDfa(states, *single3)) +states, accepts = nfaToDfa(states, *single3) +single3DFA = NonGreedyDFA(states, accepts) +states_single3DFA = states states = [] double3 = chain(states, any(states, notGroupStr(states, '"\\')), @@ -256,27 +262,34 @@ notChainStr(states, '""'))), any(states, notGroupStr(states, '"\\', chainStr(states, '"""')) -double3DFA = NonGreedyDFA(*nfaToDfa(states, *double3)) -return {"'" : singleDFA, -'"' : doubleDFA, -"'''": single3DFA, -'"""': double3DFA} +states, accepts = nfaToDfa(states, *double3) +double3DFA = NonGreedyDFA(states, accepts) +states_double3DFA = states +return {"'" : (singleDFA, states_singleDFA), +'"' : (doubleDFA, states_doubleDFA), +"'''": (single3DFA, states_single3DFA), +'"""': (double3DFA, states_double3DFA)} # __ -def output(name, dfa_class, dfa): +def output(name, dfa_class, dfa, states): import textwrap +lines = [] i = 0 for line in textwrap.wrap(repr(dfa.accepts), width = 50): if i == 0: -print "accepts =", line +lines.append("accepts = ") else: -print " ", line +lines.append(" ") +lines.append(line) +lines.append("\n") i += 1 import StringIO -print "states = [" -for numstate, state in enumerate(dfa.states): -print "#", numstate +lines.append("states = [\n") +for numstate, state in enumerate(states): +lines.append("# ") +lines.append(str(numstate)) +lines.append("\n") s = StringIO.StringIO() i = 0 for k, v in sorted(state.items()): @@ -299,13 +312,15 @@ for line in text: line = line.replace('::', ': ') if i == 0: -print '{' + line +lines.append('{') else: -print ' ' + line +lines.append(' ') +lines.append(line) +lines.append('\n') i += 1 -print "]" -print "%s = automata.%s(states, accepts)" % (name, dfa_class) -print +lines.append("]\n") +lines.append("%s = automata.%s(states, accepts)\n" % (name, dfa_class)) +return ''.join(lines) def main (): print "# THIS FILE IS AUTOMATICALLY GENERATED BY gendfa.py" @@ -314,13 +329,17 @@ print "# python gendfa.py > dfa_generated.py" print print "from pypy.interpreter.pyparser import automata" -pseudoDFA = makePyPseudoDFA() -output("pseudoDFA", "DFA", pseudoDFA) +pseudoDFA, states_pseudoDFA = makePyPseudoDFA() +print output("pseudoDFA", "DFA", pseudoDFA, states_pseudoDFA) endDFAMap = makePyEndDFAM
[pypy-commit] pypy py3.5: Add gendfa test
Author: Raffael Tfirst Branch: py3.5 Changeset: r84597:ac30234331fd Date: 2016-05-22 22:17 +0200 http://bitbucket.org/pypy/pypy/changeset/ac30234331fd/ Log:Add gendfa test diff --git a/dfa_generated.py b/dfa_generated.py deleted file mode 100644 diff --git a/pypy/interpreter/pyparser/test/test_gendfa.py b/pypy/interpreter/pyparser/test/test_gendfa.py new file mode 100644 --- /dev/null +++ b/pypy/interpreter/pyparser/test/test_gendfa.py @@ -0,0 +1,16 @@ +from pypy.interpreter.pyparser.automata import DFA, DEFAULT +from pypy.interpreter.pyparser.gendfa import output + +def test_states(): +states = [{"\x00": 1}, {"\x01": 0}] +d = DFA(states[:], [False, True]) +assert output('test', DFA, d, states) == """\ +accepts = [False, True] +states = [ +# 0 +{'\\x00': 1}, +# 1 +{'\\x01': 0}, +] +test = automata.pypy.interpreter.pyparser.automata.DFA(states, accepts) +""" ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: Fix @= not recognized by adding @ to dfa
Author: Raffael Tfirst Branch: py3.5 Changeset: r84598:8d4fbbad6a2c Date: 2016-05-22 22:21 +0200 http://bitbucket.org/pypy/pypy/changeset/8d4fbbad6a2c/ Log:Fix @= not recognized by adding @ to dfa diff --git a/pypy/interpreter/pyparser/dfa_generated.py b/pypy/interpreter/pyparser/dfa_generated.py --- a/pypy/interpreter/pyparser/dfa_generated.py +++ b/pypy/interpreter/pyparser/dfa_generated.py @@ -21,7 +21,7 @@ '0': 5, '1': 6, '2': 6, '3': 6, '4': 6, '5': 6, '6': 6, '7': 6, '8': 6, '9': 6, ':': 15, ';': 15, - '<': 10, '=': 14, '>': 9, '@': 15, + '<': 10, '=': 14, '>': 9, '@': 14, 'A': 1, 'B': 2, 'C': 1, 'D': 1, 'E': 1, 'F': 1, 'G': 1, 'H': 1, 'I': 1, 'J': 1, 'K': 1, 'L': 1, diff --git a/pypy/interpreter/pyparser/gendfa.py b/pypy/interpreter/pyparser/gendfa.py --- a/pypy/interpreter/pyparser/gendfa.py +++ b/pypy/interpreter/pyparser/gendfa.py @@ -138,7 +138,7 @@ chainStr(states, "//"), maybe(states, newArcPair(states, "="))), chain(states, - groupStr(states, "+-*/%&|^=<>"), + groupStr(states, "+-*/%&|^=<>@"), maybe(states, newArcPair(states, "="))), newArcPair(states, "~")) bracket = groupStr(states, "[](){}") ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy guard-compatible: A test checking most pieces of guard_compat, without invoking the rest
Author: Armin Rigo Branch: guard-compatible Changeset: r84599:016d5e77145e Date: 2016-05-22 23:21 +0200 http://bitbucket.org/pypy/pypy/changeset/016d5e77145e/ Log:A test checking most pieces of guard_compat, without invoking the rest of the backend diff --git a/rpython/jit/backend/x86/test/test_guard_compat.py b/rpython/jit/backend/x86/test/test_guard_compat.py --- a/rpython/jit/backend/x86/test/test_guard_compat.py +++ b/rpython/jit/backend/x86/test/test_guard_compat.py @@ -1,4 +1,11 @@ +import random from rpython.jit.backend.x86.guard_compat import * +from rpython.jit.backend.detect_cpu import getcpuclass + +CPU = getcpuclass() + +class FakeStats(object): +pass def test_invalidate_cache(): @@ -62,3 +69,107 @@ (new_gcref_3, new_asmaddr_3), (-1, 0), # invalid ]) + +def test_guard_compat(): +cpu = CPU(rtyper=None, stats=FakeStats()) +cpu.setup_once() + +mc = codebuf.MachineCodeBlockWrapper() +for i in range(4 * WORD): +mc.writechar('\x00') # 4 gctable entries; 'bchoices' will be #3 +# +mc.PUSH(regloc.ebp) +mc.SUB(regloc.esp, regloc.imm(448 - 2*WORD)) # make a frame, and align stack +mc.LEA_rs(regloc.ebp.value, 48) +# +mc.PUSH(regloc.imm(0x)) +mc.PUSH(regloc.imm(0x)) +mc.MOV(regloc.edx, regloc.edi) +mc.MOV(regloc.eax, regloc.esi) +mc.JMP(regloc.imm(cpu.assembler.guard_compat_search_tree)) +sequel = mc.get_relative_pos() +# +mc.force_frame_size(448) +mc.SUB(regloc.eax, regloc.edx) +mc.ADD(regloc.esp, regloc.imm(448 - 2*WORD)) +mc.POP(regloc.ebp) +mc.RET() +# +extra_paths = [] +for i in range(11): +mc.force_frame_size(448) +extra_paths.append(mc.get_relative_pos()) +mc.MOV(regloc.eax, regloc.imm(100 + i)) +mc.ADD(regloc.esp, regloc.imm(448 - 2*WORD)) +mc.POP(regloc.ebp) +mc.RET() +failure = extra_paths[10] +rawstart = mc.materialize(cpu, []) +call_me = rffi.cast(lltype.Ptr(lltype.FuncType([lltype.Ptr(BACKEND_CHOICES), +llmemory.GCREF], + lltype.Signed)), +rawstart + 4 * WORD) + +guard_compat_descr = GuardCompatibleDescr() +bchoices = initial_bchoices(guard_compat_descr, +rffi.cast(llmemory.GCREF, 11)) +llop.raw_store(lltype.Void, rawstart, 3 * WORD, bchoices) + +class FakeGuardToken: +guard_compat_bindex = 3 +pos_jump_offset = sequel +pos_recovery_stub = failure +gcmap = rffi.cast(lltype.Ptr(jitframe.GCMAP), 0x10111213) +faildescr = guard_compat_descr +guard_token = FakeGuardToken() + +patch_guard_compatible(guard_token, rawstart, rawstart) + +# ready + +for i in range(5): +guard_compat_descr.find_compatible = "don't call" +gcref = rffi.cast(llmemory.GCREF, 11) +print 'calling with the standard gcref' +res = call_me(bchoices, gcref) +assert res == 0x - 0x +assert bchoices.bc_most_recent.gcref == gcref +assert bchoices.bc_most_recent.asmaddr == rawstart + sequel + +seen = [] +def call(cpu, descr): +print 'find_compatible returns 0' +seen.append(descr) +return 0 + +for i in range(5): +guard_compat_descr.find_compatible = call +gcref = rffi.cast(llmemory.GCREF, 123456 + i) +print 'calling with a gcref never seen before' +res = call_me(bchoices, gcref) +assert res == 110 +assert len(seen) == 1 + i +assert bchoices.bc_most_recent.gcref == gcref +assert bchoices.bc_most_recent.asmaddr == rawstart + failure + +# grow bchoices + +expected = {11: (0x - 0x, rawstart + sequel)} +for j in range(10): +print 'growing bchoices' +bchoices = add_in_tree(bchoices, rffi.cast(llmemory.GCREF, 13 + j), + rawstart + extra_paths[j]) +expected[13 + j] = (100 + j, rawstart + extra_paths[j]) +llop.raw_store(lltype.Void, rawstart, 3 * WORD, bchoices) + +for i in range(10): +lst = expected.items() +random.shuffle(lst) +for intgcref, (expected_res, expected_asmaddr) in lst: +guard_compat_descr.find_compatible = "don't call" +gcref = rffi.cast(llmemory.GCREF, intgcref) +print 'calling with new choice', intgcref +res = call_me(bchoices, gcref) +assert res == expected_res +assert bchoices.bc_most_recent.gcref == gcref +assert bchoices.bc_most_recent.asmaddr == expected_asmaddr ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: o print out PYTHON3 version info in pypy/interpreter/test pytest header
Author: Philip Jenvey Branch: py3k Changeset: r84602:f3be34765182 Date: 2016-05-22 14:41 -0700 http://bitbucket.org/pypy/pypy/changeset/f3be34765182/ Log:o print out PYTHON3 version info in pypy/interpreter/test pytest header o try to more gracefully fail app_main tests when no PYTHON3 is found diff --git a/pypy/interpreter/test/conftest.py b/pypy/interpreter/test/conftest.py new file mode 100644 --- /dev/null +++ b/pypy/interpreter/test/conftest.py @@ -0,0 +1,13 @@ +from pypy.conftest import PYTHON3 + +def get_banner(): +import subprocess +p = subprocess.Popen([PYTHON3, "-c", + "import sys; print(sys.version.splitlines()[0])"], + stdout=subprocess.PIPE) +return p.stdout.read().rstrip() +banner = get_banner() if PYTHON3 else "PYTHON3 not found" + +def pytest_report_header(config): +if PYTHON3: +return "PYTHON3: %s\n(Version %s)" % (PYTHON3, banner) 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 @@ -6,22 +6,20 @@ import sys, os, re, runpy, subprocess from rpython.tool.udir import udir from contextlib import contextmanager -from pypy.conftest import pypydir +from pypy.conftest import PYTHON3, pypydir +from pypy.interpreter.test.conftest import banner from lib_pypy._pypy_interact import irc_header - -python3 = os.environ.get("PYTHON3", "python3") - -def get_banner(): -p = subprocess.Popen([python3, "-c", - "import sys; print(sys.version.splitlines()[0])"], - stdout=subprocess.PIPE) -return p.stdout.read().rstrip() -banner = get_banner() - app_main = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, 'app_main.py') app_main = os.path.abspath(app_main) +def get_python3(): +if PYTHON3: +return PYTHON3 +import py.test +py.test.fail("Test requires 'python3' (not found in PATH) or a PYTHON3 " + "environment variable set") + _counter = 0 def _get_next_path(ext='.py'): global _counter @@ -37,7 +35,7 @@ def getscript_pyc(space, source): p = _get_next_path() p.write(str(py.code.Source(source))) -subprocess.check_call([python3, "-c", "import " + p.purebasename], +subprocess.check_call([get_python3(), "-c", "import " + p.purebasename], env={'PYTHONPATH': str(p.dirpath())}) # the .pyc file should have been created above pycache = p.dirpath('__pycache__') @@ -99,7 +97,7 @@ "option %r has unexpectedly the value %r" % (key, value)) def check(self, argv, env, **expected): -p = subprocess.Popen([python3, app_main, +p = subprocess.Popen([get_python3(), app_main, '--argparse-only'] + list(argv), stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env) @@ -240,7 +238,7 @@ def spawn(self, argv, env=None): # make sure that when we do 'import pypy' we get the correct package with setpythonpath(): -return self._spawn(python3, [app_main] + argv, env=env) +return self._spawn(get_python3(), [app_main] + argv, env=env) def test_interactive(self): child = self.spawn([]) @@ -529,7 +527,7 @@ if sys.platform == "win32": skip("close_fds is not supported on Windows platforms") import subprocess, select, os -pipe = subprocess.Popen([python3, app_main, "-u", "-i"], +pipe = subprocess.Popen([get_python3(), app_main, "-u", "-i"], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT, @@ -624,7 +622,7 @@ import __pypy__ except: py.test.skip('app_main cannot run on non-pypy for windows') -cmdline = '%s %s "%s" %s' % (python3, python_flags, +cmdline = '%s %s "%s" %s' % (get_python3(), python_flags, app_main, cmdline) print 'POPEN:', cmdline process = subprocess.Popen( @@ -813,7 +811,7 @@ time.sleep(1) # stdout flushed automatically here """) -cmdline = '%s -E "%s" %s' % (python3, app_main, path) +cmdline = '%s -E "%s" %s' % (get_python3(), app_main, path) print 'POPEN:', cmdline child_in, child_out_err = os.popen4(cmdline) data = child_out_err.read(11) @@ -840,7 +838,7 @@ if 'stderr' in streams: os.close(2) p = subprocess.Popen( -[python3, app_main, "-E", "-c", code], +[get_python3(), app_main, "-E", "-c", code], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
[pypy-commit] pypy py3k: kill -R/update usage
Author: Philip Jenvey Branch: py3k Changeset: r84600:75f69a53e8ee Date: 2016-05-22 14:41 -0700 http://bitbucket.org/pypy/pypy/changeset/75f69a53e8ee/ Log:kill -R/update usage 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 @@ -2,7 +2,7 @@ # This is pure Python code that handles the main entry point into "pypy". # See test/test_app_main. -# Missing vs CPython: -b, -d, -x, -3 +# Missing vs CPython: -b, -d, -x from __future__ import print_function, unicode_literals USAGE1 = __doc__ = """\ Options and arguments (and corresponding environment variables): @@ -16,10 +16,10 @@ -O : skip assert statements; also PYTHONOPTIMIZE=x -OO: remove docstrings when importing modules in addition to -O -q : don't print version and copyright messages on interactive startup --R : ignored (see http://bugs.python.org/issue14621) -s : don't add user site directory to sys.path; also PYTHONNOUSERSITE -S : don't imply 'import site' on initialization --u : unbuffered binary stdout and stderr; also PYTHONUNBUFFERED=x +-u : unbuffered binary stdout and stderr, stdin always buffered; + also PYTHONUNBUFFERED=x -v : verbose (trace import statements); also PYTHONVERBOSE=x can be supplied multiple times to increase verbosity -V : print the Python version number and exit (also --version) @@ -379,6 +379,9 @@ def end_options(options, _, iterargv): return list(iterargv) +def ignore_option(*args): +pass + cmdline_options = { # simple options just increment the counter of the options listed above 'b': (simple_option, 'bytes_warning'), @@ -387,7 +390,7 @@ 'E': (simple_option, 'ignore_environment'), 'i': (simple_option, 'interactive'), 'O': (simple_option, 'optimize'), -'R': (simple_option, 'hash_randomization'), +'R': (ignore_option, 'hash_randomization'), 's': (simple_option, 'no_user_site'), 'S': (simple_option, 'no_site'), 'u': (simple_option, 'unbuffered'), ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: cleanup TempoaryDirectorys atexit
Author: Philip Jenvey Branch: py3k Changeset: r84601:263f5c13be5b Date: 2016-05-22 14:41 -0700 http://bitbucket.org/pypy/pypy/changeset/263f5c13be5b/ Log:cleanup TempoaryDirectorys atexit diff --git a/lib-python/3/tempfile.py b/lib-python/3/tempfile.py --- a/lib-python/3/tempfile.py +++ b/lib-python/3/tempfile.py @@ -34,6 +34,7 @@ import os as _os import shutil as _shutil import errno as _errno +import weakref as _weakref from random import Random as _Random try: @@ -686,6 +687,7 @@ def __init__(self, suffix="", prefix=template, dir=None): self.name = mkdtemp(suffix, prefix, dir) +_tmpdirs.add(self) def __repr__(self): return "<{} {!r}>".format(self.__class__.__name__, self.name) @@ -714,6 +716,7 @@ def __exit__(self, exc, value, tb): self.cleanup() +_tmpdirs.discard(self) def __del__(self): # Issue a ResourceWarning if implicit cleanup needed @@ -736,10 +739,23 @@ except _OSError: pass +_tmpdirs = _weakref.WeakSet() _is_running = True +def _tmpdir_cleanup(): +while _tmpdirs: +try: +tmpdir = _tmpdirs.pop() +except KeyError: +break +try: +tmpdir.cleanup(_warn=True) +except: +pass + def _on_shutdown(): global _is_running +_tmpdir_cleanup() _is_running = False _atexit.register(_on_shutdown) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: rearrange
Author: Philip Jenvey Branch: py3k Changeset: r84603:6c2b6f5406c9 Date: 2016-05-22 14:47 -0700 http://bitbucket.org/pypy/pypy/changeset/6c2b6f5406c9/ Log:rearrange 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 @@ -390,7 +390,6 @@ 'E': (simple_option, 'ignore_environment'), 'i': (simple_option, 'interactive'), 'O': (simple_option, 'optimize'), -'R': (ignore_option, 'hash_randomization'), 's': (simple_option, 'no_user_site'), 'S': (simple_option, 'no_site'), 'u': (simple_option, 'unbuffered'), @@ -410,6 +409,7 @@ '--jit': (set_jit_option, Ellipsis), '-funroll-loops': (funroll_loops, None), '--':(end_options, None), +'R': (ignore_option, None), # previously hash_randomization } def handle_argument(c, options, iterargv, iterarg=iter(())): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: merge default
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 default: forgot this for tests
Author: Philip Jenvey Branch: Changeset: r84604:184f01bf8b1e Date: 2016-05-22 15:02 -0700 http://bitbucket.org/pypy/pypy/changeset/184f01bf8b1e/ Log:forgot this for tests 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 @@ -281,6 +281,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: fix test_qualname
Author: Philip Jenvey Branch: py3k Changeset: r84606:9a7ec898d577 Date: 2016-05-22 16:24 -0700 http://bitbucket.org/pypy/pypy/changeset/9a7ec898d577/ Log:fix test_qualname diff --git a/lib-python/3/test/test_descr.py b/lib-python/3/test/test_descr.py --- a/lib-python/3/test/test_descr.py +++ b/lib-python/3/test/test_descr.py @@ -4533,6 +4533,9 @@ self.assertEqual(type(d).__name__, n + '_descriptor') for d in descriptors: +if (support.check_impl_detail(pypy=True) and +not hasattr(d, '__objclass__')): +continue qualname = d.__objclass__.__qualname__ + '.' + d.__name__ self.assertEqual(d.__qualname__, qualname) diff --git a/pypy/objspace/std/complexobject.py b/pypy/objspace/std/complexobject.py --- a/pypy/objspace/std/complexobject.py +++ b/pypy/objspace/std/complexobject.py @@ -509,7 +509,7 @@ if not isinstance(w_obj, W_ComplexObject): raise oefmt(space.w_TypeError, "descriptor is for 'complex'") return space.newfloat(getattr(w_obj, name)) -return GetSetProperty(fget, doc=doc) +return GetSetProperty(fget, doc=doc, cls=W_ComplexObject) W_ComplexObject.typedef = TypeDef("complex", __doc__ = """complex(real[, imag]) -> complex number ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: skip for now: it's pretty annoying to fix and not that important
Author: Philip Jenvey Branch: py3k Changeset: r84607:06b95516b5de Date: 2016-05-22 16:24 -0700 http://bitbucket.org/pypy/pypy/changeset/06b95516b5de/ Log:skip for now: it's pretty annoying to fix and not that important diff --git a/lib-python/3/test/test_descr.py b/lib-python/3/test/test_descr.py --- a/lib-python/3/test/test_descr.py +++ b/lib-python/3/test/test_descr.py @@ -4577,6 +4577,8 @@ for o in gc.get_objects(): self.assertIsNot(type(o), X) +@unittest.skipIf(support.check_impl_detail(pypy=True), + "https://bitbucket.org/pypy/pypy/issues/2306";) def test_object_new_and_init_with_parameters(self): # See issue #1683368 class OverrideNeither: ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: kill these, importlib handles them now (and we don't pass)
Author: Philip Jenvey Branch: py3k Changeset: r84608:338bd2b6fc05 Date: 2016-05-22 16:35 -0700 http://bitbucket.org/pypy/pypy/changeset/338bd2b6fc05/ Log:kill these, importlib handles them now (and we don't pass) 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 @@ -746,54 +746,6 @@ else: raise AssertionError("should have failed") -def test_verbose_flag_1(self): -output = [] -class StdErr(object): -def write(self, line): -output.append(line) - -import sys, imp -old_flags = sys.flags - -class Flags(object): -verbose = 1 -def __getattr__(self, name): -return getattr(old_flags, name) - -sys.flags = Flags() -sys.stderr = StdErr() -try: -import verbose1pkg.verbosemod -finally: -imp.reload(sys) -assert 'import verbose1pkg # ' in output[-2] -assert 'import verbose1pkg.verbosemod # ' in output[-1] - -def test_verbose_flag_2(self): -output = [] -class StdErr(object): -def write(self, line): -output.append(line) - -import sys, imp -old_flags = sys.flags - -class Flags(object): -verbose = 2 -def __getattr__(self, name): -return getattr(old_flags, name) - -sys.flags = Flags() -sys.stderr = StdErr() -try: -import verbose2pkg.verbosemod -finally: -imp.reload(sys) -assert any('import verbose2pkg # ' in line - for line in output[:-2]) -assert output[-2].startswith('# trying') -assert 'import verbose2pkg.verbosemod # ' in output[-1] - def test_verbose_flag_0(self): output = [] class StdErr(object): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: Backed out changeset ba47fac77ffc, this is still needed unfortunately
Author: Philip Jenvey Branch: py3k Changeset: r84609:d4f72dd6b90a Date: 2016-05-22 16:47 -0700 http://bitbucket.org/pypy/pypy/changeset/d4f72dd6b90a/ Log:Backed out changeset ba47fac77ffc, this is still needed unfortunately 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 @@ -445,7 +445,7 @@ cached_version_tag = cache.versions[method_hash] if cached_version_tag is version_tag: cached_name = cache.names[method_hash] -if cached_name is name: +if cached_name == name: tup = cache.lookup_where[method_hash] if space.config.objspace.std.withmethodcachecounter: cache.hits[name] = cache.hits.get(name, 0) + 1 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: reapply lost sysconfig changes from old py3k, add a skip
Author: Philip Jenvey Branch: py3k Changeset: r84610:7122d29b9ca9 Date: 2016-05-22 17:03 -0700 http://bitbucket.org/pypy/pypy/changeset/7122d29b9ca9/ Log:reapply lost sysconfig changes from old py3k, add a skip diff --git a/lib-python/3/sysconfig.py b/lib-python/3/sysconfig.py --- a/lib-python/3/sysconfig.py +++ b/lib-python/3/sysconfig.py @@ -42,6 +42,16 @@ 'scripts': '{base}/bin', 'data': '{base}', }, +'pypy': { +'stdlib': '{installed_base}/lib-python', +'platstdlib': '{base}/lib-python', +'purelib': '{base}/lib-python', +'platlib': '{base}/lib-python', +'include': '{installed_base}/include', +'platinclude': '{installed_base}/include', +'scripts': '{base}/bin', +'data' : '{base}', +}, 'nt': { 'stdlib': '{installed_base}/Lib', 'platstdlib': '{base}/Lib', @@ -198,7 +208,9 @@ def _get_default_scheme(): -if os.name == 'posix': +if '__pypy__' in sys.builtin_module_names: +return 'pypy' +elif os.name == 'posix': # the default scheme for posix is posix_prefix return 'posix_prefix' return os.name diff --git a/lib-python/3/test/test_sysconfig.py b/lib-python/3/test/test_sysconfig.py --- a/lib-python/3/test/test_sysconfig.py +++ b/lib-python/3/test/test_sysconfig.py @@ -239,7 +239,7 @@ def test_get_scheme_names(self): wanted = ('nt', 'nt_user', 'os2', 'os2_home', 'osx_framework_user', - 'posix_home', 'posix_prefix', 'posix_user') + 'posix_home', 'posix_prefix', 'posix_user', 'pypy') self.assertEqual(get_scheme_names(), wanted) @skip_unless_symlink @@ -345,6 +345,7 @@ self.assertEqual(status, 0) self.assertEqual(my_platform, test_platform) +@impl_detail("Test is not PyPy compatible", pypy=False) def test_srcdir(self): # See Issues #15322, #15364. srcdir = sysconfig.get_config_var('srcdir') @@ -379,7 +380,7 @@ class MakefileTests(unittest.TestCase): -@impl_detail("PyPy lacks sysconfig.get_makefile_filename", pypy=False) +@impl_detail("Test is not PyPy compatible", pypy=False) @unittest.skipIf(sys.platform.startswith('win'), 'Test is not Windows compatible') def test_get_makefile_filename(self): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: this workaround is now disabled and seemingly no longer necessary
Author: Philip Jenvey Branch: py3k Changeset: r84611:02818992e583 Date: 2016-05-22 17:29 -0700 http://bitbucket.org/pypy/pypy/changeset/02818992e583/ Log:this workaround is now disabled and seemingly no longer necessary diff --git a/pypy/conftest.py b/pypy/conftest.py --- a/pypy/conftest.py +++ b/pypy/conftest.py @@ -185,29 +185,7 @@ __multicall__.execute() def pytest_runtest_teardown(__multicall__, item): -user_del_action = None -if isinstance(item, py.test.collect.Function): -appclass = item.getparent(PyPyClassCollector) -if (appclass is not None and -not getattr(appclass.obj, 'runappdirect', False) and -hasattr(appclass.obj, 'space')): -user_del_action = appclass.obj.space.user_del_action - -if user_del_action: -# if leakfinder triggers leftover __del__s, ensure their -# enqueue_for_destruction callbacks are invoked immediately -# instead of scheduled for later (potentially never) -user_del_action._invoke_immediately = True -try: -# leakfinder -__multicall__.execute() -finally: -if user_del_action: -user_del_action._invoke_immediately = False - -if 'pygame' in sys.modules: -assert option.view, ("should not invoke Pygame " - "if conftest.option.view is False") +__multicall__.execute() class PyPyClassCollector(py.test.collect.Class): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: fix from probably a bad merge: the default branch removed this check
Author: Philip Jenvey Branch: py3k Changeset: r84612:1de1aad3990e Date: 2016-05-22 17:52 -0700 http://bitbucket.org/pypy/pypy/changeset/1de1aad3990e/ Log:fix from probably a bad merge: the default branch removed this check diff --git a/pypy/interpreter/executioncontext.py b/pypy/interpreter/executioncontext.py --- a/pypy/interpreter/executioncontext.py +++ b/pypy/interpreter/executioncontext.py @@ -539,8 +539,6 @@ self.pending_with_disabled_del = None def perform(self, executioncontext, frame): -if self.finalizers_lock_count > 0: -return self._run_finalizers() @jit.dont_look_inside ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: skip without hypothesis installed
Author: Philip Jenvey Branch: py3k Changeset: r84613:77179513ecd2 Date: 2016-05-22 18:12 -0700 http://bitbucket.org/pypy/pypy/changeset/77179513ecd2/ Log:skip without hypothesis installed diff --git a/pypy/module/posix/test/test_interp_posix.py b/pypy/module/posix/test/test_interp_posix.py --- a/pypy/module/posix/test/test_interp_posix.py +++ b/pypy/module/posix/test/test_interp_posix.py @@ -1,8 +1,6 @@ import sys import py -from hypothesis import given -from hypothesis.strategies import integers from rpython.tool.udir import udir from pypy.conftest import pypydir @@ -44,12 +42,20 @@ w_time = space.wrap(123.456) assert convert_seconds(space, w_time) == (123, 45600) -@given(s=integers(min_value=-2**30, max_value=2**30), - ns=integers(min_value=0, max_value=10**9)) -def test_convert_seconds_full(space, s, ns): -w_time = space.wrap(s + ns * 1e-9) -sec, nsec = convert_seconds(space, w_time) -assert 0 <= nsec < 1e9 -MAX_ERR = 1e9 / 2**23 + 1 # nsec has 53 - 30 = 23 bits of precisin -err = (sec * 10**9 + nsec) - (s * 10**9 + ns) -assert -MAX_ERR < err < MAX_ERR +def test_convert_seconds_full(space): +try: +from hypothesis import given +from hypothesis.strategies import integers +except ImportError: +py.test.skip("hypothesis not found") + +@given(s=integers(min_value=-2**30, max_value=2**30), + ns=integers(min_value=0, max_value=10**9)) +def _test_convert_seconds_full(space, s, ns): +w_time = space.wrap(s + ns * 1e-9) +sec, nsec = convert_seconds(space, w_time) +assert 0 <= nsec < 1e9 +MAX_ERR = 1e9 / 2**23 + 1 # nsec has 53 - 30 = 23 bits of precisin +err = (sec * 10**9 + nsec) - (s * 10**9 + ns) +assert -MAX_ERR < err < MAX_ERR +_test_convert_seconds_full(space) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: Prevent duplicate winreg module creation on win32
Author: Ronan Lamy Branch: py3k Changeset: r84614:30c1d6cb8f7d Date: 2016-05-23 03:11 +0100 http://bitbucket.org/pypy/pypy/changeset/30c1d6cb8f7d/ Log:Prevent duplicate winreg module creation on win32 diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py --- a/pypy/interpreter/baseobjspace.py +++ b/pypy/interpreter/baseobjspace.py @@ -595,7 +595,7 @@ bootstrap_modules = set(('sys', 'imp', 'builtins', 'exceptions')) if sys.platform.startswith("win"): self.setbuiltinmodule('_winreg') -bootstrap_modules.add('winreg') +bootstrap_modules.add('_winreg') installed_builtin_modules = list(bootstrap_modules) exception_types_w = self.export_builtin_exceptions() ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit