[pypy-commit] pypy py3.5: Clean up pickle tests to better match CPython
Author: Ronan LamyBranch: py3.5 Changeset: r87720:217511d75da2 Date: 2016-10-11 23:46 +0100 http://bitbucket.org/pypy/pypy/changeset/217511d75da2/ Log:Clean up pickle tests to better match CPython diff --git a/pypy/interpreter/test/test_zzpickle_and_slow.py b/pypy/interpreter/test/test_zzpickle_and_slow.py --- a/pypy/interpreter/test/test_zzpickle_and_slow.py +++ b/pypy/interpreter/test/test_zzpickle_and_slow.py @@ -74,6 +74,14 @@ spaceconfig = { "usemodules": ["struct", "binascii"] } +def setup_class(cls): +runappdirect = py.test.config.option.runappdirect +cls.w_runappdirect = cls.space.wrap(runappdirect) + +def w_skip_on_cpython(self): +import sys +if self.runappdirect and '__pypy__' not in sys.modules: +skip('Does not work on CPython') def test_pickle_basic(self): import pickle @@ -82,6 +90,7 @@ assert result == (u'abc', 0) def test_pickle_code(self): +self.skip_on_cpython() def f(): return 42 import pickle @@ -100,6 +109,7 @@ return 42 mod.__dict__['func'] = func func.__module__ = 'mod' +func.__qualname__ = 'func' import pickle pckl = pickle.dumps(func) result = pickle.loads(pckl) @@ -108,6 +118,7 @@ del sys.modules['mod'] def test_pickle_not_imported_module(self): +self.skip_on_cpython() import types mod = types.ModuleType('mod') mod.__dict__['a'] = 1 @@ -124,6 +135,7 @@ assert map is result def test_pickle_non_top_reachable_func(self): +self.skip_on_cpython() def func(): return 42 global a @@ -141,6 +153,7 @@ assert func.__globals__ == result.__globals__ def test_pickle_cell(self): +self.skip_on_cpython() def g(): x = [42] def f(): @@ -155,40 +168,34 @@ assert not (cell != result) def test_pickle_module(self): +self.skip_on_cpython() import pickle -mod= pickle -pckl = pickle.dumps(mod) +mod = pickle +pckl = pickle.dumps(mod) result = pickle.loads(pckl) assert mod is result def test_pickle_moduledict(self): +self.skip_on_cpython() import pickle -moddict = pickle.__dict__ -pckl = pickle.dumps(moddict) -result = pickle.loads(pckl) +moddict = pickle.__dict__ +pckl = pickle.dumps(moddict) +result = pickle.loads(pckl) assert moddict is result def test_pickle_bltins_module(self): +self.skip_on_cpython() import pickle -mod = __builtins__ -pckl = pickle.dumps(mod) -result = pickle.loads(pckl) +mod = __builtins__ +pckl = pickle.dumps(mod) +result = pickle.loads(pckl) assert mod is result -def test_pickle_buffer(self): -skip("Can't pickle buffer objects on top of CPython either. " - "Do we really need it?") -import pickle -a = buffer('ABCDEF') -pckl = pickle.dumps(a) -result = pickle.loads(pckl) -assert a == result - def test_pickle_complex(self): import pickle a = complex(1.23,4.567) -pckl = pickle.dumps(a) -result = pickle.loads(pckl) +pckl = pickle.dumps(a) +result = pickle.loads(pckl) assert a == result def test_pickle_method(self): @@ -199,28 +206,30 @@ return (myclass, ()) import pickle, sys, types myclass.__module__ = 'mod' +myclass.__qualname__ = 'myclass' myclass_inst = myclass() mod = types.ModuleType('mod') mod.myclass = myclass sys.modules['mod'] = mod try: -method = myclass_inst.f -pckl = pickle.dumps(method) -result = pickle.loads(pckl) +method = myclass_inst.f +pckl = pickle.dumps(method) +result = pickle.loads(pckl) # we cannot compare the objects, because the method will be a fresh one assert method() == result() finally: del sys.modules['mod'] def test_pickle_staticmethod(self): +self.skip_on_cpython() class myclass(object): def f(): return 42 f = staticmethod(f) import pickle -method = myclass.f -pckl = pickle.dumps(method) -result = pickle.loads(pckl) +method = myclass.f +pckl = pickle.dumps(method) +result = pickle.loads(pckl) assert method() == result() def test_pickle_classmethod(self): @@ -230,6 +239,7 @@ f = classmethod(f) import pickle, sys, types
[pypy-commit] pypy default: One more "I have no clue how it could have worked so far": if some
Author: Armin RigoBranch: Changeset: r87719:cb834279a539 Date: 2016-10-11 20:19 +0200 http://bitbucket.org/pypy/pypy/changeset/cb834279a539/ Log:One more "I have no clue how it could have worked so far": if some function is only found via vtables, and it indirectly uses a destructor, then boom diff --git a/rpython/memory/gctransform/framework.py b/rpython/memory/gctransform/framework.py --- a/rpython/memory/gctransform/framework.py +++ b/rpython/memory/gctransform/framework.py @@ -679,7 +679,7 @@ # return newgcdependencies -def get_finish_tables(self): +def enum_type_info_members(self): # We must first make sure that the type_info_group's members # are all followed. Do it repeatedly while new members show up. # Once it is really done, do finish_tables(). @@ -688,6 +688,15 @@ curtotal = len(self.layoutbuilder.type_info_group.members) yield self.layoutbuilder.type_info_group.members[seen:curtotal] seen = curtotal + +def get_finish_helpers(self): +for dep in self.enum_type_info_members(): +yield dep +yield self.finish_helpers() + +def get_finish_tables(self): +for dep in self.enum_type_info_members(): +yield dep yield self.finish_tables() def write_typeid_list(self): diff --git a/rpython/memory/gctransform/transform.py b/rpython/memory/gctransform/transform.py --- a/rpython/memory/gctransform/transform.py +++ b/rpython/memory/gctransform/transform.py @@ -286,6 +286,9 @@ newgcdependencies = self.ll_finalizers_ptrs return newgcdependencies +def get_finish_helpers(self): +return self.finish_helpers + def finish_tables(self): pass diff --git a/rpython/translator/c/database.py b/rpython/translator/c/database.py --- a/rpython/translator/c/database.py +++ b/rpython/translator/c/database.py @@ -275,7 +275,7 @@ finish_callbacks = [] if self.gctransformer: finish_callbacks.append(('GC transformer: finished helpers', - self.gctransformer.finish_helpers)) + self.gctransformer.get_finish_helpers())) finish_callbacks.append(('GC transformer: finished tables', self.gctransformer.get_finish_tables())) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] extradoc extradoc: misc
Author: Armin RigoBranch: extradoc Changeset: r5740:d2c31c51500a Date: 2016-10-11 19:40 +0200 http://bitbucket.org/pypy/extradoc/changeset/d2c31c51500a/ Log:misc diff --git a/planning/py3.5/milestone-1-progress.rst b/planning/py3.5/milestone-1-progress.rst --- a/planning/py3.5/milestone-1-progress.rst +++ b/planning/py3.5/milestone-1-progress.rst @@ -36,6 +36,8 @@ * 'import stackless' fails +* "except pyopcode.Return:" in pyframe can't be there, because that's + outside the JIT and it gives terrible performance Milestone 1 (Aug-Sep-Oct 2016) diff --git a/sprintinfo/pyconza2016/topics b/sprintinfo/pyconza2016/topics --- a/sprintinfo/pyconza2016/topics +++ b/sprintinfo/pyconza2016/topics @@ -4,7 +4,7 @@ * run Mercurial benchmarks on pypy, find out why they're slow -* consider the jit opimizeopt's speed-ups +* consider the jit optimizeopt's speed-ups * integrate the memory profiler into vmprof @@ -14,3 +14,8 @@ * discussion about what to do in the next 2-3 weeks + +* spend a day trying to plug cffi instead of lltype+ll2ctypes + +* try out type-specialized bytecodes as a first optimization step after + pure interpretation? ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: Split off the pickle tests that cannot possibly work on appdirect to a separate class
Author: Ronan LamyBranch: py3.5 Changeset: r87718:be1170fa2db1 Date: 2016-10-11 18:39 +0100 http://bitbucket.org/pypy/pypy/changeset/be1170fa2db1/ Log:Split off the pickle tests that cannot possibly work on appdirect to a separate class diff --git a/pypy/interpreter/test/test_zzpickle_and_slow.py b/pypy/interpreter/test/test_zzpickle_and_slow.py --- a/pypy/interpreter/test/test_zzpickle_and_slow.py +++ b/pypy/interpreter/test/test_zzpickle_and_slow.py @@ -71,17 +71,10 @@ class AppTestInterpObjectPickling: -pytestmark = py.test.mark.skipif("config.option.runappdirect") spaceconfig = { "usemodules": ["struct", "binascii"] } -def setup_class(cls): -_attach_helpers(cls.space) - -def teardown_class(cls): -_detach_helpers(cls.space) - def test_pickle_basic(self): import pickle pckl = pickle.dumps((u'abc', 0)) @@ -161,123 +154,6 @@ assert cell == result assert not (cell != result) -def test_pickle_frame(self): -#import sys -# avoid creating a closure for now -def f(): -try: -raise Exception() -except: -import sys -exc_type, exc, tb = sys.exc_info() -return tb.tb_frame -import pickle -f1 = f() -saved = hide_top_frame(f1) -pckl = pickle.dumps(f1) -restore_top_frame(f1, saved) -f2 = pickle.loads(pckl) - -assert type(f1) is type(f2) -assert dir(f1) == dir(f2) -assert f1.__doc__ == f2.__doc__ -assert f2.f_back is None # because we pruned it -assert f1.f_builtins is f2.f_builtins -assert f1.f_code == f2.f_code -assert f1.f_exc_traceback is f2.f_exc_traceback -assert f1.f_exc_type is f2.f_exc_type -assert f1.f_exc_value is f2.f_exc_value -assert f1.f_lasti == f2.f_lasti -assert f1.f_lineno == f2.f_lineno -assert f1.f_restricted is f2.f_restricted -assert f1.f_trace is f2.f_trace - -def test_pickle_frame_with_exc(self): -#import sys -# avoid creating a closure for now -self = None -def f(): -try: -raise ValueError -except: -import sys, pickle -f = sys._getframe() -saved = hide_top_frame(f) -pckl = pickle.dumps(f) -restore_top_frame(f, saved) -return pckl - -import pickle -pckl = f() -f2 = pickle.loads(pckl) - -assert read_exc_type(f2) is ValueError - -def test_pickle_frame_with_exc_nested(self): -# avoid creating a closure for now -self = None -def f(): -try: -1/0 -except: -try: -raise ValueError -except: -import sys, pickle -f = sys._getframe() -saved = hide_top_frame(f) -pckl = pickle.dumps(f) -restore_top_frame(f, saved) -return pckl - -import pickle -pckl = f() -f2 = pickle.loads(pckl) - -assert read_exc_type(f2) is ValueError - -def test_pickle_frame_clos(self): -# similar to above, therefore skipping the asserts. -# we just want to see that the closure works -import sys # this is the difference! -def f(): -try: -raise Exception() -except: -exc_type, exc, tb = sys.exc_info() -return tb.tb_frame -import pickle -f1 = f() -saved = hide_top_frame(f1) -pckl = pickle.dumps(f1) -restore_top_frame(f1, saved) -f2 = pickle.loads(pckl) - -def test_frame_setstate_crash(self): -import sys -raises(ValueError, sys._getframe().__setstate__, []) - -def test_pickle_traceback(self): -def f(): -try: -raise Exception() -except: -from sys import exc_info -exc_type, exc, tb = exc_info() -return tb -import pickle -tb = f() -saved = hide_top_frame(tb.tb_frame) -pckl = pickle.dumps(tb) -result = pickle.loads(pckl) - -assert type(tb) is type(result) -assert tb.tb_lasti == result.tb_lasti -assert tb.tb_lineno == result.tb_lineno -assert tb.tb_next == result.tb_next - -restore_top_frame(tb.tb_frame, saved) - def test_pickle_module(self): import pickle mod= pickle @@ -644,3 +520,133 @@ raises(StopIteration, next, g2) raises(StopIteration, next, g3) raises(StopIteration, next, g4) + +class AppTestFramePickling(object): +
[pypy-commit] pypy py3.5: (plan_rich, arigo) Tweak W_ReverseSeqIter
Author: Armin RigoBranch: py3.5 Changeset: r87717:368ee986dc8e Date: 2016-10-11 19:35 +0200 http://bitbucket.org/pypy/pypy/changeset/368ee986dc8e/ Log:(plan_rich, arigo) Tweak W_ReverseSeqIter diff --git a/pypy/module/_pickle_support/maker.py b/pypy/module/_pickle_support/maker.py --- a/pypy/module/_pickle_support/maker.py +++ b/pypy/module/_pickle_support/maker.py @@ -48,7 +48,7 @@ def reverseseqiter_new(space, w_seq, w_index): w_rev = instantiate(W_ReverseSeqIterObject) if space.is_w(w_seq, space.w_None): -w_rev.w_seq = None +w_rev.w_seq = space.w_None w_rev.index = -1 else: w_rev.w_seq = w_seq diff --git a/pypy/objspace/std/iterobject.py b/pypy/objspace/std/iterobject.py --- a/pypy/objspace/std/iterobject.py +++ b/pypy/objspace/std/iterobject.py @@ -150,6 +150,9 @@ class W_ReverseSeqIterObject(W_Root): def __init__(self, space, w_seq, index=-1): +# w_seq is normally a list object, but can be space.w_None after +# the iterator is exhausted or after a reduce(). In that case, +# self.index == -1. self.w_seq = w_seq self.index = space.len_w(w_seq) + index @@ -158,8 +161,7 @@ w_mod = space.getbuiltinmodule('_pickle_support') mod = space.interp_w(MixedModule, w_mod) new_inst = mod.get('reverseseqiter_new') -w_seq = space.w_None if self.w_seq is None else self.w_seq -tup = [w_seq, space.wrap(self.index)] +tup = [self.w_seq, space.wrap(self.index)] # note that setstate is not called, because this setup already sets the index return space.newtuple([new_inst, space.newtuple(tup)]) @@ -173,7 +175,7 @@ def descr_length_hint(self, space): length = self.index + 1 -if self.w_seq is None or space.len_w(self.w_seq) < length: +if self.w_seq is space.w_None or space.len_w(self.w_seq) < length: length = 0 return space.wrap(length) @@ -198,7 +200,7 @@ # Done self.index = -1 -self.w_seq = None +self.w_seq = space.w_None raise OperationError(space.w_StopIteration, space.w_None) W_ReverseSeqIterObject.typedef = TypeDef( ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: (arigo, plan_rich) missing version check lost by merge (ssl3)
Author: Richard PlanggerBranch: py3.5 Changeset: r87716:67709d07835e Date: 2016-10-11 19:25 +0200 http://bitbucket.org/pypy/pypy/changeset/67709d07835e/ Log:(arigo, plan_rich) missing version check lost by merge (ssl3) diff --git a/pypy/module/_ssl/interp_ssl.py b/pypy/module/_ssl/interp_ssl.py --- a/pypy/module/_ssl/interp_ssl.py +++ b/pypy/module/_ssl/interp_ssl.py @@ -1364,6 +1364,8 @@ options = SSL_OP_ALL & ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS if protocol != PY_SSL_VERSION_SSL2: options |= SSL_OP_NO_SSLv2 +if protocol != PY_SSL_VERSION_SSL3: +options |= SSL_OP_NO_SSLv3 libssl_SSL_CTX_set_options(self.ctx, options) libssl_SSL_CTX_set_session_id_context(self.ctx, "Python", len("Python")) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: Set up sys.*prefix attributes for applevel tests
Author: Ronan LamyBranch: py3.5 Changeset: r87715:dd35ec57b9ef Date: 2016-10-11 18:04 +0100 http://bitbucket.org/pypy/pypy/changeset/dd35ec57b9ef/ Log:Set up sys.*prefix attributes for applevel tests diff --git a/pypy/module/sys/__init__.py b/pypy/module/sys/__init__.py --- a/pypy/module/sys/__init__.py +++ b/pypy/module/sys/__init__.py @@ -154,6 +154,15 @@ from pypy.module.sys.interp_encoding import base_encoding self.filesystemencoding = base_encoding +# Set up sys.prefix and friends, like app_main.py would do +# We somewhat arbitrarily use the repo's root dir as sys.prefix +from pypy import pypydir +import os +rootdir = os.path.dirname(pypydir) +for attr in ['prefix', 'exec_prefix', 'base_prefix', 'base_exec_prefix']: +space.setitem(self.w_dict, space.wrap(attr), space.wrap(rootdir)) + + def flush_std_files(self, space): w_stdout = space.sys.getdictvalue(space, 'stdout') w_stderr = space.sys.getdictvalue(space, 'stderr') ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy value-classes: Merge with default
Author: Spenser Andrew BaumanBranch: value-classes Changeset: r87714:1bdc593889bf Date: 2016-10-11 12:58 -0400 http://bitbucket.org/pypy/pypy/changeset/1bdc593889bf/ Log:Merge with default diff too long, truncating to 2000 out of 46777 lines diff --git a/lib-python/2.7/BaseHTTPServer.py b/lib-python/2.7/BaseHTTPServer.py --- a/lib-python/2.7/BaseHTTPServer.py +++ b/lib-python/2.7/BaseHTTPServer.py @@ -362,14 +362,25 @@ message = short explain = long self.log_error("code %d, message %s", code, message) -# using _quote_html to prevent Cross Site Scripting attacks (see bug #1100201) -content = (self.error_message_format % - {'code': code, 'message': _quote_html(message), 'explain': explain}) self.send_response(code, message) -self.send_header("Content-Type", self.error_content_type) self.send_header('Connection', 'close') + +# Message body is omitted for cases described in: +# - RFC7230: 3.3. 1xx, 204(No Content), 304(Not Modified) +# - RFC7231: 6.3.6. 205(Reset Content) +content = None +if code >= 200 and code not in (204, 205, 304): +# HTML encode to prevent Cross Site Scripting attacks +# (see bug #1100201) +content = (self.error_message_format % { +'code': code, +'message': _quote_html(message), +'explain': explain +}) +self.send_header("Content-Type", self.error_content_type) self.end_headers() -if self.command != 'HEAD' and code >= 200 and code not in (204, 304): + +if self.command != 'HEAD' and content: self.wfile.write(content) error_message_format = DEFAULT_ERROR_MESSAGE diff --git a/lib-python/2.7/CGIHTTPServer.py b/lib-python/2.7/CGIHTTPServer.py --- a/lib-python/2.7/CGIHTTPServer.py +++ b/lib-python/2.7/CGIHTTPServer.py @@ -84,7 +84,7 @@ path begins with one of the strings in self.cgi_directories (and the next character is a '/' or the end of the string). """ -collapsed_path = _url_collapse_path(urllib.unquote(self.path)) +collapsed_path = _url_collapse_path(self.path) dir_sep = collapsed_path.find('/', 1) head, tail = collapsed_path[:dir_sep], collapsed_path[dir_sep+1:] if head in self.cgi_directories: @@ -120,11 +120,7 @@ break # find an explicit query string, if present. -i = rest.rfind('?') -if i >= 0: -rest, query = rest[:i], rest[i+1:] -else: -query = '' +rest, _, query = rest.partition('?') # dissect the part after the directory name into a script name & # a possible additional path, to be stored in PATH_INFO. @@ -308,13 +304,15 @@ The utility of this function is limited to is_cgi method and helps preventing some security attacks. -Returns: A tuple of (head, tail) where tail is everything after the final / -and head is everything before it. Head will always start with a '/' and, -if it contains anything else, never have a trailing '/'. +Returns: The reconstituted URL, which will always start with a '/'. Raises: IndexError if too many '..' occur within the path. """ +# Query component should not be involved. +path, _, query = path.partition('?') +path = urllib.unquote(path) + # Similar to os.path.split(os.path.normpath(path)) but specific to URL # path semantics rather than local operating system semantics. path_parts = path.split('/') @@ -335,6 +333,9 @@ else: tail_part = '' +if query: +tail_part = '?'.join((tail_part, query)) + splitpath = ('/' + '/'.join(head_parts), tail_part) collapsed_path = "/".join(splitpath) diff --git a/lib-python/2.7/Cookie.py b/lib-python/2.7/Cookie.py --- a/lib-python/2.7/Cookie.py +++ b/lib-python/2.7/Cookie.py @@ -190,7 +190,7 @@ Backwards Compatibility --- -In order to keep compatibilty with earlier versions of Cookie.py, +In order to keep compatibility with earlier versions of Cookie.py, it is still possible to use Cookie.Cookie() to create a Cookie. In fact, this simply returns a SmartCookie. diff --git a/lib-python/2.7/SimpleHTTPServer.py b/lib-python/2.7/SimpleHTTPServer.py --- a/lib-python/2.7/SimpleHTTPServer.py +++ b/lib-python/2.7/SimpleHTTPServer.py @@ -167,9 +167,9 @@ words = filter(None, words) path = os.getcwd() for word in words: -drive, word = os.path.splitdrive(word) -head, word = os.path.split(word) -if word in (os.curdir, os.pardir): continue +if os.path.dirname(word) or word in (os.curdir, os.pardir): +# Ignore components that are not a simple file/directory name +continue path = os.path.join(path, word)
[pypy-commit] pypy py3.5: Try to fix test_code_module.py
Author: Ronan LamyBranch: py3.5 Changeset: r87713:aa643d440c39 Date: 2016-10-11 17:42 +0100 http://bitbucket.org/pypy/pypy/changeset/aa643d440c39/ Log:Try to fix test_code_module.py diff --git a/pypy/module/test_lib_pypy/test_code_module.py b/pypy/module/test_lib_pypy/test_code_module.py --- a/pypy/module/test_lib_pypy/test_code_module.py +++ b/pypy/module/test_lib_pypy/test_code_module.py @@ -2,10 +2,7 @@ class AppTestCodeModule: - -def setup_class(cls): -if cls.runappdirect: -py.test.skip("CPython's code module doesn't yet support this") +spaceconfig = {'usemodules': ['struct']} def w_get_interp(self): import code ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: Final merge from branch 'py3k'
Author: Ronan LamyBranch: py3.5 Changeset: r87712:9f357f9d9ef4 Date: 2016-10-11 17:02 +0100 http://bitbucket.org/pypy/pypy/changeset/9f357f9d9ef4/ Log:Final merge from branch 'py3k' diff too long, truncating to 2000 out of 40724 lines diff --git a/lib-python/2.7/BaseHTTPServer.py b/lib-python/2.7/BaseHTTPServer.py --- a/lib-python/2.7/BaseHTTPServer.py +++ b/lib-python/2.7/BaseHTTPServer.py @@ -362,14 +362,25 @@ message = short explain = long self.log_error("code %d, message %s", code, message) -# using _quote_html to prevent Cross Site Scripting attacks (see bug #1100201) -content = (self.error_message_format % - {'code': code, 'message': _quote_html(message), 'explain': explain}) self.send_response(code, message) -self.send_header("Content-Type", self.error_content_type) self.send_header('Connection', 'close') + +# Message body is omitted for cases described in: +# - RFC7230: 3.3. 1xx, 204(No Content), 304(Not Modified) +# - RFC7231: 6.3.6. 205(Reset Content) +content = None +if code >= 200 and code not in (204, 205, 304): +# HTML encode to prevent Cross Site Scripting attacks +# (see bug #1100201) +content = (self.error_message_format % { +'code': code, +'message': _quote_html(message), +'explain': explain +}) +self.send_header("Content-Type", self.error_content_type) self.end_headers() -if self.command != 'HEAD' and code >= 200 and code not in (204, 304): + +if self.command != 'HEAD' and content: self.wfile.write(content) error_message_format = DEFAULT_ERROR_MESSAGE diff --git a/lib-python/2.7/CGIHTTPServer.py b/lib-python/2.7/CGIHTTPServer.py --- a/lib-python/2.7/CGIHTTPServer.py +++ b/lib-python/2.7/CGIHTTPServer.py @@ -84,7 +84,7 @@ path begins with one of the strings in self.cgi_directories (and the next character is a '/' or the end of the string). """ -collapsed_path = _url_collapse_path(urllib.unquote(self.path)) +collapsed_path = _url_collapse_path(self.path) dir_sep = collapsed_path.find('/', 1) head, tail = collapsed_path[:dir_sep], collapsed_path[dir_sep+1:] if head in self.cgi_directories: @@ -120,11 +120,7 @@ break # find an explicit query string, if present. -i = rest.rfind('?') -if i >= 0: -rest, query = rest[:i], rest[i+1:] -else: -query = '' +rest, _, query = rest.partition('?') # dissect the part after the directory name into a script name & # a possible additional path, to be stored in PATH_INFO. @@ -308,13 +304,15 @@ The utility of this function is limited to is_cgi method and helps preventing some security attacks. -Returns: A tuple of (head, tail) where tail is everything after the final / -and head is everything before it. Head will always start with a '/' and, -if it contains anything else, never have a trailing '/'. +Returns: The reconstituted URL, which will always start with a '/'. Raises: IndexError if too many '..' occur within the path. """ +# Query component should not be involved. +path, _, query = path.partition('?') +path = urllib.unquote(path) + # Similar to os.path.split(os.path.normpath(path)) but specific to URL # path semantics rather than local operating system semantics. path_parts = path.split('/') @@ -335,6 +333,9 @@ else: tail_part = '' +if query: +tail_part = '?'.join((tail_part, query)) + splitpath = ('/' + '/'.join(head_parts), tail_part) collapsed_path = "/".join(splitpath) diff --git a/lib-python/2.7/Cookie.py b/lib-python/2.7/Cookie.py --- a/lib-python/2.7/Cookie.py +++ b/lib-python/2.7/Cookie.py @@ -190,7 +190,7 @@ Backwards Compatibility --- -In order to keep compatibilty with earlier versions of Cookie.py, +In order to keep compatibility with earlier versions of Cookie.py, it is still possible to use Cookie.Cookie() to create a Cookie. In fact, this simply returns a SmartCookie. diff --git a/lib-python/2.7/SimpleHTTPServer.py b/lib-python/2.7/SimpleHTTPServer.py --- a/lib-python/2.7/SimpleHTTPServer.py +++ b/lib-python/2.7/SimpleHTTPServer.py @@ -167,9 +167,9 @@ words = filter(None, words) path = os.getcwd() for word in words: -drive, word = os.path.splitdrive(word) -head, word = os.path.split(word) -if word in (os.curdir, os.pardir): continue +if os.path.dirname(word) or word in (os.curdir, os.pardir): +# Ignore components that are not a simple file/directory name +continue path = os.path.join(path, word)
[pypy-commit] pypy py3.3: open the new py3.3 branch (which shadows the closed py3.3 branch)
Author: Richard PlanggerBranch: py3.3 Changeset: r87711:37939b95637a Date: 2016-10-11 16:56 +0200 http://bitbucket.org/pypy/pypy/changeset/37939b95637a/ Log:open the new py3.3 branch (which shadows the closed py3.3 branch) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: close branch
Author: Richard PlanggerBranch: py3k Changeset: r87710:1ed3edf86d71 Date: 2016-10-11 16:56 +0200 http://bitbucket.org/pypy/pypy/changeset/1ed3edf86d71/ Log:close branch ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: (arigo, plan_rich) carry along the changes of guard_not_forced_2 to all other backends
Author: Richard PlanggerBranch: Changeset: r87709:1c139dea3b20 Date: 2016-10-11 16:46 +0200 http://bitbucket.org/pypy/pypy/changeset/1c139dea3b20/ Log:(arigo, plan_rich) carry along the changes of guard_not_forced_2 to all other backends diff --git a/rpython/jit/backend/arm/regalloc.py b/rpython/jit/backend/arm/regalloc.py --- a/rpython/jit/backend/arm/regalloc.py +++ b/rpython/jit/backend/arm/regalloc.py @@ -1067,6 +1067,7 @@ def prepare_op_guard_not_forced_2(self, op, fcond): self.rm.before_call(op.getfailargs(), save_all_regs=True) +self.vfprm.before_call(op.getfailargs(), save_all_regs=True) fail_locs = self._prepare_guard(op) self.assembler.store_force_descr(op, fail_locs[1:], fail_locs[0].value) self.possibly_free_vars(op.getfailargs()) diff --git a/rpython/jit/backend/ppc/regalloc.py b/rpython/jit/backend/ppc/regalloc.py --- a/rpython/jit/backend/ppc/regalloc.py +++ b/rpython/jit/backend/ppc/regalloc.py @@ -965,6 +965,7 @@ def prepare_guard_not_forced_2(self, op): self.rm.before_call(op.getfailargs(), save_all_regs=True) +self.fprm.before_call(op.getfailargs(), save_all_regs=True) arglocs = self._prepare_guard(op) return arglocs diff --git a/rpython/jit/backend/zarch/regalloc.py b/rpython/jit/backend/zarch/regalloc.py --- a/rpython/jit/backend/zarch/regalloc.py +++ b/rpython/jit/backend/zarch/regalloc.py @@ -1138,6 +1138,7 @@ def prepare_guard_not_forced_2(self, op): self.rm.before_call(op.getfailargs(), save_all_regs=True) +self.fprm.before_call(op.getfailargs(), save_all_regs=True) arglocs = self._prepare_guard(op) return arglocs ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: doc changes to link whatsnew for pypy3.3 5.5.0
Author: Richard PlanggerBranch: Changeset: r87708:c88e5a2f7321 Date: 2016-10-11 15:24 +0200 http://bitbucket.org/pypy/pypy/changeset/c88e5a2f7321/ Log:doc changes to link whatsnew for pypy3.3 5.5.0 diff --git a/pypy/doc/index-of-whatsnew.rst b/pypy/doc/index-of-whatsnew.rst --- a/pypy/doc/index-of-whatsnew.rst +++ b/pypy/doc/index-of-whatsnew.rst @@ -32,7 +32,7 @@ .. toctree:: - whatsnew-pypy3.3-5.5.0.rst + whatsnew-pypy3-5.5.0.rst CPython 3.2 compatible versions --- ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: (plan_rich, arigo): Test and fix for guard_not_forced_2, which didn't
Author: Armin RigoBranch: Changeset: r87707:445d6075ff07 Date: 2016-10-11 16:46 +0200 http://bitbucket.org/pypy/pypy/changeset/445d6075ff07/ Log:(plan_rich, arigo): Test and fix for guard_not_forced_2, which didn't save the floating-point register (noo clue how it can have worked for so long) 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 @@ -2647,6 +2647,32 @@ deadframe2 = self.cpu.force(frame) assert self.cpu.get_int_value(deadframe2, 0) == 30 +def test_guard_not_forced_2_float(self): +cpu = self.cpu +if not cpu.supports_floats: +py.test.skip("requires floats") +faildescr = BasicFailDescr(1) +finaldescr = BasicFinalDescr(0) +loop = parse(""" +[f0] +f1 = float_add(f0, 2.5) +p2 = force_token() +guard_not_forced_2(descr=faildescr) [f1] +finish(p2, descr=finaldescr) +""", namespace=locals()) +looptoken = JitCellToken() +self.cpu.compile_loop(loop.inputargs, loop.operations, looptoken) +deadframe = self.cpu.execute_token(looptoken, 20.25) +fail = self.cpu.get_latest_descr(deadframe) +assert fail.identifier == 0 +frame = self.cpu.get_ref_value(deadframe, 0) +# actually, we should get the same pointer in 'frame' and 'deadframe' +# but it is not the case on LLGraph +if not getattr(self.cpu, 'is_llgraph', False): +assert frame == deadframe +deadframe2 = self.cpu.force(frame) +assert self.cpu.get_float_value(deadframe2, 0) == 22.75 + def test_call_to_c_function(self): from rpython.rlib.libffi import CDLL, types, ArgChain, FUNCFLAG_CDECL from rpython.rtyper.lltypesystem.ll2ctypes import libc_name diff --git a/rpython/jit/backend/x86/regalloc.py b/rpython/jit/backend/x86/regalloc.py --- a/rpython/jit/backend/x86/regalloc.py +++ b/rpython/jit/backend/x86/regalloc.py @@ -1428,6 +1428,7 @@ def consider_guard_not_forced_2(self, op): self.rm.before_call(op.getfailargs(), save_all_regs=True) +self.xrm.before_call(op.getfailargs(), save_all_regs=True) fail_locs = [self.loc(v) for v in op.getfailargs()] self.assembler.store_force_descr(op, fail_locs, self.fm.get_frame_depth()) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] jitviewer default: README edited online with Bitbucket
Author: Richard PlanggerBranch: Changeset: r283:b7c4e0f3ca63 Date: 2016-10-11 13:50 + http://bitbucket.org/pypy/jitviewer/changeset/b7c4e0f3ca63/ Log:README edited online with Bitbucket diff --git a/README b/README --- a/README +++ b/README @@ -1,11 +1,11 @@ - PLEASE NOTE! **THIS REPO IS DEPRECATED** -Head over to [this repo](https://github.com/vmprof) instead! +Head over to https://github.com/vmprof instead! The code is now hosted on GitHub, and split into three parts. The client Python library (vmprof-python), the server (vmprof-server) and a repo to do integration testing! + Old JitViewer = @@ -36,4 +36,4 @@ For usage information, invoke jitviewer.py with --help. -An example log file is shipped with the jitviewer source code. +An example log file is shipped with the jitviewer source code. \ No newline at end of file ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] jitviewer default: like this?
Author: Richard PlanggerBranch: Changeset: r282:66f3ff7690ea Date: 2016-10-11 15:48 +0200 http://bitbucket.org/pypy/jitviewer/changeset/66f3ff7690ea/ Log:like this? diff --git a/README b/README --- a/README +++ b/README @@ -1,16 +1,7 @@ -PLEASE NOTE! This repo is: +PLEASE NOTE! **THIS REPO IS DEPRECATED** - _ _ _ - | | | | | | - __| | ___ _ __ _ __ ___ ___ __ _| |_ ___ __| | - / _` |/ _ \ '_ \| '__/ _ \/ __/ _` | __/ _ \/ _` | - | (_| | __/ |_) | | | __/ (_| (_| | || __/ (_| | - \__,_|\___| .__/|_| \___|\___\__,_|\__\___|\__,_| -| | -|_| - -[Go here instead](https://github.com/vmprof) +Head over to [this repo](https://github.com/vmprof) instead! The code is now hosted on GitHub, and split into three parts. The client Python library (vmprof-python), the server (vmprof-server) and a repo to do integration testing! ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] jitviewer default: maybe this is the correct bitbucket markdown?
Author: Richard PlanggerBranch: Changeset: r281:78de652daa1d Date: 2016-10-11 15:45 +0200 http://bitbucket.org/pypy/jitviewer/changeset/78de652daa1d/ Log:maybe this is the correct bitbucket markdown? diff --git a/README b/README --- a/README +++ b/README @@ -1,18 +1,16 @@ PLEASE NOTE! This repo is: -``` - _ _ _ - | | | | | | - __| | ___ _ __ _ __ ___ ___ __ _| |_ ___ __| | - / _` |/ _ \ '_ \| '__/ _ \/ __/ _` | __/ _ \/ _` | - | (_| | __/ |_) | | | __/ (_| (_| | || __/ (_| | - \__,_|\___| .__/|_| \___|\___\__,_|\__\___|\__,_| - | | - |_| -``` + _ _ _ + | | | | | | + __| | ___ _ __ _ __ ___ ___ __ _| |_ ___ __| | + / _` |/ _ \ '_ \| '__/ _ \/ __/ _` | __/ _ \/ _` | + | (_| | __/ |_) | | | __/ (_| (_| | || __/ (_| | + \__,_|\___| .__/|_| \___|\___\__,_|\__\___|\__,_| +| | +|_| -[Please head over to https://github.com/vmprof](https://github.com/vmprof) +[Go here instead](https://github.com/vmprof) The code is now hosted on GitHub, and split into three parts. The client Python library (vmprof-python), the server (vmprof-server) and a repo to do integration testing! ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] jitviewer default: add deprecation warning to repo
Author: Richard PlanggerBranch: Changeset: r280:c5ab0ec88906 Date: 2016-10-11 15:33 +0200 http://bitbucket.org/pypy/jitviewer/changeset/c5ab0ec88906/ Log:add deprecation warning to repo diff --git a/README b/README --- a/README +++ b/README @@ -1,3 +1,25 @@ + +PLEASE NOTE! This repo is: + +``` + _ _ _ + | | | | | | + __| | ___ _ __ _ __ ___ ___ __ _| |_ ___ __| | + / _` |/ _ \ '_ \| '__/ _ \/ __/ _` | __/ _ \/ _` | + | (_| | __/ |_) | | | __/ (_| (_| | || __/ (_| | + \__,_|\___| .__/|_| \___|\___\__,_|\__\___|\__,_| + | | + |_| +``` + +[Please head over to https://github.com/vmprof](https://github.com/vmprof) + +The code is now hosted on GitHub, and split into three parts. The client Python library (vmprof-python), +the server (vmprof-server) and a repo to do integration testing! + +Old JitViewer += + You need to use PyPy to run this. To get started, using a recent virtualenv (1.6.1 or newer), virtualenvwrapper, and a recent PyPy. ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: rename fields to be more explicit, add a helper method
Author: Carl Friedrich BolzBranch: Changeset: r87706:a9211eb5876b Date: 2016-10-11 15:07 +0200 http://bitbucket.org/pypy/pypy/changeset/a9211eb5876b/ Log:rename fields to be more explicit, add a helper method diff --git a/rpython/jit/metainterp/resume.py b/rpython/jit/metainterp/resume.py --- a/rpython/jit/metainterp/resume.py +++ b/rpython/jit/metainterp/resume.py @@ -167,13 +167,18 @@ self.liveboxes = {} self.current = [0] * size self._pos = 0 -self.n = 0 -self.v = 0 +self.num_boxes = 0 +self.num_virtuals = 0 -def append(self, item): +def append_short(self, item): self.current[self._pos] = item self._pos += 1 +def append_int(self, item): +short = rffi.cast(rffi.SHORT, item) +assert rffi.cast(lltype.Signed, short) == item +return self.append_short(short) + class ResumeDataLoopMemo(object): def __init__(self, metainterp_sd): @@ -227,8 +232,8 @@ def _number_boxes(self, iter, arr, optimizer, state): """ Number boxes from one snapshot """ -n = state.n -v = state.v +num_boxes = state.num_boxes +num_virtuals = state.num_virtuals liveboxes = state.liveboxes for item in arr: box = iter.get(rffi.cast(lltype.Signed, item)) @@ -247,15 +252,15 @@ info = optimizer.getrawptrinfo(box, create=False) is_virtual = (info is not None and info.is_virtual()) if is_virtual: -tagged = tag(v, TAGVIRTUAL) -v += 1 +tagged = tag(num_virtuals, TAGVIRTUAL) +num_virtuals += 1 else: -tagged = tag(n, TAGBOX) -n += 1 +tagged = tag(num_boxes, TAGBOX) +num_boxes += 1 liveboxes[box] = tagged -state.append(tagged) -state.n = n -state.v = v +state.append_short(tagged) +state.num_boxes = num_boxes +state.num_virtuals = num_virtuals def number(self, optimizer, position, trace): snapshot_iter = trace.get_snapshot_iter(position) @@ -263,24 +268,24 @@ arr = snapshot_iter.vable_array -state.append(rffi.cast(rffi.SHORT, len(arr))) +state.append_int(len(arr)) self._number_boxes(snapshot_iter, arr, optimizer, state) arr = snapshot_iter.vref_array n = len(arr) assert not (n & 1) -state.append(rffi.cast(rffi.SHORT, n >> 1)) +state.append_int(n >> 1) self._number_boxes(snapshot_iter, arr, optimizer, state) for snapshot in snapshot_iter.framestack: jitcode_index, pc = snapshot_iter.unpack_jitcode_pc(snapshot) -state.append(rffi.cast(rffi.SHORT, jitcode_index)) -state.append(rffi.cast(rffi.SHORT, pc)) +state.append_int(jitcode_index) +state.append_int(pc) self._number_boxes(snapshot_iter, snapshot.box_array, optimizer, state) numb = resumecode.create_numbering(state.current) -return numb, state.liveboxes, state.v +return numb, state.liveboxes, state.num_virtuals # caching for virtuals and boxes inside them @@ -421,14 +426,14 @@ resume_position = self.guard_op.rd_resume_position assert resume_position >= 0 # count stack depth -numb, liveboxes_from_env, v = self.memo.number(optimizer, +numb, liveboxes_from_env, num_virtuals = self.memo.number(optimizer, resume_position, self.optimizer.trace) self.liveboxes_from_env = liveboxes_from_env self.liveboxes = {} storage.rd_numb = numb # collect liveboxes and virtuals -n = len(liveboxes_from_env) - v +n = len(liveboxes_from_env) - num_virtuals liveboxes = [None] * n self.vfieldboxes = {} for box, tagged in liveboxes_from_env.iteritems(): @@ -459,7 +464,7 @@ assert info is not None and info.is_virtual() info.visitor_walk_recursive(fieldbox, self, optimizer) -self._number_virtuals(liveboxes, optimizer, v) +self._number_virtuals(liveboxes, optimizer, num_virtuals) self._add_pending_fields(optimizer, pending_setfields) storage.rd_consts = self.memo.consts ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: kill the dead "forget_numberings" code in resume.py
Author: Carl Friedrich BolzBranch: Changeset: r87705:adff0c72c0f1 Date: 2016-10-11 13:06 +0200 http://bitbucket.org/pypy/pypy/changeset/adff0c72c0f1/ Log:kill the dead "forget_numberings" code in resume.py diff --git a/rpython/jit/metainterp/optimizeopt/info.py b/rpython/jit/metainterp/optimizeopt/info.py --- a/rpython/jit/metainterp/optimizeopt/info.py +++ b/rpython/jit/metainterp/optimizeopt/info.py @@ -132,7 +132,6 @@ def force_box(self, op, optforce): if self.is_virtual(): -optforce.forget_numberings() # if self._is_immutable_and_filled_with_constants(optforce.optimizer): constptr = optforce.optimizer.constant_fold(op) diff --git a/rpython/jit/metainterp/optimizeopt/optimizer.py b/rpython/jit/metainterp/optimizeopt/optimizer.py --- a/rpython/jit/metainterp/optimizeopt/optimizer.py +++ b/rpython/jit/metainterp/optimizeopt/optimizer.py @@ -249,9 +249,6 @@ def produce_potential_short_preamble_ops(self, potential_ops): pass -def forget_numberings(self): -self.optimizer.forget_numberings() - def _can_optimize_call_pure(self, op): arg_consts = [] for i in range(op.numargs()): @@ -350,10 +347,6 @@ for opt in self.optimizations: opt.produce_potential_short_preamble_ops(sb) -def forget_numberings(self): -self.metainterp_sd.profiler.count(jitprof.Counters.OPT_FORCINGS) -self.resumedata_memo.forget_numberings() - def getinfo(self, op): if op.type == 'r': return self.getptrinfo(op) diff --git a/rpython/jit/metainterp/optimizeopt/vstring.py b/rpython/jit/metainterp/optimizeopt/vstring.py --- a/rpython/jit/metainterp/optimizeopt/vstring.py +++ b/rpython/jit/metainterp/optimizeopt/vstring.py @@ -79,7 +79,6 @@ def force_box(self, op, optforce): if not self.is_virtual(): return op -optforce.forget_numberings() if self.mode is mode_string: s = self.get_constant_string_spec(optforce, mode_string) if s is not None: diff --git a/rpython/jit/metainterp/resume.py b/rpython/jit/metainterp/resume.py --- a/rpython/jit/metainterp/resume.py +++ b/rpython/jit/metainterp/resume.py @@ -182,7 +182,6 @@ self.consts = [] self.large_ints = {} self.refs = self.cpu.ts.new_ref_dict_2() -self.numberings = {} self.cached_boxes = {} self.cached_virtuals = {} @@ -282,11 +281,7 @@ numb = resumecode.create_numbering(state.current) return numb, state.liveboxes, state.v - -def forget_numberings(self): -# XXX ideally clear only the affected numberings -self.numberings.clear() -self.clear_box_virtual_numbers() + # caching for virtuals and boxes inside them @@ -526,7 +521,7 @@ if self._invalidation_needed(len(liveboxes), nholes): memo.clear_box_virtual_numbers() - + def _invalidation_needed(self, nliveboxes, nholes): memo = self.memo # xxx heuristic a bit out of thin air ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: kill the pure_reverse function and just move the parts to the relevant
Author: Carl Friedrich BolzBranch: Changeset: r87704:018a54181f0f Date: 2016-10-11 12:10 +0200 http://bitbucket.org/pypy/pypy/changeset/018a54181f0f/ Log:kill the pure_reverse function and just move the parts to the relevant postprocess_* functions. It doesn't make sense to dispatch *twice* on the opnum. diff --git a/rpython/jit/metainterp/optimizeopt/optimizer.py b/rpython/jit/metainterp/optimizeopt/optimizer.py --- a/rpython/jit/metainterp/optimizeopt/optimizer.py +++ b/rpython/jit/metainterp/optimizeopt/optimizer.py @@ -865,63 +865,6 @@ return opinfo is not None and opinfo.is_virtual() return False -def pure_reverse(self, op): -import sys -if self.optpure is None: -return -optpure = self.optpure -if op.getopnum() == rop.INT_ADD: -arg0 = op.getarg(0) -arg1 = op.getarg(1) -optpure.pure_from_args(rop.INT_ADD, [arg1, arg0], op) -# Synthesize the reverse op for optimize_default to reuse -optpure.pure_from_args(rop.INT_SUB, [op, arg1], arg0) -optpure.pure_from_args(rop.INT_SUB, [op, arg0], arg1) -if isinstance(arg0, ConstInt): -# invert the constant -i0 = arg0.getint() -if i0 == -sys.maxint - 1: -return -inv_arg0 = ConstInt(-i0) -elif isinstance(arg1, ConstInt): -# commutative -i0 = arg1.getint() -if i0 == -sys.maxint - 1: -return -inv_arg0 = ConstInt(-i0) -arg1 = arg0 -else: -return -optpure.pure_from_args(rop.INT_SUB, [arg1, inv_arg0], op) -optpure.pure_from_args(rop.INT_SUB, [arg1, op], inv_arg0) -optpure.pure_from_args(rop.INT_ADD, [op, inv_arg0], arg1) -optpure.pure_from_args(rop.INT_ADD, [inv_arg0, op], arg1) - -elif op.getopnum() == rop.INT_SUB: -arg0 = op.getarg(0) -arg1 = op.getarg(1) -optpure.pure_from_args(rop.INT_ADD, [op, arg1], arg0) -optpure.pure_from_args(rop.INT_SUB, [arg0, op], arg1) -if isinstance(arg1, ConstInt): -# invert the constant -i1 = arg1.getint() -if i1 == -sys.maxint - 1: -return -inv_arg1 = ConstInt(-i1) -optpure.pure_from_args(rop.INT_ADD, [arg0, inv_arg1], op) -optpure.pure_from_args(rop.INT_ADD, [inv_arg1, arg0], op) -optpure.pure_from_args(rop.INT_SUB, [op, inv_arg1], arg0) -optpure.pure_from_args(rop.INT_SUB, [op, arg0], inv_arg1) -elif op.getopnum() == rop.FLOAT_MUL: -optpure.pure_from_args(rop.FLOAT_MUL, - [op.getarg(1), op.getarg(0)], op) -elif op.getopnum() == rop.FLOAT_NEG: -optpure.pure_from_args(rop.FLOAT_NEG, [op], op.getarg(0)) -elif op.getopnum() == rop.CAST_INT_TO_PTR: -optpure.pure_from_args(rop.CAST_PTR_TO_INT, [op], op.getarg(0)) -elif op.getopnum() == rop.CAST_PTR_TO_INT: -optpure.pure_from_args(rop.CAST_INT_TO_PTR, [op], op.getarg(0)) - # These are typically removed already by OptRewrite, but it can be # dissabled and unrolling emits some SAME_AS ops to setup the # optimizier state. These needs to always be optimized out. diff --git a/rpython/jit/metainterp/optimizeopt/rewrite.py b/rpython/jit/metainterp/optimizeopt/rewrite.py --- a/rpython/jit/metainterp/optimizeopt/rewrite.py +++ b/rpython/jit/metainterp/optimizeopt/rewrite.py @@ -143,7 +143,21 @@ return self.emit(op) def postprocess_INT_SUB(self, op): -self.optimizer.pure_reverse(op) +import sys +arg0 = op.getarg(0) +arg1 = op.getarg(1) +self.optimizer.pure_from_args(rop.INT_ADD, [op, arg1], arg0) +self.optimizer.pure_from_args(rop.INT_SUB, [arg0, op], arg1) +if isinstance(arg1, ConstInt): +# invert the constant +i1 = arg1.getint() +if i1 == -sys.maxint - 1: +return +inv_arg1 = ConstInt(-i1) +self.optimizer.pure_from_args(rop.INT_ADD, [arg0, inv_arg1], op) +self.optimizer.pure_from_args(rop.INT_ADD, [inv_arg1, arg0], op) +self.optimizer.pure_from_args(rop.INT_SUB, [op, inv_arg1], arg0) +self.optimizer.pure_from_args(rop.INT_SUB, [op, arg0], inv_arg1) def optimize_INT_ADD(self, op): if self.is_raw_ptr(op.getarg(0)) or self.is_raw_ptr(op.getarg(1)): @@ -162,7 +176,32 @@ return self.emit(op) def postprocess_INT_ADD(self, op): -self.optimizer.pure_reverse(op) +import sys +arg0 = op.getarg(0) +arg1 = op.getarg(1) +
[pypy-commit] pypy py3.5: Fix translation
Author: Amaury Forgeot d'ArcBranch: py3.5 Changeset: r87703:2ddf9bfa3ece Date: 2016-10-11 08:19 +0200 http://bitbucket.org/pypy/pypy/changeset/2ddf9bfa3ece/ Log:Fix translation diff --git a/pypy/module/_weakref/interp__weakref.py b/pypy/module/_weakref/interp__weakref.py --- a/pypy/module/_weakref/interp__weakref.py +++ b/pypy/module/_weakref/interp__weakref.py @@ -188,9 +188,6 @@ state = u"; to '%s'" % (typename,) return self.getrepr(space, unicode(self.typedef.name), state) -def descr_callback(self, space): -return self.w_callable - class W_Weakref(W_WeakrefBase): def __init__(self, space, w_obj, w_callable): @@ -232,6 +229,9 @@ def descr__ne__(self, space, w_ref2): return space.not_(space.eq(self, w_ref2)) +def descr_callback(self, space): +return self.w_callable + def getlifeline(space, w_obj): lifeline = w_obj.getweakref() if lifeline is None: @@ -260,7 +260,7 @@ __hash__ = interp2app(W_Weakref.descr_hash), __call__ = interp2app(W_Weakref.descr_call), __repr__ = interp2app(W_WeakrefBase.descr__repr__), -__callback__ = GetSetProperty(W_WeakrefBase.descr_callback), +__callback__ = GetSetProperty(W_Weakref.descr_callback), ) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit