Author: Philip Jenvey <pjen...@underboss.org> Branch: py3k Changeset: r60355:99491555f303 Date: 2013-01-22 18:10 -0800 http://bitbucket.org/pypy/pypy/changeset/99491555f303/
Log: merge default diff --git a/pypy/doc/arm.rst b/pypy/doc/arm.rst --- a/pypy/doc/arm.rst +++ b/pypy/doc/arm.rst @@ -130,15 +130,7 @@ export SB2=/srv/chroot/precise_arm export SB2OPT='-t ARM' -Once this is set, you can call the translator - -:: - - pypy ~/path_to_pypy_checkout/pypy/translator/goal/translate.py -O1 --platform=arm target.py - -If everything worked correctly this should yield an ARM binary. Running this binary in the ARM chroot or on an ARM device should produce the output ``"Hello World"``. - -.. _`this`: +Once this is set, you can call the translator. For example save this file :: @@ -148,3 +140,22 @@ def target(*args): return main, None + +and call the translator + +:: + + pypy ~/path_to_pypy_checkout/pypy/translator/goal/translate.py -O1 --platform=arm target.py + +If everything worked correctly this should yield an ARM binary. Running this binary in the ARM chroot or on an ARM device should produce the output ``"Hello World"``. + +To translate the full python pypy interpreter with a jit, you can cd into pypy/goal and call + +:: + + pypy <path to rpython>/rpython/translator/goal/translate.py -Ojit --platform=arm --gcrootfinder=shadowstack --jit-backend=arm targetpypystandalone.py + +The gcrootfinder option is needed to work around `issue 1377`_ and the jit-backend works around `issue 1376`_ + +.. _`issue 1377`: https://bugs.pypy.org/issue1377 +.. _`issue 1376`: https://bugs.pypy.org/issue1376 diff --git a/pypy/goal/__init__.py b/pypy/goal/__init__.py new file mode 100644 --- /dev/null +++ b/pypy/goal/__init__.py @@ -0,0 +1,1 @@ +#empty diff --git a/pypy/interpreter/astcompiler/codegen.py b/pypy/interpreter/astcompiler/codegen.py --- a/pypy/interpreter/astcompiler/codegen.py +++ b/pypy/interpreter/astcompiler/codegen.py @@ -985,8 +985,9 @@ def visit_Set(self, s): self.update_position(s.lineno) + elt_count = len(s.elts) if s.elts is not None else 0 self.visit_sequence(s.elts) - self.emit_op_arg(ops.BUILD_SET, len(s.elts)) + self.emit_op_arg(ops.BUILD_SET, elt_count) def visit_Name(self, name): self.update_position(name.lineno) diff --git a/pypy/interpreter/test2/test_targetpypy.py b/pypy/interpreter/test2/test_targetpypy.py --- a/pypy/interpreter/test2/test_targetpypy.py +++ b/pypy/interpreter/test2/test_targetpypy.py @@ -1,6 +1,6 @@ import py -from goal.targetpypystandalone import get_entry_point +from pypy.goal.targetpypystandalone import get_entry_point from pypy.config.pypyoption import get_pypy_config class TestTargetPyPy(object): diff --git a/pypy/module/_ast/test/test_ast.py b/pypy/module/_ast/test/test_ast.py --- a/pypy/module/_ast/test/test_ast.py +++ b/pypy/module/_ast/test/test_ast.py @@ -282,6 +282,12 @@ ]) exec(compile(body, '<string>', 'exec')) + def test_empty_set(self): + import ast + m = ast.Module(body=[ast.Expr(value=ast.Set(elts=[]))]) + ast.fix_missing_locations(m) + compile(m, "<test>", "exec") + def test_invalid_sum(self): import _ast as ast pos = dict(lineno=2, col_offset=3) diff --git a/pypy/module/cpyext/include/ceval.h b/pypy/module/cpyext/include/ceval.h new file mode 100644 --- /dev/null +++ b/pypy/module/cpyext/include/ceval.h @@ -0,0 +1,1 @@ +/* empty */ diff --git a/pypy/module/cpyext/test/conftest.py b/pypy/module/cpyext/test/conftest.py --- a/pypy/module/cpyext/test/conftest.py +++ b/pypy/module/cpyext/test/conftest.py @@ -1,6 +1,15 @@ import py import pytest +def pytest_configure(config): + from pypy.tool.pytest.objspace import gettestobjspace + # For some reason (probably a ll2ctypes cache issue on linux64) + # it's necessary to run "import time" at least once before any + # other cpyext test, otherwise the same statement will fail in + # test_datetime.py. + space = gettestobjspace(usemodules=['rctime']) + space.getbuiltinmodule("time") + def pytest_ignore_collect(path, config): if config.option.runappdirect: return True # "cannot be run by py.test -A" diff --git a/pypy/module/micronumpy/arrayimpl/scalar.py b/pypy/module/micronumpy/arrayimpl/scalar.py --- a/pypy/module/micronumpy/arrayimpl/scalar.py +++ b/pypy/module/micronumpy/arrayimpl/scalar.py @@ -34,6 +34,9 @@ def get_shape(self): return [] + def get_strides(self): + return [] + def create_iter(self, shape=None): return ScalarIterator(self.value) diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py --- a/pypy/module/micronumpy/interp_numarray.py +++ b/pypy/module/micronumpy/interp_numarray.py @@ -40,6 +40,10 @@ self.implementation = self.implementation.set_shape(space, get_shape_from_iterable(space, self.get_size(), w_new_shape)) + def descr_get_strides(self, space): + strides = self.implementation.get_strides() + return space.newtuple([space.wrap(i) for i in strides]) + def get_dtype(self): return self.implementation.dtype @@ -645,6 +649,7 @@ dtype = GetSetProperty(W_NDimArray.descr_get_dtype), shape = GetSetProperty(W_NDimArray.descr_get_shape, W_NDimArray.descr_set_shape), + strides = GetSetProperty(W_NDimArray.descr_get_strides), ndim = GetSetProperty(W_NDimArray.descr_get_ndim), size = GetSetProperty(W_NDimArray.descr_get_size), itemsize = GetSetProperty(W_NDimArray.descr_get_itemsize), diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/micronumpy/test/test_numarray.py --- a/pypy/module/micronumpy/test/test_numarray.py +++ b/pypy/module/micronumpy/test/test_numarray.py @@ -684,6 +684,18 @@ assert a.reshape([1]).shape == (1,) raises(ValueError, "a.reshape(3)") + def test_strides(self): + from _numpypy import array + a = array([[1.0, 2.0], + [3.0, 4.0]]) + assert a.strides == (16, 8) + assert a[1:].strides == (16, 8) + + def test_strides_scalar(self): + from _numpypy import array + a = array(42) + assert a.strides == () + def test_add(self): from _numpypy import array a = array(range(5)) diff --git a/pypy/module/rctime/interp_time.py b/pypy/module/rctime/interp_time.py --- a/pypy/module/rctime/interp_time.py +++ b/pypy/module/rctime/interp_time.py @@ -447,10 +447,6 @@ space.warn("Century info guessed for a 2-digit year.", space.w_DeprecationWarning) - if rffi.getintfield(glob_buf, 'c_tm_wday') < 0: - raise OperationError(space.w_ValueError, - space.wrap("day of week out of range")) - rffi.setintfield(glob_buf, 'c_tm_year', y - 1900) rffi.setintfield(glob_buf, 'c_tm_mon', rffi.getintfield(glob_buf, 'c_tm_mon') - 1) @@ -459,6 +455,12 @@ rffi.setintfield(glob_buf, 'c_tm_yday', rffi.getintfield(glob_buf, 'c_tm_yday') - 1) + # tm_wday does not need checking of its upper-bound since taking "% + # 7" in gettmarg() automatically restricts the range. + if rffi.getintfield(glob_buf, 'c_tm_wday') < 0: + raise OperationError(space.w_ValueError, + space.wrap("day of week out of range")) + return glob_buf def time(space): diff --git a/pypy/module/rctime/test/test_rctime.py b/pypy/module/rctime/test/test_rctime.py --- a/pypy/module/rctime/test/test_rctime.py +++ b/pypy/module/rctime/test/test_rctime.py @@ -113,6 +113,9 @@ if os.name != 'nt': assert rctime.mktime(rctime.localtime(-1)) == -1 + res = rctime.mktime((2000, 1, 1, 0, 0, 0, -1, -1, -1)) + assert rctime.ctime(res) == 'Sat Jan 1 00:00:00 2000' + def test_asctime(self): import time as rctime rctime.asctime() diff --git a/pypy/module/unicodedata/test/test_unicodedata.py b/pypy/module/unicodedata/test/test_unicodedata.py new file mode 100644 --- /dev/null +++ b/pypy/module/unicodedata/test/test_unicodedata.py @@ -0,0 +1,105 @@ +import py +import sys + +class AppTestUnicodeData: + spaceconfig = dict(usemodules=('unicodedata',)) + + def test_hangul_syllables(self): + import unicodedata + # Test all leading, vowel and trailing jamo + # but not every combination of them. + for code, name in ((0xAC00, 'HANGUL SYLLABLE GA'), + (0xAE69, 'HANGUL SYLLABLE GGAEG'), + (0xB0D2, 'HANGUL SYLLABLE NYAGG'), + (0xB33B, 'HANGUL SYLLABLE DYAEGS'), + (0xB5A4, 'HANGUL SYLLABLE DDEON'), + (0xB80D, 'HANGUL SYLLABLE RENJ'), + (0xBA76, 'HANGUL SYLLABLE MYEONH'), + (0xBCDF, 'HANGUL SYLLABLE BYED'), + (0xBF48, 'HANGUL SYLLABLE BBOL'), + (0xC1B1, 'HANGUL SYLLABLE SWALG'), + (0xC41A, 'HANGUL SYLLABLE SSWAELM'), + (0xC683, 'HANGUL SYLLABLE OELB'), + (0xC8EC, 'HANGUL SYLLABLE JYOLS'), + (0xCB55, 'HANGUL SYLLABLE JJULT'), + (0xCDBE, 'HANGUL SYLLABLE CWEOLP'), + (0xD027, 'HANGUL SYLLABLE KWELH'), + (0xD290, 'HANGUL SYLLABLE TWIM'), + (0xD4F9, 'HANGUL SYLLABLE PYUB'), + (0xD762, 'HANGUL SYLLABLE HEUBS'), + (0xAE27, 'HANGUL SYLLABLE GYIS'), + (0xB090, 'HANGUL SYLLABLE GGISS'), + (0xB0AD, 'HANGUL SYLLABLE NANG'), + (0xB316, 'HANGUL SYLLABLE DAEJ'), + (0xB57F, 'HANGUL SYLLABLE DDYAC'), + (0xB7E8, 'HANGUL SYLLABLE RYAEK'), + (0xBA51, 'HANGUL SYLLABLE MEOT'), + (0xBCBA, 'HANGUL SYLLABLE BEP'), + (0xBF23, 'HANGUL SYLLABLE BBYEOH'), + (0xD7A3, 'HANGUL SYLLABLE HIH')): + assert unicodedata.name(chr(code)) == name + assert unicodedata.lookup(name) == chr(code) + # Test outside the range + raises(ValueError, unicodedata.name, chr(0xAC00 - 1)) + raises(ValueError, unicodedata.name, chr(0xD7A3 + 1)) + + def test_cjk(self): + import sys + import unicodedata + cases = ((0x3400, 0x4DB5), + (0x4E00, 0x9FA5)) + if unicodedata.unidata_version >= "5": # don't know the exact limit + cases = ((0x3400, 0x4DB5), + (0x4E00, 0x9FCB), + (0x20000, 0x2A6D6), + (0x2A700, 0x2B734)) + elif unicodedata.unidata_version >= "4.1": + cases = ((0x3400, 0x4DB5), + (0x4E00, 0x9FBB), + (0x20000, 0x2A6D6)) + for first, last in cases: + # Test at and inside the boundary + for i in (first, first + 1, last - 1, last): + charname = 'CJK UNIFIED IDEOGRAPH-%X'%i + char = chr(i) + assert unicodedata.name(char) == charname + assert unicodedata.lookup(charname) == char + # Test outside the boundary + for i in first - 1, last + 1: + charname = 'CJK UNIFIED IDEOGRAPH-%X'%i + char = chr(i) + try: + unicodedata.name(char) + except ValueError as e: + assert e.message == 'no such name' + raises(KeyError, unicodedata.lookup, charname) + + def test_bug_1704793(self): # from CPython + import unicodedata + assert unicodedata.lookup("GOTHIC LETTER FAIHU") == '\U00010346' + + def test_normalize(self): + import unicodedata + raises(TypeError, unicodedata.normalize, 'x') + + @py.test.mark.skipif("sys.maxunicode < 0x10ffff", + reason="requires a 'wide' python build.") + def test_normalize_wide(self): + import unicodedata + assert unicodedata.normalize('NFC', '\U000110a5\U000110ba') == u'\U000110ab' + + def test_linebreaks(self): + linebreaks = (0x0a, 0x0b, 0x0c, 0x0d, 0x85, + 0x1c, 0x1d, 0x1e, 0x2028, 0x2029) + for i in linebreaks: + for j in range(-2, 3): + lines = (chr(i + j) + 'A').splitlines() + if i + j in linebreaks: + assert len(lines) == 2 + else: + assert len(lines) == 1 + + def test_mirrored(self): + import unicodedata + # For no reason, unicodedata.mirrored() returns an int, not a bool + assert repr(unicodedata.mirrored(' ')) == '0' diff --git a/pypy/module/unicodedata/test_unicodedata.py b/pypy/module/unicodedata/test_unicodedata.py deleted file mode 100644 --- a/pypy/module/unicodedata/test_unicodedata.py +++ /dev/null @@ -1,103 +0,0 @@ - -class AppTestUnicodeData: - spaceconfig = dict(usemodules=('unicodedata',)) - - def test_hangul_syllables(self): - import unicodedata - # Test all leading, vowel and trailing jamo - # but not every combination of them. - for code, name in ((0xAC00, 'HANGUL SYLLABLE GA'), - (0xAE69, 'HANGUL SYLLABLE GGAEG'), - (0xB0D2, 'HANGUL SYLLABLE NYAGG'), - (0xB33B, 'HANGUL SYLLABLE DYAEGS'), - (0xB5A4, 'HANGUL SYLLABLE DDEON'), - (0xB80D, 'HANGUL SYLLABLE RENJ'), - (0xBA76, 'HANGUL SYLLABLE MYEONH'), - (0xBCDF, 'HANGUL SYLLABLE BYED'), - (0xBF48, 'HANGUL SYLLABLE BBOL'), - (0xC1B1, 'HANGUL SYLLABLE SWALG'), - (0xC41A, 'HANGUL SYLLABLE SSWAELM'), - (0xC683, 'HANGUL SYLLABLE OELB'), - (0xC8EC, 'HANGUL SYLLABLE JYOLS'), - (0xCB55, 'HANGUL SYLLABLE JJULT'), - (0xCDBE, 'HANGUL SYLLABLE CWEOLP'), - (0xD027, 'HANGUL SYLLABLE KWELH'), - (0xD290, 'HANGUL SYLLABLE TWIM'), - (0xD4F9, 'HANGUL SYLLABLE PYUB'), - (0xD762, 'HANGUL SYLLABLE HEUBS'), - (0xAE27, 'HANGUL SYLLABLE GYIS'), - (0xB090, 'HANGUL SYLLABLE GGISS'), - (0xB0AD, 'HANGUL SYLLABLE NANG'), - (0xB316, 'HANGUL SYLLABLE DAEJ'), - (0xB57F, 'HANGUL SYLLABLE DDYAC'), - (0xB7E8, 'HANGUL SYLLABLE RYAEK'), - (0xBA51, 'HANGUL SYLLABLE MEOT'), - (0xBCBA, 'HANGUL SYLLABLE BEP'), - (0xBF23, 'HANGUL SYLLABLE BBYEOH'), - (0xD7A3, 'HANGUL SYLLABLE HIH')): - assert unicodedata.name(chr(code)) == name - assert unicodedata.lookup(name) == chr(code) - # Test outside the range - raises(ValueError, unicodedata.name, chr(0xAC00 - 1)) - raises(ValueError, unicodedata.name, chr(0xD7A3 + 1)) - - def test_cjk(self): - import sys - import unicodedata - cases = ((0x3400, 0x4DB5), - (0x4E00, 0x9FA5)) - if unicodedata.unidata_version >= "5": # don't know the exact limit - cases = ((0x3400, 0x4DB5), - (0x4E00, 0x9FCB), - (0x20000, 0x2A6D6), - (0x2A700, 0x2B734)) - elif unicodedata.unidata_version >= "4.1": - cases = ((0x3400, 0x4DB5), - (0x4E00, 0x9FBB), - (0x20000, 0x2A6D6)) - for first, last in cases: - # Test at and inside the boundary - for i in (first, first + 1, last - 1, last): - charname = 'CJK UNIFIED IDEOGRAPH-%X'%i - char = chr(i) - assert unicodedata.name(char) == charname - assert unicodedata.lookup(charname) == char - # Test outside the boundary - for i in first - 1, last + 1: - charname = 'CJK UNIFIED IDEOGRAPH-%X'%i - char = chr(i) - try: - unicodedata.name(char) - except ValueError as e: - assert e.message == 'no such name' - raises(KeyError, unicodedata.lookup, charname) - - def test_bug_1704793(self): # from CPython - import unicodedata - assert unicodedata.lookup("GOTHIC LETTER FAIHU") == '\U00010346' - - def test_normalize(self): - import unicodedata - raises(TypeError, unicodedata.normalize, 'x') - - def test_normalize_wide(self): - import sys, unicodedata - if sys.maxunicode < 0x10ffff: - skip("requires a 'wide' python build.") - assert unicodedata.normalize('NFC', '\U000110a5\U000110ba') == '\U000110ab' - - def test_linebreaks(self): - linebreaks = (0x0a, 0x0b, 0x0c, 0x0d, 0x85, - 0x1c, 0x1d, 0x1e, 0x2028, 0x2029) - for i in linebreaks: - for j in range(-2, 3): - lines = (chr(i + j) + 'A').splitlines() - if i + j in linebreaks: - assert len(lines) == 2 - else: - assert len(lines) == 1 - - def test_mirrored(self): - import unicodedata - # For no reason, unicodedata.mirrored() returns an int, not a bool - assert repr(unicodedata.mirrored(' ')) == '0' diff --git a/pypy/pytest-A.cfg b/pypy/pytest-A.cfg --- a/pypy/pytest-A.cfg +++ b/pypy/pytest-A.cfg @@ -1,5 +1,5 @@ cherrypick = ['interpreter', 'objspace/test', 'objspace/std', 'module'] -interp = ['translator/goal/pypy-c'] +interp = ['goal/pypy-c'] test_driver = ['test_all.py', '-A'] diff --git a/pypy/test_all.py b/pypy/test_all.py --- a/pypy/test_all.py +++ b/pypy/test_all.py @@ -23,7 +23,8 @@ if len(sys.argv) == 1 and os.path.dirname(sys.argv[0]) in '.': print >> sys.stderr, __doc__ sys.exit(2) - + #Add toplevel repository dir to sys.path + sys.path.insert(0,os.path.dirname(os.path.dirname(__file__))) import pytest import pytest_cov sys.exit(pytest.main(plugins=[pytest_cov])) diff --git a/pypy/tool/release/package.py b/pypy/tool/release/package.py --- a/pypy/tool/release/package.py +++ b/pypy/tool/release/package.py @@ -11,8 +11,10 @@ import shutil import sys +import os +#Add toplevel repository dir to sys.path +sys.path.insert(0,os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))) import py -import os import fnmatch from rpython.tool.udir import udir diff --git a/pypy/bin/translatorshell.py b/rpython/bin/translatorshell.py rename from pypy/bin/translatorshell.py rename to rpython/bin/translatorshell.py diff --git a/rpython/jit/backend/arm/test/support.py b/rpython/jit/backend/arm/test/support.py --- a/rpython/jit/backend/arm/test/support.py +++ b/rpython/jit/backend/arm/test/support.py @@ -14,6 +14,9 @@ def check_jumps(self, maxcount): pass +if not getattr(os, 'uname', None): + pytest.skip('cannot run arm tests on non-posix platform') + if os.uname()[1] == 'llaima.local': AS = '~/Code/arm-jit/android/android-ndk-r4b//build/prebuilt/darwin-x86/arm-eabi-4.4.0/arm-eabi/bin/as' else: diff --git a/rpython/rlib/parsing/test/test_pcre_regtest.py b/rpython/rlib/parsing/test/test_pcre_regtest.py --- a/rpython/rlib/parsing/test/test_pcre_regtest.py +++ b/rpython/rlib/parsing/test/test_pcre_regtest.py @@ -84,8 +84,7 @@ from rpython.rlib.parsing.regexparse import make_runner, unescape import string import re -import os -this_dir = py.path.local(os.path.realpath(os.path.dirname(__file__))) +this_dir = py.path.local(__file__).join('..') #py.test.skip("Still in progress") diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py --- a/rpython/translator/c/genc.py +++ b/rpython/translator/c/genc.py @@ -131,7 +131,7 @@ self.secondary_entrypoints = secondary_entrypoints def get_eci(self): - pypy_include_dir = py.path.local(os.path.realpath(os.path.dirname(__file__))) + pypy_include_dir = py.path.local(__file__).join('..') include_dirs = [pypy_include_dir] return ExternalCompilationInfo(include_dirs=include_dirs) @@ -753,7 +753,7 @@ defines['PYPY_LONGLONG_BIT'] = LONGLONG_BIT def add_extra_files(eci): - srcdir = py.path.local(os.path.realpath(os.path.dirname(__file__))).join('src') + srcdir = py.path.local(__file__).join('..', 'src') files = [ srcdir / 'entrypoint.c', # ifdef PYPY_STANDALONE srcdir / 'allocator.c', # ifdef PYPY_STANDALONE 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 @@ -5,7 +5,7 @@ from rpython.translator.platform import Platform, log, _run_subprocess import rpython -rpydir = os.path.dirname(rpython.__file__) +rpydir = str(py.path.local(rpython.__file__).join('..')) class BasePosix(Platform): exe_ext = '' diff --git a/rpython/translator/platform/windows.py b/rpython/translator/platform/windows.py --- a/rpython/translator/platform/windows.py +++ b/rpython/translator/platform/windows.py @@ -7,7 +7,7 @@ from rpython.translator.platform import Platform, posix import rpython -rpydir = os.path.dirname(rpython.__file__) +rpydir = str(py.path.local(rpython.__file__).join('..')) def _get_compiler_type(cc, x64_flag): import subprocess _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit