Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r69722:d39482624aee Date: 2014-03-05 12:50 +0100 http://bitbucket.org/pypy/pypy/changeset/d39482624aee/
Log: merge heads diff --git a/pypy/module/micronumpy/tool/numready/main.py b/pypy/module/micronumpy/tool/numready/main.py --- a/pypy/module/micronumpy/tool/numready/main.py +++ b/pypy/module/micronumpy/tool/numready/main.py @@ -39,7 +39,7 @@ return len(self._items) class Item(object): - def __init__(self, name, kind, subitems=None): + def __init__(self, name, kind, subitems=[]): self.name = name self.kind = kind self.subitems = subitems @@ -72,7 +72,7 @@ items = SearchableSet() for line in lines: kind, name = line.split(" : ", 1) - subitems = None + subitems = [] if kind == KINDS["TYPE"] and name in SPECIAL_NAMES and attr is None: subitems = find_numpy_items(python, modname, name) items.add(Item(name, kind, subitems)) @@ -93,7 +93,8 @@ l[i].append(lst[k * lgt + i]) return l -SPECIAL_NAMES = ["ndarray", "dtype", "generic", "flatiter", "ufunc"] +SPECIAL_NAMES = ["ndarray", "dtype", "generic", "flatiter", "ufunc", + "nditer"] def main(argv): cpy_items = find_numpy_items("/usr/bin/python") diff --git a/pypy/module/micronumpy/tool/numready/search.py b/pypy/module/micronumpy/tool/numready/search.py --- a/pypy/module/micronumpy/tool/numready/search.py +++ b/pypy/module/micronumpy/tool/numready/search.py @@ -30,4 +30,4 @@ print kind, ":", name if __name__ == "__main__": - main(sys.argv) \ No newline at end of file + main(sys.argv) diff --git a/pypy/module/pypyjit/test_pypy_c/test_misc.py b/pypy/module/pypyjit/test_pypy_c/test_misc.py --- a/pypy/module/pypyjit/test_pypy_c/test_misc.py +++ b/pypy/module/pypyjit/test_pypy_c/test_misc.py @@ -176,14 +176,14 @@ loop, = log.loops_by_filename(self.filepath) assert loop.match(""" guard_not_invalidated? - i16 = int_ge(i11, i12) - guard_false(i16, descr=...) + i16 = int_lt(i11, i12) + guard_true(i16, descr=...) i20 = int_add(i11, 1) i21 = force_token() setfield_gc(p4, i20, descr=<.* .*W_AbstractSeqIterObject.inst_index .*>) guard_not_invalidated? - i25 = int_ge(i11, i9) - guard_false(i25, descr=...) + i25 = int_lt(i11, i9) + guard_true(i25, descr=...) i27 = int_add_ovf(i7, i11) guard_no_overflow(descr=...) --TICK-- @@ -214,10 +214,10 @@ i21 = force_token() setfield_gc(p4, i20, descr=<.* .*W_AbstractSeqIterObject.inst_index .*>) guard_not_invalidated? - i23 = int_lt(i18, 0) - guard_false(i23, descr=...) - i25 = int_ge(i18, i9) - guard_false(i25, descr=...) + i23 = int_ge(i18, 0) + guard_true(i23, descr=...) + i25 = int_lt(i18, i9) + guard_true(i25, descr=...) i27 = int_add_ovf(i7, i18) guard_no_overflow(descr=...) --TICK-- diff --git a/pypy/objspace/std/test/test_rangeobject.py b/pypy/objspace/std/test/test_rangeobject.py --- a/pypy/objspace/std/test/test_rangeobject.py +++ b/pypy/objspace/std/test/test_rangeobject.py @@ -109,6 +109,14 @@ assert not self.not_forced(r) assert r == [1, 2, 3, 4, 5, 6, 7] + def test_getitem_simple(self): + r = range(4) + assert r[-1] == 3 + assert r[3] == 3 + assert r[-4] == 0 + raises(IndexError, r.__getitem__, -5) + raises(IndexError, r.__getitem__, 4) + def test_reduce(self): it = iter(range(10)) assert it.next() == 0 diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py --- a/rpython/rlib/rposix.py +++ b/rpython/rlib/rposix.py @@ -136,141 +136,92 @@ # - but rpython.rtyper.module.ll_os.py on Windows will replace these functions # with other wrappers that directly handle unicode strings. @specialize.argtype(0) -def open(path, flags, mode): +def _as_bytes(path): assert path is not None if isinstance(path, str): - return os.open(path, flags, mode) + return path else: - return os.open(path.as_bytes(), flags, mode) + return path.as_bytes() + +@specialize.argtype(0) +def open(path, flags, mode): + return os.open(_as_bytes(path), flags, mode) @specialize.argtype(0) def stat(path): - if isinstance(path, str): - return os.stat(path) - else: - return os.stat(path.as_bytes()) + return os.stat(_as_bytes(path)) @specialize.argtype(0) def lstat(path): - if isinstance(path, str): - return os.lstat(path) - else: - return os.lstat(path.as_bytes()) + return os.lstat(_as_bytes(path)) @specialize.argtype(0) def statvfs(path): - if isinstance(path, str): - return os.statvfs(path) - else: - return os.statvfs(path.as_bytes()) + return os.statvfs(_as_bytes(path)) @specialize.argtype(0) def unlink(path): - if isinstance(path, str): - return os.unlink(path) - else: - return os.unlink(path.as_bytes()) + return os.unlink(_as_bytes(path)) @specialize.argtype(0, 1) def rename(path1, path2): - if isinstance(path1, str): - return os.rename(path1, path2) - else: - return os.rename(path1.as_bytes(), path2.as_bytes()) + return os.rename(_as_bytes(path1), _as_bytes(path2)) @specialize.argtype(0) def listdir(dirname): - if isinstance(dirname, str): - return os.listdir(dirname) - else: - return os.listdir(dirname.as_bytes()) + return os.listdir(_as_bytes(dirname)) @specialize.argtype(0) def access(path, mode): - if isinstance(path, str): - return os.access(path, mode) - else: - return os.access(path.as_bytes(), mode) + return os.access(_as_bytes(path), mode) @specialize.argtype(0) def chmod(path, mode): - if isinstance(path, str): - return os.chmod(path, mode) - else: - return os.chmod(path.as_bytes(), mode) + return os.chmod(_as_bytes(path), mode) @specialize.argtype(0, 1) def utime(path, times): - if isinstance(path, str): - return os.utime(path, times) - else: - return os.utime(path.as_bytes(), times) + return os.utime(_as_bytes(path), times) @specialize.argtype(0) def chdir(path): - if isinstance(path, str): - return os.chdir(path) - else: - return os.chdir(path.as_bytes()) + return os.chdir(_as_bytes(path)) @specialize.argtype(0) def mkdir(path, mode=0777): - if isinstance(path, str): - return os.mkdir(path, mode) - else: - return os.mkdir(path.as_bytes(), mode) + return os.mkdir(_as_bytes(path), mode) @specialize.argtype(0) def rmdir(path): - if isinstance(path, str): - return os.rmdir(path) - else: - return os.rmdir(path.as_bytes()) + return os.rmdir(_as_bytes(path)) @specialize.argtype(0) def mkfifo(path, mode): - if isinstance(path, str): - os.mkfifo(path, mode) - else: - os.mkfifo(path.as_bytes(), mode) + os.mkfifo(_as_bytes(path), mode) @specialize.argtype(0) def mknod(path, mode, device): - if isinstance(path, str): - os.mknod(path, mode, device) - else: - os.mknod(path.as_bytes(), mode, device) + os.mknod(_as_bytes(path), mode, device) @specialize.argtype(0, 1) def symlink(src, dest): - if isinstance(src, str): - os.symlink(src, dest) - else: - os.symlink(src.as_bytes(), dest.as_bytes()) + os.symlink(_as_bytes(src), _as_bytes(dest)) if os.name == 'nt': import nt + @specialize.argtype(0) def _getfullpathname(path): - if isinstance(path, str): - return nt._getfullpathname(path) - else: - return nt._getfullpathname(path.as_bytes()) + return nt._getfullpathname(_as_bytes(path)) @specialize.argtype(0, 1) def putenv(name, value): - if isinstance(name, str): - os.environ[name] = value - else: - os.environ[name.as_bytes()] = value.as_bytes() + os.environ[_as_bytes(name)] = _as_bytes(value) @specialize.argtype(0) def unsetenv(name): - if isinstance(name, str): - del os.environ[name] - else: - del os.environ[name.as_bytes()] + del os.environ[_as_bytes(name)] if os.name == 'nt': from rpython.rlib import rwin32 _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit