Author: Philip Jenvey <pjen...@underboss.org> Branch: Changeset: r73957:5b2a4468b724 Date: 2014-10-14 12:11 -0700 http://bitbucket.org/pypy/pypy/changeset/5b2a4468b724/
Log: merge upstream diff --git a/pypy/objspace/std/bytearrayobject.py b/pypy/objspace/std/bytearrayobject.py --- a/pypy/objspace/std/bytearrayobject.py +++ b/pypy/objspace/std/bytearrayobject.py @@ -4,6 +4,7 @@ import_from_mixin, newlist_hint, resizelist_hint, specialize) from rpython.rlib.buffer import Buffer from rpython.rlib.rstring import StringBuilder, ByteListBuilder +from rpython.rlib.debug import check_list_of_chars from pypy.interpreter.baseobjspace import W_Root from pypy.interpreter.error import OperationError, oefmt @@ -22,6 +23,7 @@ import_from_mixin(StringMethods) def __init__(self, data): + check_list_of_chars(data) self.data = data def __repr__(self): diff --git a/rpython/config/translationoption.py b/rpython/config/translationoption.py --- a/rpython/config/translationoption.py +++ b/rpython/config/translationoption.py @@ -53,7 +53,7 @@ cmdline="-b --backend"), BoolOption("shared", "Build as a shared library", - default=False, cmdline="--shared"), + default=True, cmdline="--shared"), BoolOption("log", "Include debug prints in the translation (PYPYLOG=...)", default=True, cmdline="--log"), diff --git a/rpython/jit/backend/llsupport/gc.py b/rpython/jit/backend/llsupport/gc.py --- a/rpython/jit/backend/llsupport/gc.py +++ b/rpython/jit/backend/llsupport/gc.py @@ -548,12 +548,6 @@ type_id = self.layoutbuilder.get_type_id(A) descr.tid = llop.combine_ushort(lltype.Signed, type_id, 0) - def _set_tid(self, gcptr, tid): - hdr_addr = llmemory.cast_ptr_to_adr(gcptr) - hdr_addr -= self.gcheaderbuilder.size_gc_header - hdr = llmemory.cast_adr_to_ptr(hdr_addr, self.HDRPTR) - hdr.tid = tid - def can_use_nursery_malloc(self, size): return size < self.max_size_of_young_obj diff --git a/rpython/rlib/debug.py b/rpython/rlib/debug.py --- a/rpython/rlib/debug.py +++ b/rpython/rlib/debug.py @@ -383,3 +383,35 @@ def specialize_call(self, hop): hop.exception_cannot_occur() return hop.inputarg(hop.args_r[0], arg=0) + +def check_list_of_chars(l): + if not we_are_translated(): + assert isinstance(l, list) + for x in l: + assert isinstance(x, (unicode, str)) and len(x) == 1 + return l + +class NotAListOfChars(Exception): + pass + +class Entry(ExtRegistryEntry): + _about_ = check_list_of_chars + + def compute_result_annotation(self, s_arg): + from rpython.annotator.model import SomeList, s_None + from rpython.annotator.model import SomeChar, SomeUnicodeCodePoint + from rpython.annotator.model import SomeImpossibleValue + if s_None.contains(s_arg): + return s_arg # only None: just return + assert isinstance(s_arg, SomeList) + if not isinstance( + s_arg.listdef.listitem.s_value, + (SomeChar, SomeUnicodeCodePoint, SomeImpossibleValue)): + raise NotAListOfChars + return s_arg + + def specialize_call(self, hop): + hop.exception_cannot_occur() + return hop.inputarg(hop.args_r[0], arg=0) + + diff --git a/rpython/rlib/test/test_debug.py b/rpython/rlib/test/test_debug.py --- a/rpython/rlib/test/test_debug.py +++ b/rpython/rlib/test/test_debug.py @@ -4,7 +4,9 @@ debug_print, debug_start, debug_stop, have_debug_prints, debug_offset, debug_flush, check_nonneg, IntegerCanBeNegative, - mark_dict_non_null) + mark_dict_non_null, + check_list_of_chars, + NotAListOfChars) from rpython.rlib import debug from rpython.rtyper.test.test_llinterp import interpret, gengraph @@ -72,6 +74,26 @@ assert sorted(graph.returnblock.inputargs[0].concretetype.TO.entries.TO.OF._flds.keys()) == ['key', 'value'] +def test_check_list_of_chars(): + def f(x): + result = [] + check_list_of_chars(result) + result = [chr(x), 'a'] + check_list_of_chars(result) + result = [unichr(x)] + check_list_of_chars(result) + return result + + interpret(f, [3]) + + def g(x): + result = ['a', 'b', 'c', ''] + check_list_of_chars(result) + return x + + py.test.raises(NotAListOfChars, "interpret(g, [3])") + + class DebugTests(object): def test_debug_print_start_stop(self): diff --git a/rpython/translator/platform/posix.py b/rpython/translator/platform/posix.py --- a/rpython/translator/platform/posix.py +++ b/rpython/translator/platform/posix.py @@ -182,7 +182,7 @@ 'int main(int argc, char* argv[]) ' '{ return $(PYPY_MAIN_FUNCTION)(argc, argv); }" > $@') m.rule('$(DEFAULT_TARGET)', ['$(TARGET)', 'main.o'], - '$(CC_LINK) $(LDFLAGS_LINK) main.o -L. -l$(SHARED_IMPORT_LIB) -o $@') + '$(CC_LINK) $(LDFLAGS_LINK) main.o -L. -l$(SHARED_IMPORT_LIB) -o $@ -Wl,-rpath="$ORIGIN/"') return m _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit