[pypy-commit] pypy py3k: 2to3

2016-10-02 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r87539:b7f4ac3cf6b2
Date: 2016-10-03 07:55 +0200
http://bitbucket.org/pypy/pypy/changeset/b7f4ac3cf6b2/

Log:2to3

diff --git a/pypy/objspace/std/test/test_bytesobject.py 
b/pypy/objspace/std/test/test_bytesobject.py
--- a/pypy/objspace/std/test/test_bytesobject.py
+++ b/pypy/objspace/std/test/test_bytesobject.py
@@ -256,19 +256,13 @@
 assert b'one'.replace(memoryview(b'o'), memoryview(b'n')) == b'nne'
 
 def test_strip(self):
-s = " a b "
-assert s.strip() == "a b"
-assert s.rstrip() == " a b"
-assert s.lstrip() == "a b "
+s = b" a b "
+assert s.strip() == b"a b"
+assert s.rstrip() == b" a b"
+assert s.lstrip() == b"a b "
 assert b'xyzzyhelloxyzzy'.strip(b'xyz') == b'hello'
 assert b'xyzzyhelloxyzzy'.lstrip(b'xyz') == b'helloxyzzy'
 assert b'xyzzyhelloxyzzy'.rstrip(b'xyz') == b'xyzzyhello'
-exc = raises(TypeError, s.strip, buffer(' '))
-assert str(exc.value) == 'strip arg must be None, str or unicode'
-exc = raises(TypeError, s.rstrip, buffer(' '))
-assert str(exc.value) == 'strip arg must be None, str or unicode'
-exc = raises(TypeError, s.lstrip, buffer(' '))
-assert str(exc.value) == 'strip arg must be None, str or unicode'
 
 def test_zfill(self):
 assert b'123'.zfill(2) == b'123'
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2016-09-21 Thread rlamy
Author: Ronan Lamy 
Branch: py3k
Changeset: r87290:4b1d7e36364a
Date: 2016-09-21 20:08 +0100
http://bitbucket.org/pypy/pypy/changeset/4b1d7e36364a/

Log:2to3

diff --git a/pypy/module/cpyext/test/test_longobject.py 
b/pypy/module/cpyext/test/test_longobject.py
--- a/pypy/module/cpyext/test/test_longobject.py
+++ b/pypy/module/cpyext/test/test_longobject.py
@@ -46,7 +46,7 @@
 
 def test_fromdouble(self, space, api):
 w_value = api.PyLong_FromDouble(-12.74)
-assert isinstance(w_value, W_LongObject)
+assert space.isinstance_w(w_value, space.w_int)
 assert space.unwrap(w_value) == -12
 assert api.PyLong_AsDouble(w_value) == -12
 
@@ -108,24 +108,20 @@
 lltype.free(overflow, flavor='raw')
 
 def test_as_voidptr(self, space, api):
-# CPython returns an int (not a long) depending on the value
-# passed to PyLong_FromVoidPtr().  In all cases, NULL becomes
-# the int 0.
 w_l = api.PyLong_FromVoidPtr(lltype.nullptr(rffi.VOIDP.TO))
 assert space.is_w(space.type(w_l), space.w_int)
 assert space.unwrap(w_l) == 0
 assert api.PyLong_AsVoidPtr(w_l) == lltype.nullptr(rffi.VOIDP.TO)
-# Positive values also return an int (assuming, like always in
-# PyPy, that an int is big enough to store any pointer).
+
 p = rffi.cast(rffi.VOIDP, maxint)
 w_l = api.PyLong_FromVoidPtr(p)
 assert space.is_w(space.type(w_l), space.w_int)
 assert space.unwrap(w_l) == maxint
 assert api.PyLong_AsVoidPtr(w_l) == p
-# Negative values always return a long.
+
 p = rffi.cast(rffi.VOIDP, -maxint-1)
 w_l = api.PyLong_FromVoidPtr(p)
-assert space.is_w(space.type(w_l), space.w_long)
+assert space.is_w(space.type(w_l), space.w_int)
 assert space.unwrap(w_l) == maxint+1
 assert api.PyLong_AsVoidPtr(w_l) == p
 
@@ -287,7 +283,7 @@
 return PyLong_FromLong(3);
  if (str + strlen(str) != end)
 return PyLong_FromLong(4);
- return PyLong_FromLong(0); 
+ return PyLong_FromLong(0);
  """)])
 assert module.from_str() == 0
 
@@ -343,4 +339,4 @@
 assert module.has_pow() == 0
 assert module.has_hex() == '0x2aL'
 assert module.has_oct() == '052L'
-
+
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2016-05-29 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r84814:342ade5f1037
Date: 2016-05-29 17:54 +0200
http://bitbucket.org/pypy/pypy/changeset/342ade5f1037/

Log:2to3

diff --git a/pypy/module/__builtin__/test/test_functional.py 
b/pypy/module/__builtin__/test/test_functional.py
--- a/pypy/module/__builtin__/test/test_functional.py
+++ b/pypy/module/__builtin__/test/test_functional.py
@@ -587,9 +587,9 @@
 raises(TypeError, min, 1, 2, key=lambda x: x, bar=2)
 assert type(min(1, 1.0)) is int
 assert type(min(1.0, 1)) is float
-assert type(min(1, 1.0, 1L)) is int
-assert type(min(1.0, 1L, 1)) is float
-assert type(min(1L, 1, 1.0)) is long
+assert type(min(1, 1.0, 1)) is int
+assert type(min(1.0, 1, 1)) is float
+assert type(min(1, 1, 1.0)) is int
 
 def test_max(self):
 assert max(1, 2) == 2
@@ -599,6 +599,6 @@
 raises(TypeError, max, 1, 2, key=lambda x: x, bar=2)
 assert type(max(1, 1.0)) is int
 assert type(max(1.0, 1)) is float
-assert type(max(1, 1.0, 1L)) is int
-assert type(max(1.0, 1L, 1)) is float
-assert type(max(1L, 1, 1.0)) is long
+assert type(max(1, 1.0, 1)) is int
+assert type(max(1.0, 1, 1)) is float
+assert type(max(1, 1, 1.0)) is int
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2016-04-20 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r83800:40c11f7ad71a
Date: 2016-04-20 23:44 +0200
http://bitbucket.org/pypy/pypy/changeset/40c11f7ad71a/

Log:2to3

diff --git a/pypy/module/__pypy__/test/test_magic.py 
b/pypy/module/__pypy__/test/test_magic.py
--- a/pypy/module/__pypy__/test/test_magic.py
+++ b/pypy/module/__pypy__/test/test_magic.py
@@ -56,7 +56,7 @@
 from __pypy__ import _promote
 assert _promote(1) == 1
 assert _promote(1.1) == 1.1
-assert _promote("abc") == "abc"
+assert _promote(b"abc") == b"abc"
 raises(TypeError, _promote, u"abc")
 l = []
 assert _promote(l) is l
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2016-04-20 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r83799:9f5913d6c6c2
Date: 2016-04-20 23:37 +0200
http://bitbucket.org/pypy/pypy/changeset/9f5913d6c6c2/

Log:2to3

diff --git a/pypy/objspace/std/test/test_typeobject.py 
b/pypy/objspace/std/test/test_typeobject.py
--- a/pypy/objspace/std/test/test_typeobject.py
+++ b/pypy/objspace/std/test/test_typeobject.py
@@ -1176,22 +1176,26 @@
 """
 
 def test_crash_mro_without_object_1(self):
+"""
 class X(type):
 def mro(self):
 return [self]
-class C:
-__metaclass__ = X
+class C(metaclass=X):
+pass
 e = raises(TypeError, C) # the lookup of '__new__' fails
 assert str(e.value) == "cannot create 'C' instances"
+"""
 
 def test_crash_mro_without_object_2(self):
+"""
 class X(type):
 def mro(self):
 return [self, int]
-class C(int):
-__metaclass__ = X
+class C(int, metaclass=X):
+pass
 C()# the lookup of '__new__' succeeds in 'int',
# but the lookup of '__init__' fails
+"""
 
 
 class AppTestWithMethodCacheCounter:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2016-02-02 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r82044:8645b9cf5eab
Date: 2016-02-02 18:30 +0100
http://bitbucket.org/pypy/pypy/changeset/8645b9cf5eab/

Log:2to3

diff --git a/pypy/module/__pypy__/test/test_magic.py 
b/pypy/module/__pypy__/test/test_magic.py
--- a/pypy/module/__pypy__/test/test_magic.py
+++ b/pypy/module/__pypy__/test/test_magic.py
@@ -24,26 +24,26 @@
 __pypy__.set_code_callback(callable)
 d = {}
 try:
-exec """
+exec("""
 def f():
 pass
-""" in d
+""", d)
 finally:
 __pypy__.set_code_callback(None)
 assert d['f'].__code__ in l
 
 def test_decode_long(self):
 from __pypy__ import decode_long
-assert decode_long('') == 0
-assert decode_long('\xff\x00') == 255
-assert decode_long('\xff\x7f') == 32767
-assert decode_long('\x00\xff') == -256
-assert decode_long('\x00\x80') == -32768
-assert decode_long('\x80') == -128
-assert decode_long('\x7f') == 127
-assert decode_long('\x55' * 97) == (1 << (97 * 8)) // 3
-assert decode_long('\x00\x80', 'big') == 128
-assert decode_long('\xff\x7f', 'little', False) == 32767
-assert decode_long('\x00\x80', 'little', False) == 32768
-assert decode_long('\x00\x80', 'little', True) == -32768
+assert decode_long(b'') == 0
+assert decode_long(b'\xff\x00') == 255
+assert decode_long(b'\xff\x7f') == 32767
+assert decode_long(b'\x00\xff') == -256
+assert decode_long(b'\x00\x80') == -32768
+assert decode_long(b'\x80') == -128
+assert decode_long(b'\x7f') == 127
+assert decode_long(b'\x55' * 97) == (1 << (97 * 8)) // 3
+assert decode_long(b'\x00\x80', 'big') == 128
+assert decode_long(b'\xff\x7f', 'little', False) == 32767
+assert decode_long(b'\x00\x80', 'little', False) == 32768
+assert decode_long(b'\x00\x80', 'little', True) == -32768
 raises(ValueError, decode_long, '', 'foo')
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2016-02-02 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r82046:77bfed7253ce
Date: 2016-02-02 19:14 +0100
http://bitbucket.org/pypy/pypy/changeset/77bfed7253ce/

Log:2to3

diff --git a/pypy/module/_socket/test/test_sock_app.py 
b/pypy/module/_socket/test/test_sock_app.py
--- a/pypy/module/_socket/test/test_sock_app.py
+++ b/pypy/module/_socket/test/test_sock_app.py
@@ -651,7 +651,7 @@
 def test_connect_to_kernel_netlink_routing_socket(self):
 import _socket, os
 s = _socket.socket(_socket.AF_NETLINK, _socket.SOCK_DGRAM, 
_socket.NETLINK_ROUTE)
-assert s.getsockname() == (0L, 0L)
+assert s.getsockname() == (0, 0)
 s.bind((0, 0))
 a, b = s.getsockname()
 assert a == os.getpid()
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2016-02-02 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r82045:60029cb06b5b
Date: 2016-02-02 19:09 +0100
http://bitbucket.org/pypy/pypy/changeset/60029cb06b5b/

Log:2to3

diff --git a/pypy/module/_cffi_backend/test/test_recompiler.py 
b/pypy/module/_cffi_backend/test/test_recompiler.py
--- a/pypy/module/_cffi_backend/test/test_recompiler.py
+++ b/pypy/module/_cffi_backend/test/test_recompiler.py
@@ -1046,7 +1046,7 @@
 #
 @ffi.callback("int *(*)(void)")
 def get_my_value():
-return values + it.next()
+return values + next(it)
 lib.get_my_value = get_my_value
 #
 values[0] = 41
@@ -1390,7 +1390,7 @@
 def getvalue(self):
 if self._result is None:
 os.close(self._wr)
-self._result = os.read(self._rd, 4096)
+self._result = os.read(self._rd, 4096).decode()
 os.close(self._rd)
 # xxx hack away these lines
 while self._result.startswith('[platform:execute]'):
@@ -1456,11 +1456,11 @@
 baz1 = ffi.def_extern()(baz)
 assert baz1 is baz
 seen = []
-baz(40L, 4L)
-res = lib.baz(50L, 8L)
+baz(40, 4)
+res = lib.baz(50, 8)
 assert res is None
-assert seen == [("Baz", 40L, 4L), ("Baz", 50, 8)]
-assert type(seen[0][1]) is type(seen[0][2]) is long
+assert seen == [("Baz", 40, 4), ("Baz", 50, 8)]
+assert type(seen[0][1]) is type(seen[0][2]) is int
 assert type(seen[1][1]) is type(seen[1][2]) is int
 
 @ffi.def_extern(name="bok")
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2016-02-02 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r82047:fbb1c9fd86c0
Date: 2016-02-02 19:17 +0100
http://bitbucket.org/pypy/pypy/changeset/fbb1c9fd86c0/

Log:2to3

diff --git a/pypy/module/itertools/test/test_itertools.py 
b/pypy/module/itertools/test/test_itertools.py
--- a/pypy/module/itertools/test/test_itertools.py
+++ b/pypy/module/itertools/test/test_itertools.py
@@ -201,8 +201,8 @@
 # CPython implementation allows floats
 it = itertools.islice([1, 2, 3, 4, 5], 0.0, 3.0, 2.0)
 for x in [1, 3]:
-assert it.next() == x
-raises(StopIteration, it.next)
+assert next(it) == x
+raises(StopIteration, next, it)
 
 it = itertools.islice([1, 2, 3], 0, None)
 for x in [1, 2, 3]:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2016-02-01 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r82027:91eaf91dbb4c
Date: 2016-02-01 11:45 +0100
http://bitbucket.org/pypy/pypy/changeset/91eaf91dbb4c/

Log:2to3

diff --git a/lib_pypy/greenlet.py b/lib_pypy/greenlet.py
--- a/lib_pypy/greenlet.py
+++ b/lib_pypy/greenlet.py
@@ -203,7 +203,7 @@
 try:
 if hasattr(_tls, 'trace'):
 _run_trace_callback('throw')
-raise exc, value, tb
+raise __pypy__.normalize_exc(exc, value, tb)
 except GreenletExit as e:
 res = e
 finally:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2015-11-23 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r80862:d6232c50f187
Date: 2015-11-23 18:11 +0100
http://bitbucket.org/pypy/pypy/changeset/d6232c50f187/

Log:2to3

diff --git a/pypy/module/__builtin__/functional.py 
b/pypy/module/__builtin__/functional.py
--- a/pypy/module/__builtin__/functional.py
+++ b/pypy/module/__builtin__/functional.py
@@ -214,10 +214,12 @@
 start = 0
 else:
 w_start = space.index(w_start)
-if space.is_w(space.type(w_start), space.w_int):
+try:
 start = space.int_w(w_start)
 w_start = None
-else:
+except OperationError as e:
+if not e.match(space, space.w_OverflowError):
+raise
 start = -1
 
 if start == 0 and type(w_iterable) is W_ListObject:
diff --git a/pypy/module/__builtin__/test/test_builtin.py 
b/pypy/module/__builtin__/test/test_builtin.py
--- a/pypy/module/__builtin__/test/test_builtin.py
+++ b/pypy/module/__builtin__/test/test_builtin.py
@@ -313,8 +313,8 @@
 enum = enumerate(range(2), 2**100)
 assert list(enum) == [(2**100, 0), (2**100+1, 1)]
 
-enum = enumerate(range(2), sys.maxint)
-assert list(enum) == [(sys.maxint, 0), (sys.maxint+1, 1)]
+enum = enumerate(range(2), sys.maxsize)
+assert list(enum) == [(sys.maxsize, 0), (sys.maxsize+1, 1)]
 
 raises(TypeError, enumerate, range(2), 5.5)
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2015-11-19 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r80771:2656e0ec2579
Date: 2015-11-19 13:29 +0100
http://bitbucket.org/pypy/pypy/changeset/2656e0ec2579/

Log:2to3

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
@@ -606,7 +606,7 @@
 static PyObject * 
 foo_nb_add_call(PyObject *self, PyObject *other)
 {
-return PyInt_FromLong(42); 
+return PyLong_FromLong(42); 
 }
 
 PyTypeObject Foo_Type = {
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2015-11-18 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r80754:27eb9104567c
Date: 2015-11-15 10:44 +0100
http://bitbucket.org/pypy/pypy/changeset/27eb9104567c/

Log:2to3

diff --git a/pypy/module/thread/test/test_lock.py 
b/pypy/module/thread/test/test_lock.py
--- a/pypy/module/thread/test/test_lock.py
+++ b/pypy/module/thread/test/test_lock.py
@@ -182,7 +182,7 @@
 self.sig_recvd = True
 old_handler = signal.signal(signal.SIGUSR1, my_handler)
 try:
-ready = thread.allocate_lock()
+ready = _thread.allocate_lock()
 ready.acquire()
 def other_thread():
 # Acquire the lock in a non-main thread, so this test works for
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2015-09-30 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r79915:6029baccadac
Date: 2015-09-30 16:29 +0200
http://bitbucket.org/pypy/pypy/changeset/6029baccadac/

Log:2to3

diff --git a/pypy/module/_vmprof/test/test__vmprof.py 
b/pypy/module/_vmprof/test/test__vmprof.py
--- a/pypy/module/_vmprof/test/test__vmprof.py
+++ b/pypy/module/_vmprof/test/test__vmprof.py
@@ -40,7 +40,7 @@
 count += 1
 i += 2 * WORD + size
 else:
-raise AssertionError(ord(s[i]))
+raise AssertionError(s[i])
 return count
 
 import _vmprof
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2015-08-21 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r79129:bff4896d8c5a
Date: 2015-08-22 03:01 +0200
http://bitbucket.org/pypy/pypy/changeset/bff4896d8c5a/

Log:2to3

diff --git a/pypy/module/_vmprof/test/test__vmprof.py 
b/pypy/module/_vmprof/test/test__vmprof.py
--- a/pypy/module/_vmprof/test/test__vmprof.py
+++ b/pypy/module/_vmprof/test/test__vmprof.py
@@ -25,7 +25,7 @@
 assert s[i + 1] == 0# 0
 assert s[i + 2] == 1# VERSION_THREAD_ID
 assert s[i + 3] == 4# len('pypy')
-assert s[i + 4: i + 8] == 'pypy'
+assert s[i + 4: i + 8] == b'pypy'
 i += 8
 while i < len(s):
 if s[i] == 3:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2015-07-16 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r78564:6da82c1b733b
Date: 2015-07-17 04:23 +0200
http://bitbucket.org/pypy/pypy/changeset/6da82c1b733b/

Log:2to3

diff --git a/pypy/module/_cffi_backend/test/test_ffi_obj.py 
b/pypy/module/_cffi_backend/test/test_ffi_obj.py
--- a/pypy/module/_cffi_backend/test/test_ffi_obj.py
+++ b/pypy/module/_cffi_backend/test/test_ffi_obj.py
@@ -300,7 +300,7 @@
 seen = []
 def myalloc(size):
 seen.append(size)
-return ffi.new("char[]", "X" * size)
+return ffi.new("char[]", b"X" * size)
 def myfree(raw):
 seen.append(raw)
 alloc1 = ffi.new_allocator(myalloc, myfree)
@@ -333,7 +333,7 @@
 seen = []
 def myalloc(size):
 seen.append(size)
-return ffi.new("char[]", "X" * size)
+return ffi.new("char[]", b"X" * size)
 alloc1 = ffi.new_allocator(myalloc)# no 'free'
 p1 = alloc1("int[10]")
 assert seen == [40]
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2015-07-16 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r78563:e3d0cafafa1a
Date: 2015-07-17 04:21 +0200
http://bitbucket.org/pypy/pypy/changeset/e3d0cafafa1a/

Log:2to3

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
@@ -537,9 +537,9 @@
 yield 0
 
 x = f()
-x.next()
+next(x)
 try:
-x.next()
+next(x)
 except StopIteration:
 y = pickle.loads(pickle.dumps(x))
 assert 'finished' in y.__name__
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2015-07-02 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r78412:3cb6a7ae2fb7
Date: 2015-07-02 12:40 +0200
http://bitbucket.org/pypy/pypy/changeset/3cb6a7ae2fb7/

Log:2to3

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
@@ -1407,15 +1407,15 @@
 return self
 def load_module(self, fullname):
 assert fullname == 'meta_path_2_pseudo_module'
-m = new.module('meta_path_2_pseudo_module')
+m = types.ModuleType('meta_path_2_pseudo_module')
 m.__path__ = ['/some/random/dir']
 sys.modules['meta_path_2_pseudo_module'] = m
 return m
 
-import sys, new
+import sys, types
 sys.meta_path.append(ImportHook())
 try:
-exec "from meta_path_2_pseudo_module import *" in {}
+exec("from meta_path_2_pseudo_module import *", {})
 finally:
 sys.meta_path.pop()
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2015-06-03 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r77829:e1465507097e
Date: 2015-06-03 17:38 +0200
http://bitbucket.org/pypy/pypy/changeset/e1465507097e/

Log:2to3

diff --git a/pypy/module/_random/test/test_random.py 
b/pypy/module/_random/test/test_random.py
--- a/pypy/module/_random/test/test_random.py
+++ b/pypy/module/_random/test/test_random.py
@@ -49,8 +49,7 @@
 rnd.seed(1234)
 state = rnd.getstate()
 s = repr(state)
-assert len(s) == 7956
-assert s.count('L') == 625
+assert len(s) == 7331
 
 def test_seed(self):
 import _random, sys
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2015-06-03 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r77818:b75b97b522c4
Date: 2015-06-03 15:01 +0200
http://bitbucket.org/pypy/pypy/changeset/b75b97b522c4/

Log:2to3

diff --git a/pypy/module/test_lib_pypy/test_grp_extra.py 
b/pypy/module/test_lib_pypy/test_grp_extra.py
--- a/pypy/module/test_lib_pypy/test_grp_extra.py
+++ b/pypy/module/test_lib_pypy/test_grp_extra.py
@@ -20,7 +20,7 @@
 assert g.gr_gid == 0
 assert 'root' in g.gr_mem or g.gr_mem == []
 assert g.gr_name == name
-assert isinstance(g.gr_passwd, str)# usually just 'x', don't 
hope :-)
+assert isinstance(g.gr_passwd, bytes)# usually just 'x', don't 
hope :-)
 break
 else:
 raise
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2015-06-02 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r77798:9cbfdd1c8b6b
Date: 2015-06-03 01:32 +0200
http://bitbucket.org/pypy/pypy/changeset/9cbfdd1c8b6b/

Log:2to3

diff --git a/pypy/module/_cffi_backend/test/test_re_python.py 
b/pypy/module/_cffi_backend/test/test_re_python.py
--- a/pypy/module/_cffi_backend/test/test_re_python.py
+++ b/pypy/module/_cffi_backend/test/test_re_python.py
@@ -171,7 +171,7 @@
 def test_global_const_nonint(self):
 from re_python_pysrc import ffi
 lib = ffi.dlopen(self.extmod)
-assert ffi.string(lib.globalconsthello, 8) == "hello"
+assert ffi.string(lib.globalconsthello, 8) == b"hello"
 raises(AttributeError, ffi.addressof, lib, 'globalconsthello')
 
 def test_rtld_constants(self):
diff --git a/pypy/module/_cffi_backend/test/test_recompiler.py 
b/pypy/module/_cffi_backend/test/test_recompiler.py
--- a/pypy/module/_cffi_backend/test/test_recompiler.py
+++ b/pypy/module/_cffi_backend/test/test_recompiler.py
@@ -855,7 +855,7 @@
 # but we can get its address
 p = ffi.addressof(lib, 'globvar')
 assert ffi.typeof(p) == ffi.typeof('opaque_t *')
-assert ffi.string(ffi.cast("char *", p), 8) == "hello"
+assert ffi.string(ffi.cast("char *", p), 8) == b"hello"
 
 def test_constant_of_value_unknown_to_the_compiler(self):
 extra_c_source = self.udir + self.os_sep + (
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2015-06-02 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r77789:b0fb0320e5d9
Date: 2015-06-02 20:49 +0200
http://bitbucket.org/pypy/pypy/changeset/b0fb0320e5d9/

Log:2to3

diff --git a/pypy/module/micronumpy/casting.py 
b/pypy/module/micronumpy/casting.py
--- a/pypy/module/micronumpy/casting.py
+++ b/pypy/module/micronumpy/casting.py
@@ -308,8 +308,6 @@
 if space.isinstance_w(w_obj, space.w_bool):
 return bool_dtype
 elif space.isinstance_w(w_obj, space.w_int):
-return long_dtype
-elif space.isinstance_w(w_obj, space.w_long):
 try:
 space.int_w(w_obj)
 except OperationError, e:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2015-06-02 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r77784:56eddd4b5785
Date: 2015-06-02 19:03 +0200
http://bitbucket.org/pypy/pypy/changeset/56eddd4b5785/

Log:2to3

diff --git a/pypy/module/_cffi_backend/test/test_recompiler.py 
b/pypy/module/_cffi_backend/test/test_recompiler.py
--- a/pypy/module/_cffi_backend/test/test_recompiler.py
+++ b/pypy/module/_cffi_backend/test/test_recompiler.py
@@ -100,7 +100,7 @@
 del self.space._cleanup_ffi
 self.space.appexec([self._w_modules], """(old_modules):
 import sys
-for key in sys.modules.keys():
+for key in list(sys.modules.keys()):
 if key not in old_modules:
 del sys.modules[key]
 """)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2015-06-02 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r77783:a4114a083024
Date: 2015-06-02 19:03 +0200
http://bitbucket.org/pypy/pypy/changeset/a4114a083024/

Log:2to3

diff --git a/pypy/module/_cffi_backend/test/test_ffi_obj.py 
b/pypy/module/_cffi_backend/test/test_ffi_obj.py
--- a/pypy/module/_cffi_backend/test/test_ffi_obj.py
+++ b/pypy/module/_cffi_backend/test/test_ffi_obj.py
@@ -186,7 +186,7 @@
 import _cffi_backend as _cffi1_backend
 ffi = _cffi1_backend.FFI()
 a = ffi.new("signed char[]", [5, 6, 7])
-assert ffi.buffer(a)[:] == '\x05\x06\x07'
+assert ffi.buffer(a)[:] == b'\x05\x06\x07'
 
 def test_ffi_from_buffer(self):
 import _cffi_backend as _cffi1_backend
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2015-06-02 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r77780:94efbc9c28df
Date: 2015-06-02 18:06 +0200
http://bitbucket.org/pypy/pypy/changeset/94efbc9c28df/

Log:2to3

diff --git a/pypy/module/__pypy__/test/test_magic.py 
b/pypy/module/__pypy__/test/test_magic.py
--- a/pypy/module/__pypy__/test/test_magic.py
+++ b/pypy/module/__pypy__/test/test_magic.py
@@ -3,12 +3,12 @@
 spaceconfig = dict(usemodules=['__pypy__'])
 
 def test_save_module_content_for_future_reload(self):
-import sys, __pypy__
+import sys, __pypy__, imp
 d = sys.dont_write_bytecode
 sys.dont_write_bytecode = "hello world"
 __pypy__.save_module_content_for_future_reload(sys)
 sys.dont_write_bytecode = d
-reload(sys)
+imp.reload(sys)
 assert sys.dont_write_bytecode == "hello world"
 #
 sys.dont_write_bytecode = d
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2015-06-02 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r77781:a13d93cc5971
Date: 2015-06-02 18:20 +0200
http://bitbucket.org/pypy/pypy/changeset/a13d93cc5971/

Log:2to3

diff --git a/pypy/module/_cffi_backend/ffi_obj.py 
b/pypy/module/_cffi_backend/ffi_obj.py
--- a/pypy/module/_cffi_backend/ffi_obj.py
+++ b/pypy/module/_cffi_backend/ffi_obj.py
@@ -132,7 +132,7 @@
 def ffi_type(self, w_x, accept):
 space = self.space
 if (accept & ACCEPT_STRING) and (
-space.isinstance_w(w_x, space.w_basestring)):
+space.isinstance_w(w_x, space.w_unicode)):
 string = space.str_w(w_x)
 consider_fn_as_fnptr = (accept & CONSIDER_FN_AS_FNPTR) != 0
 if jit.isconstant(string):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2015-05-31 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r77731:89467232f906
Date: 2015-05-31 21:19 +0200
http://bitbucket.org/pypy/pypy/changeset/89467232f906/

Log:2to3

diff --git a/pypy/module/_vmprof/test/test__vmprof.py 
b/pypy/module/_vmprof/test/test__vmprof.py
--- a/pypy/module/_vmprof/test/test__vmprof.py
+++ b/pypy/module/_vmprof/test/test__vmprof.py
@@ -21,17 +21,17 @@
 i = 0
 count = 0
 i += 5 * WORD # header
-assert s[i] == '\x04'
+assert s[i] == 4
 i += 1 # marker
-assert s[i] == '\x04'
+assert s[i] == 4
 i += 1 # length
 i += len('pypy')
 while i < len(s):
-if s[i] == '\x03':
+if s[i] == 3:
 break
-if s[i] == '\x01':
+if s[i] == 1:
 xxx
-assert s[i] == '\x02'
+assert s[i] == 2
 i += 1
 _, size = struct.unpack("ll", s[i:i + 2 * WORD])
 count += 1
@@ -41,26 +41,26 @@
 import _vmprof
 _vmprof.enable(self.tmpfileno)
 _vmprof.disable()
-s = open(self.tmpfilename).read()
+s = open(self.tmpfilename, 'rb').read()
 no_of_codes = count(s)
 assert no_of_codes > 10
 d = {}
 
-exec """def foo():
+exec("""def foo():
 pass
-""" in d
+""", d)
 
 _vmprof.enable(self.tmpfileno2)
 
-exec """def foo2():
+exec("""def foo2():
 pass
-""" in d
+""", d)
 
 _vmprof.disable()
-s = open(self.tmpfilename2).read()
+s = open(self.tmpfilename2, 'rb').read()
 no_of_codes2 = count(s)
-assert "py:foo:" in s
-assert "py:foo2:" in s
+assert b"py:foo:" in s
+assert b"py:foo2:" in s
 assert no_of_codes2 >= no_of_codes + 2 # some extra codes from tests
 
 def test_enable_ovf(self):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2015-05-31 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r77732:8a80d24662e3
Date: 2015-05-31 21:24 +0200
http://bitbucket.org/pypy/pypy/changeset/8a80d24662e3/

Log:2to3

diff --git a/pypy/module/sys/test/test_sysmodule.py 
b/pypy/module/sys/test/test_sysmodule.py
--- a/pypy/module/sys/test/test_sysmodule.py
+++ b/pypy/module/sys/test/test_sysmodule.py
@@ -609,7 +609,7 @@
 tracer = Tracer()
 func(tracer.trace)
 sys.settrace(None)
-compare_events(func.func_code.co_firstlineno,
+compare_events(func.__code__.co_firstlineno,
tracer.events, func.events)
 
 
@@ -627,7 +627,7 @@
 def settrace_and_raise(tracefunc):
 try:
 _settrace_and_raise(tracefunc)
-except RuntimeError, exc:
+except RuntimeError as exc:
 pass
 
 settrace_and_raise.events = [(2, 'exception'),
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3: There is no space.w_long / space.w_memoryview in Py3k.

2015-05-28 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r77669:fd4c68713a10
Date: 2015-05-29 03:51 +0200
http://bitbucket.org/pypy/pypy/changeset/fd4c68713a10/

Log:2to3: There is no space.w_long / space.w_memoryview in Py3k.

diff --git a/pypy/module/cpyext/longobject.py b/pypy/module/cpyext/longobject.py
--- a/pypy/module/cpyext/longobject.py
+++ b/pypy/module/cpyext/longobject.py
@@ -195,7 +195,7 @@
 out of range, ValueError will be raised."""
 w_value = space.wrap(rffi.wcharpsize2unicode(u, length))
 w_base = space.wrap(rffi.cast(lltype.Signed, base))
-return space.call_function(space.w_long, w_value, w_base)
+return space.call_function(space.w_int, w_value, w_base)
 
 @cpython_api([rffi.VOIDP], PyObject)
 def PyLong_FromVoidPtr(space, p):
diff --git a/pypy/module/micronumpy/descriptor.py 
b/pypy/module/micronumpy/descriptor.py
--- a/pypy/module/micronumpy/descriptor.py
+++ b/pypy/module/micronumpy/descriptor.py
@@ -1031,5 +1031,4 @@
 space.isinstance_w(w_arg, space.w_int) or
 space.isinstance_w(w_arg, space.w_float) or
 space.isinstance_w(w_arg, space.w_complex) or
-space.isinstance_w(w_arg, space.w_long) or
 space.isinstance_w(w_arg, space.w_bool))
diff --git a/pypy/module/micronumpy/strides.py 
b/pypy/module/micronumpy/strides.py
--- a/pypy/module/micronumpy/strides.py
+++ b/pypy/module/micronumpy/strides.py
@@ -186,7 +186,7 @@
 
 def _find_shape_and_elems(space, w_iterable, is_rec_type):
 shape = [space.len_w(w_iterable)]
-if space.isinstance_w(w_iterable, space.w_buffer):
+if space.isinstance_w(w_iterable, space.w_memoryview):
 batch = [space.wrap(0)] * shape[0]
 for i in range(shape[0]):
 batch[i] = space.ord(space.getitem(w_iterable, space.wrap(i)))
diff --git a/pypy/module/micronumpy/support.py 
b/pypy/module/micronumpy/support.py
--- a/pypy/module/micronumpy/support.py
+++ b/pypy/module/micronumpy/support.py
@@ -8,7 +8,7 @@
 from pypy.module.micronumpy.base import W_NDimArray
 return (space.isinstance_w(w_obj, space.w_tuple) or
space.isinstance_w(w_obj, space.w_list) or
-   space.isinstance_w(w_obj, space.w_buffer) or
+   space.isinstance_w(w_obj, space.w_memoryview) or
isinstance(w_obj, W_NDimArray))
 
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2015-02-25 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r76136:66a2427025a2
Date: 2015-02-25 16:36 +0100
http://bitbucket.org/pypy/pypy/changeset/66a2427025a2/

Log:2to3

diff --git a/pypy/module/sys/test/test_sysmodule.py 
b/pypy/module/sys/test/test_sysmodule.py
--- a/pypy/module/sys/test/test_sysmodule.py
+++ b/pypy/module/sys/test/test_sysmodule.py
@@ -517,6 +517,7 @@
 
 def test_reload_doesnt_override_sys_executable(self):
 import sys
+from imp import reload
 sys.executable = 'from_test_sysmodule'
 reload(sys)
 assert sys.executable == 'from_test_sysmodule'
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2015-02-25 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r76137:8d66bee0307a
Date: 2015-02-25 16:38 +0100
http://bitbucket.org/pypy/pypy/changeset/8d66bee0307a/

Log:2to3

diff --git a/pypy/objspace/std/test/test_intobject.py 
b/pypy/objspace/std/test/test_intobject.py
--- a/pypy/objspace/std/test/test_intobject.py
+++ b/pypy/objspace/std/test/test_intobject.py
@@ -486,7 +486,7 @@
 
 def test_bit_length_max(self):
 import sys
-val = -sys.maxint-1
+val = -sys.maxsize-1
 bits = 32 if val == -2147483648 else 64
 assert val.bit_length() == bits
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2015-02-25 Thread mjacob
Author: Manuel Jacob 
Branch: py3k
Changeset: r76135:817e1b862c7c
Date: 2015-02-25 16:32 +0100
http://bitbucket.org/pypy/pypy/changeset/817e1b862c7c/

Log:2to3

diff --git a/lib_pypy/_gdbm.py b/lib_pypy/_gdbm.py
--- a/lib_pypy/_gdbm.py
+++ b/lib_pypy/_gdbm.py
@@ -72,9 +72,9 @@
 pass
 
 def _checkstr(key):
-if isinstance(key, unicode):
+if isinstance(key, str):
 key = key.encode("ascii")
-if not isinstance(key, str):
+if not isinstance(key, bytes):
 raise TypeError("gdbm mappings have string indices only")
 return key
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2014-09-11 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r73490:71b29c6796ae
Date: 2014-09-11 15:14 -0700
http://bitbucket.org/pypy/pypy/changeset/71b29c6796ae/

Log:2to3

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
@@ -1107,7 +1107,7 @@
 assert sys.executable == ''  # not executable!
 assert sys.path == old_sys_path + [self.goal_dir]
 
-os.chmod(self.fake_exe, 0755)
+os.chmod(self.fake_exe, 0o755)
 app_main.setup_bootstrap_path(self.fake_exe)
 assert sys.executable == self.fake_exe
 assert self.goal_dir not in sys.path
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2014-05-20 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r71625:eb55b133230a
Date: 2014-05-20 15:39 -0700
http://bitbucket.org/pypy/pypy/changeset/eb55b133230a/

Log:2to3

diff --git a/lib_pypy/gdbm.py b/lib_pypy/gdbm.py
--- a/lib_pypy/gdbm.py
+++ b/lib_pypy/gdbm.py
@@ -149,7 +149,7 @@
 self._check_closed()
 lib.gdbm_sync(self.ll_dbm)
 
-def open(filename, flags='r', mode=0666):
+def open(filename, flags='r', mode=0o666):
 if flags[0] == 'r':
 iflags = lib.GDBM_READER
 elif flags[0] == 'w':
diff --git a/pypy/module/fcntl/test/test_fcntl.py 
b/pypy/module/fcntl/test/test_fcntl.py
--- a/pypy/module/fcntl/test/test_fcntl.py
+++ b/pypy/module/fcntl/test/test_fcntl.py
@@ -270,7 +270,7 @@
 try:
 if termios.TIOCSWINSZ < 0:
 set_winsz_opcode_maybe_neg = termios.TIOCSWINSZ
-set_winsz_opcode_pos = termios.TIOCSWINSZ & 0xL
+set_winsz_opcode_pos = termios.TIOCSWINSZ & 0x
 else:
 set_winsz_opcode_pos = termios.TIOCSWINSZ
 set_winsz_opcode_maybe_neg, = struct.unpack("i",
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2014-05-06 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r71350:89063808e736
Date: 2014-05-06 15:24 -0700
http://bitbucket.org/pypy/pypy/changeset/89063808e736/

Log:2to3

diff --git a/pypy/module/cppyy/test/test_datatypes.py 
b/pypy/module/cppyy/test/test_datatypes.py
--- a/pypy/module/cppyy/test/test_datatypes.py
+++ b/pypy/module/cppyy/test/test_datatypes.py
@@ -158,15 +158,15 @@
 # integer types
 names = ['short', 'ushort', 'int', 'uint', 'long', 'ulong', 'llong', 
'ullong']
 for i in range(len(names)):
-exec 'c.m_%s = %d' % (names[i],i)
+exec('c.m_%s = %d' % (names[i],i))
 assert eval('c.get_%s()' % names[i]) == i
 
 for i in range(len(names)):
-exec 'c.set_%s(%d)' % (names[i],2*i)
+exec('c.set_%s(%d)' % (names[i],2*i))
 assert eval('c.m_%s' % names[i]) == 2*i
 
 for i in range(len(names)):
-exec 'c.set_%s_c(%d)' % (names[i],3*i)
+exec('c.set_%s_c(%d)' % (names[i],3*i))
 assert eval('c.m_%s' % names[i]) == 3*i
 
 # float types through functions
@@ -191,11 +191,11 @@
 atypes = ['h', 'H', 'i', 'I', 'l', 'L' ]
 for j in range(len(names)):
 b = array.array(atypes[j], a)
-exec 'c.m_%s_array = b' % names[j]   # buffer copies
+exec('c.m_%s_array = b' % names[j])   # buffer copies
 for i in range(self.N):
 assert eval('c.m_%s_array[i]' % names[j]) == b[i]
 
-exec 'c.m_%s_array2 = b' % names[j]  # pointer copies
+exec('c.m_%s_array2 = b' % names[j])  # pointer copies
 b[i] = 28
 for i in range(self.N):
 assert eval('c.m_%s_array2[i]' % names[j]) == b[i]
@@ -264,14 +264,14 @@
 assert c.s_int  == -202
 assert c.s_uint ==  202
 assert cppyy_test_data.s_uint   ==  202
-assert cppyy_test_data.s_long   == -303L
-assert c.s_long == -303L
-assert c.s_ulong==  303L
-assert cppyy_test_data.s_ulong  ==  303L
-assert cppyy_test_data.s_llong  == -404L
-assert c.s_llong== -404L
-assert c.s_ullong   ==  505L
-assert cppyy_test_data.s_ullong ==  505L
+assert cppyy_test_data.s_long   == -303
+assert c.s_long == -303
+assert c.s_ulong==  303
+assert cppyy_test_data.s_ulong  ==  303
+assert cppyy_test_data.s_llong  == -404
+assert c.s_llong== -404
+assert c.s_ullong   ==  505
+assert cppyy_test_data.s_ullong ==  505
 
 # floating point types
 assert round(cppyy_test_data.s_float  + 606., 5) == 0
@@ -321,14 +321,14 @@
 assert cppyy_test_data.s_uint   == 4321
 raises(ValueError, setattr, c,   's_uint', -1)
 raises(ValueError, setattr, cppyy_test_data, 's_uint', -1)
-cppyy_test_data.s_long   = -87L
-assert c.s_long == -87L
-c.s_long = 876L
-assert cppyy_test_data.s_long   == 876L
-cppyy_test_data.s_ulong  = 876L
-assert c.s_ulong== 876L
-c.s_ulong= 678L
-assert cppyy_test_data.s_ulong  == 678L
+cppyy_test_data.s_long   = -87
+assert c.s_long == -87
+c.s_long = 876
+assert cppyy_test_data.s_long   == 876
+cppyy_test_data.s_ulong  = 876
+assert c.s_ulong== 876
+c.s_ulong= 678
+assert cppyy_test_data.s_ulong  == 678
 raises(ValueError, setattr, cppyy_test_data, 's_ulong', -1)
 raises(ValueError, setattr, c,   's_ulong', -1)
 
diff --git a/pypy/module/cppyy/test/test_pythonify.py 
b/pypy/module/cppyy/test/test_pythonify.py
--- a/pypy/module/cppyy/test/test_pythonify.py
+++ b/pypy/module/cppyy/test/test_pythonify.py
@@ -44,8 +44,6 @@
 res = example01_class.staticAddOneToInt(1)
 assert res == 2
 
-res = example01_class.staticAddOneToInt(1L)
-assert res == 2
 res = example01_class.staticAddOneToInt(1, 2)
 assert res == 4
 res = example01_class.staticAddOneToInt(-1)
@@ -118,7 +116,7 @@
 res = instance.addToStringValue("-12")   # TODO: this leaks
 assert res == "30"
 
-res = instance.staticAddOneToInt(1L)
+res = instance.staticAddOneToInt(1)
 assert res == 2
 
 instance.destruct()
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3 the relative import

2014-04-17 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r70729:527abf1156de
Date: 2014-04-17 12:16 -0700
http://bitbucket.org/pypy/pypy/changeset/527abf1156de/

Log:2to3 the relative import

diff --git a/pypy/module/__pypy__/app_signal.py 
b/pypy/module/__pypy__/app_signal.py
--- a/pypy/module/__pypy__/app_signal.py
+++ b/pypy/module/__pypy__/app_signal.py
@@ -1,4 +1,4 @@
-import thread
+from . import thread
 # ^^ relative import of __pypy__.thread.  Note that some tests depend on
 # this (test_enable_signals in test_signal.py) to work properly,
 # otherwise they get caught in some deadlock waiting for the import
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2014-02-14 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r69144:84b7dca9f936
Date: 2014-02-14 18:17 -0800
http://bitbucket.org/pypy/pypy/changeset/84b7dca9f936/

Log:2to3

diff --git a/pypy/module/__pypy__/test/test_locals2fast.py 
b/pypy/module/__pypy__/test/test_locals2fast.py
--- a/pypy/module/__pypy__/test/test_locals2fast.py
+++ b/pypy/module/__pypy__/test/test_locals2fast.py
@@ -61,7 +61,7 @@
 def check_co_vars(a):
 frame = sys._getframe()
 def function2():
-print a
+print(a)
 assert 'a' in frame.f_code.co_cellvars
 frame = sys._getframe()
 frame.f_locals['a'] = 50
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2014-02-02 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r69055:274c5ad9d1ee
Date: 2014-02-02 21:41 -0800
http://bitbucket.org/pypy/pypy/changeset/274c5ad9d1ee/

Log:2to3

diff --git a/pypy/objspace/std/test/test_intobject.py 
b/pypy/objspace/std/test/test_intobject.py
--- a/pypy/objspace/std/test/test_intobject.py
+++ b/pypy/objspace/std/test/test_intobject.py
@@ -497,7 +497,7 @@
 import sys
 if '__pypy__' not in sys.builtin_module_names:
 skip('PyPy 2.x/CPython 3.4 only')
-for value in b'  1j ', u'  1٢٣٤j ':
+for value in b'  1j ', '  1٢٣٤j ':
 try:
 int(value)
 except ValueError as e:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2014-01-28 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r68983:ffa7cbdd7233
Date: 2014-01-28 12:48 -0800
http://bitbucket.org/pypy/pypy/changeset/ffa7cbdd7233/

Log:2to3

diff --git a/pypy/interpreter/pyparser/test/test_parsestring.py 
b/pypy/interpreter/pyparser/test/test_parsestring.py
--- a/pypy/interpreter/pyparser/test/test_parsestring.py
+++ b/pypy/interpreter/pyparser/test/test_parsestring.py
@@ -109,7 +109,7 @@
 def test_wide_unicode_in_source(self):
 if sys.maxunicode == 65535:
 py.test.skip("requires a wide-unicode host")
-self.parse_and_compare('u"\xf0\x9f\x92\x8b"',
+self.parse_and_compare('"\xf0\x9f\x92\x8b"',
unichr(0x1f48b),
encoding='utf-8')
 
diff --git a/pypy/module/__pypy__/test/test_special.py 
b/pypy/module/__pypy__/test/test_special.py
--- a/pypy/module/__pypy__/test/test_special.py
+++ b/pypy/module/__pypy__/test/test_special.py
@@ -80,9 +80,9 @@
 
 l = [1, 2, 3]
 assert list_strategy(l) == "int"
+l = [b"a", b"b", b"c"]
+assert list_strategy(l) == "bytes"
 l = ["a", "b", "c"]
-assert list_strategy(l) == "bytes"
-l = [u"a", u"b", u"c"]
 assert list_strategy(l) == "unicode"
 l = [1.1, 2.2, 3.3]
 assert list_strategy(l) == "float"
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2014-01-14 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r68674:70bdd46f5d7c
Date: 2014-01-14 15:22 -0800
http://bitbucket.org/pypy/pypy/changeset/70bdd46f5d7c/

Log:2to3

diff --git a/lib_pypy/audioop.py b/lib_pypy/audioop.py
--- a/lib_pypy/audioop.py
+++ b/lib_pypy/audioop.py
@@ -22,8 +22,8 @@
 if not (0 <= i < len(cp) / size):
 raise error("Index out of range")
 if size == 1:
-return struct.unpack_from("B", buffer(cp)[i:])[0]
+return struct.unpack_from("B", memoryview(cp)[i:])[0]
 elif size == 2:
-return struct.unpack_from("H", buffer(cp)[i * 2:])[0]
+return struct.unpack_from("H", memoryview(cp)[i * 2:])[0]
 elif size == 4:
-return struct.unpack_from("I", buffer(cp)[i * 4:])[0]
+return struct.unpack_from("I", memoryview(cp)[i * 4:])[0]
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2013-12-18 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r68484:5547c4821d09
Date: 2013-12-18 20:17 -0800
http://bitbucket.org/pypy/pypy/changeset/5547c4821d09/

Log:2to3

diff --git a/pypy/module/__builtin__/test/test_builtin.py 
b/pypy/module/__builtin__/test/test_builtin.py
--- a/pypy/module/__builtin__/test/test_builtin.py
+++ b/pypy/module/__builtin__/test/test_builtin.py
@@ -92,7 +92,7 @@
 def __int__(self):
 return 42
 exc = raises(TypeError, bin, D())
-assert "index" in exc.value.message
+assert "index" in str(exc.value)
 
 def test_oct(self):
 class Foo:
diff --git a/pypy/objspace/std/test/test_longobject.py 
b/pypy/objspace/std/test/test_longobject.py
--- a/pypy/objspace/std/test/test_longobject.py
+++ b/pypy/objspace/std/test/test_longobject.py
@@ -301,7 +301,7 @@
 
 def test_long_before_string(self):
 class A(str):
-def __long__(self):
+def __int__(self):
 return 42
 assert int(A('abc')) == 42
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2013-11-19 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r68254:422a28c0490d
Date: 2013-11-19 17:44 -0800
http://bitbucket.org/pypy/pypy/changeset/422a28c0490d/

Log:2to3

diff --git a/pypy/module/cpyext/test/test_getargs.py 
b/pypy/module/cpyext/test/test_getargs.py
--- a/pypy/module/cpyext/test/test_getargs.py
+++ b/pypy/module/cpyext/test/test_getargs.py
@@ -174,7 +174,7 @@
 if (!PyArg_ParseTuple(args, "s#", &buf, &y)) {
 return NULL;
 }
-return PyInt_FromSsize_t(y);
+return PyLong_FromSsize_t(y);
 ''')
 if sys.maxsize < 2**32:
 expected = 5
@@ -182,7 +182,7 @@
 expected = -0xfffb
 else:
 expected = 0x5
-assert charbuf('12345') == expected
+assert charbuf(b'12345') == expected
 
 def test_pyarg_parse_with_py_ssize_t(self):
 charbuf = self.import_parser(
@@ -192,6 +192,6 @@
 if (!PyArg_ParseTuple(args, "s#", &buf, &y)) {
 return NULL;
 }
-return PyInt_FromSsize_t(y);
+return PyLong_FromSsize_t(y);
 ''', PY_SSIZE_T_CLEAN=True)
-assert charbuf('12345') == 5
+assert charbuf(b'12345') == 5
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2013-10-25 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r67625:ecf25bee47a9
Date: 2013-10-25 11:53 -0700
http://bitbucket.org/pypy/pypy/changeset/ecf25bee47a9/

Log:2to3

diff --git a/pypy/module/cpyext/test/test_ndarrayobject.py 
b/pypy/module/cpyext/test/test_ndarrayobject.py
--- a/pypy/module/cpyext/test/test_ndarrayobject.py
+++ b/pypy/module/cpyext/test/test_ndarrayobject.py
@@ -267,7 +267,7 @@
 ),
 ("test_DescrFromType", "METH_O",
 """
-Signed typenum = PyInt_AsLong(args);
+Signed typenum = PyLong_AsLong(args);
 return _PyArray_DescrFromType(typenum);
 """
 ),
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2013-10-23 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r67539:6965cd292e2b
Date: 2013-10-23 13:14 -0700
http://bitbucket.org/pypy/pypy/changeset/6965cd292e2b/

Log:2to3

diff --git a/lib_pypy/numpypy/__init__.py b/lib_pypy/numpypy/__init__.py
--- a/lib_pypy/numpypy/__init__.py
+++ b/lib_pypy/numpypy/__init__.py
@@ -3,7 +3,7 @@
 from . import lib
 from .lib import *
 
-from __builtin__ import bool, int, long, float, complex, object, unicode, str
+from builtins import bool, int, int, float, complex, object, str, str
 
 from .core import round, abs, max, min
 
diff --git a/lib_pypy/numpypy/core/__init__.py 
b/lib_pypy/numpypy/core/__init__.py
--- a/lib_pypy/numpypy/core/__init__.py
+++ b/lib_pypy/numpypy/core/__init__.py
@@ -1,4 +1,4 @@
-from __future__ import division, absolute_import, print_function
+
 
 from . import multiarray
 from . import umath
diff --git a/lib_pypy/numpypy/core/_methods.py 
b/lib_pypy/numpypy/core/_methods.py
--- a/lib_pypy/numpypy/core/_methods.py
+++ b/lib_pypy/numpypy/core/_methods.py
@@ -1,9 +1,9 @@
 # Array methods which are called by the both the C-code for the method
 # and the Python code for the NumPy-namespace function
 
-import multiarray as mu
-import umath as um
-from numeric import asanyarray
+from . import multiarray as mu
+from . import umath as um
+from .numeric import asanyarray
 
 def _amax(a, axis=None, out=None, keepdims=False):
 return um.maximum.reduce(a, axis=axis,
@@ -31,7 +31,7 @@
 
 def _count_reduce_items(arr, axis):
 if axis is None:
-axis = tuple(xrange(arr.ndim))
+axis = tuple(range(arr.ndim))
 if not isinstance(axis, tuple):
 axis = (axis,)
 items = 1
diff --git a/lib_pypy/numpypy/core/arrayprint.py 
b/lib_pypy/numpypy/core/arrayprint.py
--- a/lib_pypy/numpypy/core/arrayprint.py
+++ b/lib_pypy/numpypy/core/arrayprint.py
@@ -13,10 +13,10 @@
 # and by Travis Oliphant  2005-8-22 for numpy
 
 import sys
-import numerictypes as _nt
-from umath import maximum, minimum, absolute, not_equal, isnan, isinf
+from . import numerictypes as _nt
+from .umath import maximum, minimum, absolute, not_equal, isnan, isinf
 #from multiarray import format_longfloat, datetime_as_string, datetime_data
-from fromnumeric import ravel
+from .fromnumeric import ravel
 
 
 def product(x, y): return x*y
@@ -194,7 +194,7 @@
 return d
 
 def _leading_trailing(a):
-import numeric as _nc
+from . import numeric as _nc
 if a.ndim == 1:
 if len(a) > 2*_summaryEdgeItems:
 b = _nc.concatenate((a[:_summaryEdgeItems],
@@ -258,9 +258,9 @@
   'str' : str}
 
 if formatter is not None:
-fkeys = [k for k in formatter.keys() if formatter[k] is not None]
+fkeys = [k for k in list(formatter.keys()) if formatter[k] is not None]
 if 'all' in fkeys:
-for key in formatdict.keys():
+for key in list(formatdict.keys()):
 formatdict[key] = formatter['all']
 if 'int_kind' in fkeys:
 for key in ['int']:
@@ -274,7 +274,7 @@
 if 'str_kind' in fkeys:
 for key in ['numpystr', 'str']:
 formatdict[key] = formatter['str_kind']
-for key in formatdict.keys():
+for key in list(formatdict.keys()):
 if key in fkeys:
 formatdict[key] = formatter[key]
 
@@ -322,7 +322,7 @@
 return lst
 
 def _convert_arrays(obj):
-import numeric as _nc
+from . import numeric as _nc
 newtup = []
 for k in obj:
 if isinstance(k, _nc.ndarray):
@@ -478,14 +478,14 @@
 if rank == 1:
 s = ""
 line = next_line_prefix
-for i in xrange(leading_items):
+for i in range(leading_items):
 word = format_function(a[i]) + separator
 s, line = _extendLine(s, line, word, max_line_len, 
next_line_prefix)
 
 if summary_insert1:
 s, line = _extendLine(s, line, summary_insert1, max_line_len, 
next_line_prefix)
 
-for i in xrange(trailing_items, 1, -1):
+for i in range(trailing_items, 1, -1):
 word = format_function(a[-i]) + separator
 s, line = _extendLine(s, line, word, max_line_len, 
next_line_prefix)
 
@@ -496,7 +496,7 @@
 else:
 s = '['
 sep = separator.rstrip()
-for i in xrange(leading_items):
+for i in range(leading_items):
 if i > 0:
 s += next_line_prefix
 s += _formatArray(a[i], format_function, rank-1, max_line_len,
@@ -507,7 +507,7 @@
 if summary_insert1:
 s += next_line_prefix + summary_insert1 + "\n"
 
-for i in xrange(trailing_items, 1, -1):
+for i in range(trailing_items, 1, -1):
 if leading_items or i != trailing_items:
 s += next_line_prefix
 s += _formatArray(a[-i], format_function, rank-1, max_line_len,
@@ -537,7 +537,7 @@
 pass
 
 def fillFormat(self, data):
-import numeric as 

[pypy-commit] pypy py3k: 2to3

2013-07-19 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r65498:018c042a46f0
Date: 2013-07-19 18:20 -0700
http://bitbucket.org/pypy/pypy/changeset/018c042a46f0/

Log:2to3

diff --git a/pypy/module/test_lib_pypy/test_collections.py 
b/pypy/module/test_lib_pypy/test_collections.py
--- a/pypy/module/test_lib_pypy/test_collections.py
+++ b/pypy/module/test_lib_pypy/test_collections.py
@@ -28,17 +28,17 @@
 def test_deque_iter(self):
 it = iter(self.d)
 raises(TypeError, len, it)
-assert it.next() == 0
+assert next(it) == 0
 self.d.pop()
-raises(RuntimeError, it.next)
+raises(RuntimeError, next, it)
 
 def test_deque_reversed(self):
 it = reversed(self.d)
 raises(TypeError, len, it)
-assert it.next() == self.n-1
-assert it.next() == self.n-2
+assert next(it) == self.n-1
+assert next(it) == self.n-2
 self.d.pop()
-raises(RuntimeError, it.next)
+raises(RuntimeError, next, it)
 
 def test_deque_remove(self):
 d = self.d
@@ -124,7 +124,7 @@
 
 d = collections.deque(range(100))
 d.reverse()
-assert list(d) == range(99, -1, -1)
+assert list(d) == list(range(99, -1, -1))
 
 def test_subclass_with_kwargs(self):
 collections = self.collections
@@ -194,7 +194,7 @@
 d2 = collections.defaultdict(int)
 assert d2.default_factory == int
 d2[12] = 42
-assert repr(d2) == "defaultdict(, {12: 42})"
+assert repr(d2) == "defaultdict(, {12: 42})"
 def foo(): return 43
 d3 = collections.defaultdict(foo)
 assert d3.default_factory is foo
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2013-07-19 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r65494:e552c1932247
Date: 2013-07-19 17:49 -0700
http://bitbucket.org/pypy/pypy/changeset/e552c1932247/

Log:2to3

diff --git a/pypy/module/posix/app_posix.py b/pypy/module/posix/app_posix.py
--- a/pypy/module/posix/app_posix.py
+++ b/pypy/module/posix/app_posix.py
@@ -64,8 +64,7 @@
 self.__dict__['st_ctime'] = self[9]
 
 
-class statvfs_result:
-__metaclass__ = structseqtype
+class statvfs_result(metaclass=structseqtype):
 
 name = osname + ".statvfs_result"
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2013-07-15 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r65408:dedb7f16dcd3
Date: 2013-07-11 12:38 -0700
http://bitbucket.org/pypy/pypy/changeset/dedb7f16dcd3/

Log:2to3

diff --git a/pypy/module/_locale/test/test_locale.py 
b/pypy/module/_locale/test/test_locale.py
--- a/pypy/module/_locale/test/test_locale.py
+++ b/pypy/module/_locale/test/test_locale.py
@@ -159,11 +159,11 @@
 _locale.setlocale(_locale.LC_ALL, self.language_pl)
 assert _locale.strcoll("a", "b") < 0
 assert _locale.strcoll(
-u"\N{LATIN SMALL LETTER A WITH OGONEK}",
+"\N{LATIN SMALL LETTER A WITH OGONEK}",
 "b") < 0
 
 assert _locale.strcoll(
-u"\N{LATIN SMALL LETTER C WITH ACUTE}",
+"\N{LATIN SMALL LETTER C WITH ACUTE}",
 "b") > 0
 assert _locale.strcoll("c", "b") > 0
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2013-07-09 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r65298:0035155e3f55
Date: 2013-07-08 15:51 -0700
http://bitbucket.org/pypy/pypy/changeset/0035155e3f55/

Log:2to3

diff --git a/pypy/module/_pypyjson/test/test__pypyjson.py 
b/pypy/module/_pypyjson/test/test__pypyjson.py
--- a/pypy/module/_pypyjson/test/test__pypyjson.py
+++ b/pypy/module/_pypyjson/test/test__pypyjson.py
@@ -18,7 +18,7 @@
 
 def test_raise_on_unicode(self):
 import _pypyjson
-raises(TypeError, _pypyjson.loads, u"42")
+raises(TypeError, _pypyjson.loads, "42")
 
 
 def test_decode_constants(self):
@@ -46,19 +46,19 @@
 def test_decode_string(self):
 import _pypyjson
 res = _pypyjson.loads('"hello"')
-assert res == u'hello'
-assert type(res) is unicode
+assert res == 'hello'
+assert type(res) is str
 
 def test_decode_string_utf8(self):
 import _pypyjson
-s = u'àèìòù'
+s = 'àèìòù'
 res = _pypyjson.loads('"%s"' % s.encode('utf-8'))
 assert res == s
 
 def test_skip_whitespace(self):
 import _pypyjson
 s = '   "hello"   '
-assert _pypyjson.loads(s) == u'hello'
+assert _pypyjson.loads(s) == 'hello'
 s = '   "hello"   extra'
 raises(ValueError, "_pypyjson.loads(s)")
 
@@ -69,14 +69,14 @@
 
 def test_escape_sequence(self):
 import _pypyjson
-assert _pypyjson.loads(r'"\\"') == u'\\'
-assert _pypyjson.loads(r'"\""') == u'"'
-assert _pypyjson.loads(r'"\/"') == u'/'   
-assert _pypyjson.loads(r'"\b"') == u'\b'
-assert _pypyjson.loads(r'"\f"') == u'\f'
-assert _pypyjson.loads(r'"\n"') == u'\n'
-assert _pypyjson.loads(r'"\r"') == u'\r'
-assert _pypyjson.loads(r'"\t"') == u'\t'
+assert _pypyjson.loads(r'"\\"') == '\\'
+assert _pypyjson.loads(r'"\""') == '"'
+assert _pypyjson.loads(r'"\/"') == '/'   
+assert _pypyjson.loads(r'"\b"') == '\b'
+assert _pypyjson.loads(r'"\f"') == '\f'
+assert _pypyjson.loads(r'"\n"') == '\n'
+assert _pypyjson.loads(r'"\r"') == '\r'
+assert _pypyjson.loads(r'"\t"') == '\t'
 
 def test_escape_sequence_in_the_middle(self):
 import _pypyjson
@@ -91,7 +91,7 @@
 def test_escape_sequence_unicode(self):
 import _pypyjson
 s = r'"\u1234"'
-assert _pypyjson.loads(s) == u'\u1234'
+assert _pypyjson.loads(s) == '\u1234'
 
 def test_invalid_utf_8(self):
 import _pypyjson
@@ -122,11 +122,11 @@
 check(str(1 << 32), 1 << 32)
 check(str(1 << 64), 1 << 64)
 #
-x = str(sys.maxint+1) + '.123'
+x = str(sys.maxsize+1) + '.123'
 check(x, float(x))
-x = str(sys.maxint+1) + 'E1'
+x = str(sys.maxsize+1) + 'E1'
 check(x, float(x))
-x = str(sys.maxint+1) + 'E-1'
+x = str(sys.maxsize+1) + 'E-1'
 check(x, float(x))
 #
 check('1E400', float('inf'))
@@ -181,7 +181,7 @@
 
 def test_unicode_surrogate_pair(self):
 import _pypyjson
-expected = u'z\U0001d120x'
+expected = 'z\U0001d120x'
 res = _pypyjson.loads('"z\\ud834\\udd20x"')
 assert res == expected
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2013-07-03 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r65178:5d231843e448
Date: 2013-07-03 13:14 -0700
http://bitbucket.org/pypy/pypy/changeset/5d231843e448/

Log:2to3

diff --git a/pypy/objspace/std/test/test_identityset.py 
b/pypy/objspace/std/test/test_identityset.py
--- a/pypy/objspace/std/test/test_identityset.py
+++ b/pypy/objspace/std/test/test_identityset.py
@@ -53,7 +53,7 @@
 
 assert self.uses_strategy('IdentitySetStrategy',set([X(),X()]))
 assert not self.uses_strategy('IdentitySetStrategy',set([X(),""]))
-assert not self.uses_strategy('IdentitySetStrategy',set([X(),u""]))
+assert not self.uses_strategy('IdentitySetStrategy',set([X(),""]))
 assert not self.uses_strategy('IdentitySetStrategy',set([X(),1]))
 
 def test_identity_strategy_add(self):
@@ -125,11 +125,11 @@
 assert s.intersection(set(['a','b','c'])) == set()
 assert s.intersection(set([X(),X()])) == set()
 
-other = set(['a','b','c',s.__iter__().next()])
+other = set(['a','b','c',next(s.__iter__())])
 intersect = s.intersection(other)
 assert len(intersect) == 1
-assert intersect.__iter__().next() in s
-assert intersect.__iter__().next() in other
+assert next(intersect.__iter__()) in s
+assert next(intersect.__iter__()) in other
 
 def test_class_monkey_patch(self):
 
@@ -145,7 +145,7 @@
 assert not self.uses_strategy('IdentitySetStrategy',s)
 assert not self.uses_strategy('IdentitySetStrategy',set([X(),X()]))
 assert not self.uses_strategy('IdentitySetStrategy',set([X(),""]))
-assert not self.uses_strategy('IdentitySetStrategy',set([X(),u""]))
+assert not self.uses_strategy('IdentitySetStrategy',set([X(),""]))
 assert not self.uses_strategy('IdentitySetStrategy',set([X(),1]))
 
 # An interesting case, add an instance, mutate the class,
@@ -161,7 +161,7 @@
 s.add(inst)
 
 assert len(s) == 1
-assert s.__iter__().next() is inst
+assert next(s.__iter__()) is inst
 assert not self.uses_strategy('IdentitySetStrategy',s)
 
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2013-07-01 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r65152:6be53cd7a876
Date: 2013-07-01 11:30 -0700
http://bitbucket.org/pypy/pypy/changeset/6be53cd7a876/

Log:2to3

diff --git a/lib_pypy/grp.py b/lib_pypy/grp.py
--- a/lib_pypy/grp.py
+++ b/lib_pypy/grp.py
@@ -25,8 +25,7 @@
 ('gr_mem', POINTER(c_char_p)),
 )
 
-class struct_group:
-__metaclass__ = _structseq.structseqtype
+class struct_group(metaclass=_structseq.structseqtype):
 
 gr_name   = _structseq.structseqfield(0)
 gr_passwd = _structseq.structseqfield(1)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2013-06-17 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r64930:10bf1805e3e8
Date: 2013-06-17 15:34 -0700
http://bitbucket.org/pypy/pypy/changeset/10bf1805e3e8/

Log:2to3

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
@@ -626,9 +626,10 @@
 assert 'settrace' in dir(sys)
 
 def test_reload_builtin_doesnt_clear(self):
+import imp
 import sys
 sys.foobar = "baz"
-reload(sys)
+imp.reload(sys)
 assert sys.foobar == "baz"
 
 def test_reimport_builtin_simple_case_1(self):
@@ -648,7 +649,7 @@
 
 def test_reimport_builtin(self):
 skip("fix me")
-import sys, time
+import imp, sys, time
 oldpath = sys.path
 time.tzset = ""
 
@@ -658,7 +659,7 @@
 
 assert time.tzset == ""
 
-reload(time1)   # don't leave a broken time.tzset behind
+imp.reload(time1)   # don't leave a broken time.tzset behind
 import time
 assert time.tzset != ""
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2013-05-22 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r64501:1d61aefe7ef0
Date: 2013-05-22 17:03 -0700
http://bitbucket.org/pypy/pypy/changeset/1d61aefe7ef0/

Log:2to3

diff --git a/lib-python/3/distutils/unixccompiler.py 
b/lib-python/3/distutils/unixccompiler.py
--- a/lib-python/3/distutils/unixccompiler.py
+++ b/lib-python/3/distutils/unixccompiler.py
@@ -134,7 +134,7 @@
 executables['ranlib'] = ["ranlib"]
 executables['linker_so'] += ['-undefined', 'dynamic_lookup']
 
-for k, v in executables.iteritems():
+for k, v in executables.items():
 if v and v[0] == 'cc':
 v += ['-arch', arch]
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2013-05-10 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r63971:48383cc7b1b0
Date: 2013-05-10 13:52 -0700
http://bitbucket.org/pypy/pypy/changeset/48383cc7b1b0/

Log:2to3

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
@@ -508,16 +508,16 @@
 yield 42 + i
 g = f(4)
 g2 = copy.deepcopy(g)
-res = g.next()
+res = next(g)
 assert res == 42
-res = g2.next()
+res = next(g2)
 assert res == 42
 g3 = copy.deepcopy(g)
-res = g.next()
+res = next(g)
 assert res == 43
-res = g2.next()
+res = next(g2)
 assert res == 43
-res = g3.next()
+res = next(g3)
 assert res == 43
 
 def test_shallowcopy_generator(self):
@@ -533,20 +533,20 @@
 n -= 1
 g = f(2)
 g2 = copy.copy(g)
-res = g.next()
+res = next(g)
 assert res == 44
-res = g2.next()
+res = next(g2)
 assert res == 44
 g3 = copy.copy(g)
-res = g.next()
+res = next(g)
 assert res == 43
-res = g2.next()
+res = next(g2)
 assert res == 43
-res = g3.next()
+res = next(g3)
 assert res == 43
 g4 = copy.copy(g2)
 for i in range(2):
-raises(StopIteration, g.next)
-raises(StopIteration, g2.next)
-raises(StopIteration, g3.next)
-raises(StopIteration, g4.next)
+raises(StopIteration, next, g)
+raises(StopIteration, next, g2)
+raises(StopIteration, next, g3)
+raises(StopIteration, next, g4)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2013-05-08 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r63926:28b4dbf82ddf
Date: 2013-05-08 11:11 -0700
http://bitbucket.org/pypy/pypy/changeset/28b4dbf82ddf/

Log:2to3

diff --git a/lib_pypy/ctypes_config_cache/dumpcache.py 
b/lib_pypy/ctypes_config_cache/dumpcache.py
--- a/lib_pypy/ctypes_config_cache/dumpcache.py
+++ b/lib_pypy/ctypes_config_cache/dumpcache.py
@@ -11,7 +11,7 @@
 g = open(filename, 'w')
 print >> g, '''\
 import sys
-_size = 32 if sys.maxint <= 2**32 else 64
+_size = 32 if sys.maxsize <= 2**32 else 64
 # XXX relative import, should be removed together with
 # XXX the relative imports done e.g. by lib_pypy/pypy_test/test_hashlib
 _mod = __import__("_%s_%%s_" %% (_size,),
diff --git a/pypy/module/_random/test/test_random.py 
b/pypy/module/_random/test/test_random.py
--- a/pypy/module/_random/test/test_random.py
+++ b/pypy/module/_random/test/test_random.py
@@ -46,7 +46,7 @@
 rnd = _random.Random()
 rnd.seed()
 different_nums = []
-mask = sys.maxint * 2 + 1
+mask = sys.maxsize * 2 + 1
 for obj in ["spam and eggs", 3.14, 1+2j, 'a', tuple('abc')]:
 nums = []
 for o in [obj, hash(obj) & mask, -(hash(obj) & mask)]:
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2013-05-02 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r63806:aeb541bf1ab8
Date: 2013-05-02 12:22 -0700
http://bitbucket.org/pypy/pypy/changeset/aeb541bf1ab8/

Log:2to3

diff --git a/pypy/module/__builtin__/test/test_zip.py 
b/pypy/module/__builtin__/test/test_zip.py
--- a/pypy/module/__builtin__/test/test_zip.py
+++ b/pypy/module/__builtin__/test/test_zip.py
@@ -15,9 +15,9 @@
 
 def test_two_lists(self):
 # uses a different code path
-assert zip([1, 2, 3], [3, 4, 5]) == [(1, 3), (2, 4), (3, 5)]
-assert zip([1, 2, 3], [3, 4]) == [(1, 3), (2, 4)]
-assert zip([1, 2], [3, 4, 5]) == [(1, 3), (2, 4)]
+assert list(zip([1, 2, 3], [3, 4, 5])) == [(1, 3), (2, 4), (3, 5)]
+assert list(zip([1, 2, 3], [3, 4])) == [(1, 3), (2, 4)]
+assert list(zip([1, 2], [3, 4, 5])) == [(1, 3), (2, 4)]
 
 def test_three_lists_same_size(self):
 assert list(zip([1, 2, 3], [3, 4, 5], [6, 7, 8])) == (
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2013-04-24 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r63599:ef1505d5cddd
Date: 2013-04-24 10:49 -0700
http://bitbucket.org/pypy/pypy/changeset/ef1505d5cddd/

Log:2to3

diff --git a/pypy/module/_multiprocessing/test/test_win32.py 
b/pypy/module/_multiprocessing/test/test_win32.py
--- a/pypy/module/_multiprocessing/test/test_win32.py
+++ b/pypy/module/_multiprocessing/test/test_win32.py
@@ -39,7 +39,7 @@
 
 try:
 win32.ConnectNamedPipe(readhandle, win32.NULL)
-except WindowsError, e:
+except WindowsError as e:
 if e.args[0] != win32.ERROR_PIPE_CONNECTED:
 raise
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2013-04-18 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r63487:dcc0b43bd43a
Date: 2013-04-18 13:36 -0700
http://bitbucket.org/pypy/pypy/changeset/dcc0b43bd43a/

Log:2to3

diff --git a/pypy/module/_winreg/test/test_winreg.py 
b/pypy/module/_winreg/test/test_winreg.py
--- a/pypy/module/_winreg/test/test_winreg.py
+++ b/pypy/module/_winreg/test/test_winreg.py
@@ -22,8 +22,8 @@
 spaceconfig = dict(usemodules=('_winreg',))
 
 def test_repr(self):
-import _winreg
-k = _winreg.HKEYType(0x123)
+import winreg
+k = winreg.HKEYType(0x123)
 assert str(k) == ""
 
 class AppTestFfi:
@@ -60,19 +60,19 @@
 pass
 
 def test_constants(self):
-from _winreg import (
+from winreg import (
 HKEY_LOCAL_MACHINE, HKEY_CLASSES_ROOT, HKEY_CURRENT_CONFIG,
 HKEY_CURRENT_USER, HKEY_DYN_DATA, HKEY_LOCAL_MACHINE,
 HKEY_PERFORMANCE_DATA, HKEY_USERS)
 
 def test_simple_write(self):
-from _winreg import SetValue, QueryValue, REG_SZ
+from winreg import SetValue, QueryValue, REG_SZ
 value = "Some Default value"
 SetValue(self.root_key, self.test_key_name, REG_SZ, value)
 assert QueryValue(self.root_key, self.test_key_name) == value
 
 def test_CreateKey(self):
-from _winreg import CreateKey, QueryInfoKey
+from winreg import CreateKey, QueryInfoKey
 key = CreateKey(self.root_key, self.test_key_name)
 sub_key = CreateKey(key, "sub_key")
 
@@ -83,8 +83,8 @@
 assert nkeys == 0
 
 def test_CreateKeyEx(self):
-from _winreg import CreateKeyEx, QueryInfoKey
-from _winreg import KEY_ALL_ACCESS, KEY_READ
+from winreg import CreateKeyEx, QueryInfoKey
+from winreg import KEY_ALL_ACCESS, KEY_READ
 key = CreateKeyEx(self.root_key, self.test_key_name, 0, KEY_ALL_ACCESS)
 sub_key = CreateKeyEx(key, "sub_key", 0, KEY_READ)
 
@@ -95,7 +95,7 @@
 assert nkeys == 0
 
 def test_close(self):
-from _winreg import OpenKey, CloseKey, FlushKey, QueryInfoKey
+from winreg import OpenKey, CloseKey, FlushKey, QueryInfoKey
 key = OpenKey(self.root_key, self.test_key_name)
 sub_key = OpenKey(key, "sub_key")
 
@@ -117,7 +117,7 @@
 raises(EnvironmentError, QueryInfoKey, int_key) # now closed
 
 def test_with(self):
-from _winreg import OpenKey
+from winreg import OpenKey
 with OpenKey(self.root_key, self.test_key_name) as key:
 with OpenKey(key, "sub_key") as sub_key:
 assert key.handle != 0
@@ -126,11 +126,11 @@
 assert sub_key.handle == 0
 
 def test_exception(self):
-from _winreg import QueryInfoKey
+from winreg import QueryInfoKey
 import errno
 try:
 QueryInfoKey(0)
-except EnvironmentError, e:
+except EnvironmentError as e:
 assert e.winerror == 6
 assert e.errno == errno.EBADF
 # XXX translations...
@@ -140,21 +140,21 @@
 assert 0, "Did not raise"
 
 def test_SetValueEx(self):
-from _winreg import CreateKey, SetValueEx
+from winreg import CreateKey, SetValueEx
 key = CreateKey(self.root_key, self.test_key_name)
 sub_key = CreateKey(key, "sub_key")
 for name, value, type in self.test_data:
 SetValueEx(sub_key, name, 0, type, value)
 
 def test_readValues(self):
-from _winreg import OpenKey, EnumValue, QueryValueEx, EnumKey
+from winreg import OpenKey, EnumValue, QueryValueEx, EnumKey
 key = OpenKey(self.root_key, self.test_key_name)
 sub_key = OpenKey(key, "sub_key")
 index = 0
 while 1:
 try:
 data = EnumValue(sub_key, index)
-except EnvironmentError, e:
+except EnvironmentError as e:
 break
 assert data in self.test_data
 index = index + 1
@@ -167,7 +167,7 @@
 raises(EnvironmentError, EnumKey, key, 1)
 
 def test_delete(self):
-from _winreg import OpenKey, KEY_ALL_ACCESS, DeleteValue, DeleteKey
+from winreg import OpenKey, KEY_ALL_ACCESS, DeleteValue, DeleteKey
 key = OpenKey(self.root_key, self.test_key_name, 0, KEY_ALL_ACCESS)
 sub_key = OpenKey(key, "sub_key", 0, KEY_ALL_ACCESS)
 
@@ -177,14 +177,14 @@
 DeleteKey(key, "sub_key")
 
 def test_connect(self):
-from _winreg import ConnectRegistry, HKEY_LOCAL_MACHINE
+from winreg import ConnectRegistry, HKEY_LOCAL_MACHINE
 h = ConnectRegistry(None, HKEY_LOCAL_MACHINE)
 h.Close()
 
 def test_savekey(self):
 if not self.canSaveKey:
 skip("CPython needs win32api to set the SeBackupPrivilege security 
privilege")
-from _winreg import OpenKey, KEY_ALL_ACCESS, SaveKey
+from winreg import OpenKey, KEY_ALL_ACCESS, SaveKey
 import o

[pypy-commit] pypy py3k: 2to3

2013-03-30 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r62898:978d0f19e56e
Date: 2013-03-30 12:29 -0700
http://bitbucket.org/pypy/pypy/changeset/978d0f19e56e/

Log:2to3

diff --git a/pypy/objspace/std/test/test_listobject.py 
b/pypy/objspace/std/test/test_listobject.py
--- a/pypy/objspace/std/test/test_listobject.py
+++ b/pypy/objspace/std/test/test_listobject.py
@@ -1172,10 +1172,10 @@
 # strategies, to avoid surprizes depending on the strategy.
 class X: pass
 for base, arg in [
-(list, []), (list, [5]), (list, ['x']), (list, [X]), (list, 
[u'x']),
-(set, []),  (set,  [5]), (set,  ['x']), (set, [X]), (set, 
[u'x']),
+(list, []), (list, [5]), (list, ['x']), (list, [X]), (list, 
['x']),
+(set, []),  (set,  [5]), (set,  ['x']), (set, [X]), (set, 
['x']),
 (dict, []), (dict, [(5,6)]), (dict, [('x',7)]), (dict, 
[(X,8)]),
-(dict, [(u'x', 7)]),
+(dict, [('x', 7)]),
 ]:
 print(base, arg)
 class SubClass(base):
@@ -1258,17 +1258,17 @@
 assert len(l1) == 0
 
 def test_use_method_for_wrong_object(self):
-raises(TypeError, list.append.im_func, 1, 2)
+raises(TypeError, list.append, 1, 2)
 
 
 def test_issue1266(self):
-l = range(1)
+l = list(range(1))
 l.pop()
 # would previously crash
 l.append(1)
 assert l == [1]
 
-l = range(1)
+l = list(range(1))
 l.pop()
 # would previously crash
 l.reverse()
@@ -1277,17 +1277,17 @@
 def test_issue1266_ovf(self):
 import sys
 
-l = range(0, sys.maxint, sys.maxint)
-l.append(sys.maxint)
+l = list(range(0, sys.maxsize, sys.maxsize))
+l.append(sys.maxsize)
 # -2 would be next in the range sequence if overflow were
 # allowed
 l.append(-2)
-assert l == [0, sys.maxint, -2]
+assert l == [0, sys.maxsize, -2]
 assert -2 in l
 
-l = range(-sys.maxint, sys.maxint, sys.maxint // 10)
+l = list(range(-sys.maxsize, sys.maxsize, sys.maxsize // 10))
 item11 = l[11]
-assert l[::11] == [-sys.maxint, item11]
+assert l[::11] == [-sys.maxsize, item11]
 assert item11 in l[::11]
 
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2013-02-25 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r61769:da202b86b4e7
Date: 2013-02-25 11:08 -0800
http://bitbucket.org/pypy/pypy/changeset/da202b86b4e7/

Log:2to3

diff --git a/pypy/module/unicodedata/test/test_unicodedata.py 
b/pypy/module/unicodedata/test/test_unicodedata.py
--- a/pypy/module/unicodedata/test/test_unicodedata.py
+++ b/pypy/module/unicodedata/test/test_unicodedata.py
@@ -85,7 +85,7 @@
 @py.test.mark.skipif("sys.maxunicode < 0x10")
 def test_normalize_wide(self):
 import unicodedata
-assert unicodedata.normalize('NFC', '\U000110a5\U000110ba') == 
u'\U000110ab'
+assert unicodedata.normalize('NFC', '\U000110a5\U000110ba') == 
'\U000110ab'
 
 def test_linebreaks(self):
 linebreaks = (0x0a, 0x0b, 0x0c, 0x0d, 0x85,
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2013-02-22 Thread Manuel Jacob
Author: Manuel Jacob
Branch: py3k
Changeset: r61596:e198fe7b0d06
Date: 2013-02-22 12:12 +0100
http://bitbucket.org/pypy/pypy/changeset/e198fe7b0d06/

Log:2to3

diff --git a/pypy/interpreter/test/test_executioncontext.py 
b/pypy/interpreter/test/test_executioncontext.py
--- a/pypy/interpreter/test/test_executioncontext.py
+++ b/pypy/interpreter/test/test_executioncontext.py
@@ -269,7 +269,7 @@
 import gc
 class X(object):
 def __del__(self):
-print "Called", self.num
+print("Called", self.num)
 def f():
 x1 = X(); x1.num = 1
 x2 = X(); x2.num = 2
@@ -285,7 +285,7 @@
 # test the behavior fixed in r71420: before, only one __del__
 # would be called
 import os, sys
-print sys.executable, self.tmpfile
+print(sys.executable, self.tmpfile)
 if sys.platform == "win32":
 cmdformat = '"%s" "%s"'
 else:
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2013-02-19 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r61468:5c54a69052f7
Date: 2013-02-19 13:16 -0800
http://bitbucket.org/pypy/pypy/changeset/5c54a69052f7/

Log:2to3

diff --git a/pypy/module/__pypy__/test/test_signal.py 
b/pypy/module/__pypy__/test/test_signal.py
--- a/pypy/module/__pypy__/test/test_signal.py
+++ b/pypy/module/__pypy__/test/test_signal.py
@@ -17,10 +17,10 @@
 spaceconfig = dict(usemodules=['__pypy__', 'thread', 'signal', 'time'])
 
 def test_exit_twice(self):
-import __pypy__, thread
+import __pypy__, _thread
 __pypy__.thread._signals_exit()
 try:
-raises(thread.error, __pypy__.thread._signals_exit)
+raises(_thread.error, __pypy__.thread._signals_exit)
 finally:
 __pypy__.thread._signals_enter()
 
@@ -60,7 +60,7 @@
 
 def test_thread_fork_signals(self):
 import __pypy__
-import os, thread, signal
+import os, _thread, signal
 
 if not hasattr(os, 'fork'):
 skip("No fork on this platform")
@@ -72,7 +72,7 @@
 def threadfunction():
 pid = fork()
 if pid == 0:
-print 'in child'
+print('in child')
 # signal() only works from the 'main' thread
 signal.signal(signal.SIGUSR1, signal.SIG_IGN)
 os._exit(42)
@@ -82,7 +82,7 @@
 feedback.append(exitcode)
 
 feedback = []
-thread.start_new_thread(threadfunction, ())
+_thread.start_new_thread(threadfunction, ())
 self.waitfor(lambda: feedback)
 # if 0, an (unraisable) exception was raised from the forked thread.
 # if 9, process was killed by timer.
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2013-02-18 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r61436:77234913b6d6
Date: 2013-02-18 18:34 -0800
http://bitbucket.org/pypy/pypy/changeset/77234913b6d6/

Log:2to3

diff --git a/pypy/objspace/std/test/test_obj.py 
b/pypy/objspace/std/test/test_obj.py
--- a/pypy/objspace/std/test/test_obj.py
+++ b/pypy/objspace/std/test/test_obj.py
@@ -32,7 +32,7 @@
 skip("on CPython >= 2.7, id != hash")
 import sys
 o = object()
-assert (hash(o) & sys.maxint) == (id(o) & sys.maxint)
+assert (hash(o) & sys.maxsize) == (id(o) & sys.maxsize)
 
 def test_hash_method(self):
 o = object()
@@ -52,7 +52,7 @@
 pass
 x = X()
 if self.cpython_behavior and self.cpython_version < (2, 7):
-assert (hash(x) & sys.maxint) == (id(x) & sys.maxint)
+assert (hash(x) & sys.maxsize) == (id(x) & sys.maxsize)
 assert hash(x) == object.__hash__(x)
 
 def test_reduce_recursion_bug(self):
@@ -189,8 +189,8 @@
 for i in range(10):
 l.append(float(i))
 l.append(i + 0.1)
-l.append(i + sys.maxint)
-l.append(i - sys.maxint)
+l.append(i + sys.maxsize)
+l.append(i - sys.maxsize)
 l.append(i + 1j)
 l.append(1 + i * 1j)
 s = str(i)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2013-02-17 Thread Manuel Jacob
Author: Manuel Jacob
Branch: py3k
Changeset: r61373:4da3c416a10c
Date: 2013-02-17 14:46 +0100
http://bitbucket.org/pypy/pypy/changeset/4da3c416a10c/

Log:2to3

diff --git a/pypy/module/_rawffi/test/test__rawffi.py 
b/pypy/module/_rawffi/test/test__rawffi.py
--- a/pypy/module/_rawffi/test/test__rawffi.py
+++ b/pypy/module/_rawffi/test/test__rawffi.py
@@ -260,7 +260,6 @@
 assert lib.ptr(1, [], 'i')()[0] == 42
 
 def test_getchar(self):
-py3k_skip('bytes vs unicode')
 import _rawffi
 lib = _rawffi.CDLL(self.lib_name)
 get_char = lib.ptr('get_char', ['P', 'H'], 'c')
@@ -272,7 +271,7 @@
 intptr = B(1)
 intptr[0] = i
 res = get_char(dupaptr, intptr)
-assert res[0] == 'dupa'[i:i+1]
+assert res[0] == b'dupa'[i:i+1]
 intptr.free()
 dupaptr.free()
 dupa.free()
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2013-02-17 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r61354:4fd8ae7b9746
Date: 2013-02-17 11:23 -0800
http://bitbucket.org/pypy/pypy/changeset/4fd8ae7b9746/

Log:2to3

diff --git a/pypy/module/__pypy__/test/test_signal.py 
b/pypy/module/__pypy__/test/test_signal.py
--- a/pypy/module/__pypy__/test/test_signal.py
+++ b/pypy/module/__pypy__/test/test_signal.py
@@ -22,7 +22,7 @@
 with __pypy__.thread.signals_enabled:
 thread.interrupt_main()
 for i in range(10):
-print 'x'
+print('x')
 time.sleep(0.1)
 except BaseException, e:
 interrupted.append(e)
@@ -40,7 +40,7 @@
 thread.start_new_thread(subthread, ())
 for i in range(10):
 if len(done): break
-print '.'
+print('.')
 time.sleep(0.1)
 assert len(done) == 1
 assert len(interrupted) == 1
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3, fix fix fix

2013-02-16 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r61335:2664c3cf8d21
Date: 2013-02-16 13:17 -0800
http://bitbucket.org/pypy/pypy/changeset/2664c3cf8d21/

Log:2to3, fix fix fix

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
@@ -689,7 +689,7 @@
 executable = sys.pypy_find_executable(executable)
 stdlib_path = sys.pypy_find_stdlib(executable)
 if stdlib_path is None:
-print >> sys.stderr, STDLIB_WARNING
+print(STDLIB_WARNING, file=sys.stderr)
 else:
 sys.path[:] = stdlib_path
 # from this point on, we are free to use all the unicode stuff we want,
diff --git a/pypy/interpreter/test2/test_app_main.py 
b/pypy/interpreter/test2/test_app_main.py
--- a/pypy/interpreter/test2/test_app_main.py
+++ b/pypy/interpreter/test2/test_app_main.py
@@ -187,7 +187,6 @@
 def test_sysflags(self):
 flags = (
 ("debug", "-d", "1"),
-("py3k_warning", "-3", "1"),
 ("division_warning", "-Qwarn", "1"),
 ("division_warning", "-Qwarnall", "2"),
 ("division_new", "-Qnew", "1"),
@@ -215,9 +214,9 @@
run_command='pass', **expected)
 
 def test_sysflags_envvar(self, monkeypatch):
-monkeypatch.setenv('PYTHONNOUSERSITE', '1')
 expected = {"no_user_site": True}
-self.check(['-c', 'pass'], {}, sys_argv=['-c'], run_command='pass', 
**expected)
+self.check(['-c', 'pass'], {'PYTHONNOUSERSITE': '1'}, sys_argv=['-c'],
+   run_command='pass', **expected)
 
 
 class TestInteraction:
@@ -251,10 +250,10 @@
 child.logfile = sys.stdout
 return child
 
-def spawn(self, argv):
+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)
+return self._spawn(python3, [app_main] + argv, env=env)
 
 def test_interactive(self):
 child = self.spawn([])
@@ -362,6 +361,7 @@
 child.expect(re.escape(repr('NameError')))
 
 def test_atexit(self):
+skip("Python3 atexit is a builtin module")
 child = self.spawn([])
 child.expect('>>> ')
 child.sendline('def f(): print("foobye")')
@@ -399,7 +399,7 @@
 child.expect('Traceback')
 child.expect('NameError')
 
-def test_pythonstartup_file1(self, monkeypatch):
+def test_pythonstartup_file1(self, monkeypatch, demo_script):
 monkeypatch.setenv('PYTHONPATH', None)
 monkeypatch.setenv('PYTHONSTARTUP', demo_script)
 child = self.spawn([])
@@ -413,7 +413,7 @@
 child.expect('Traceback')
 child.expect('NameError')
 
-def test_pythonstartup_file2(self, monkeypatch):
+def test_pythonstartup_file2(self, monkeypatch, crashing_demo_script):
 monkeypatch.setenv('PYTHONPATH', None)
 monkeypatch.setenv('PYTHONSTARTUP', crashing_demo_script)
 child = self.spawn([])
@@ -447,8 +447,8 @@
 def test_python_path_keeps_duplicates(self):
 old = os.environ.get('PYTHONPATH', '')
 try:
-os.environ['PYTHONPATH'] = 'foobarbaz:foobarbaz'
-child = self.spawn(['-c', 'import sys; print sys.path'])
+child = self.spawn(['-c', 'import sys; print(sys.path)'],
+   env={'PYTHONPATH': 'foobarbaz:foobarbaz'})
 child.expect(r"\['', 'foobarbaz', 'foobarbaz', ")
 finally:
 os.environ['PYTHONPATH'] = old
@@ -457,7 +457,7 @@
 old = os.environ.get('PYTHONPATH', '')
 try:
 os.environ['PYTHONPATH'] = 'foobarbaz'
-child = self.spawn(['-E', '-c', 'import sys; print sys.path'])
+child = self.spawn(['-E', '-c', 'import sys; print(sys.path)'])
 from pexpect import EOF
 index = child.expect(['foobarbaz', EOF])
 assert index == 1  # no foobarbaz
@@ -742,10 +742,11 @@
 print 'POPEN:', cmdline
 child_in, child_out_err = os.popen4(cmdline)
 data = child_out_err.read(11)
-assert data == '\x00[STDERR]\n\x00'# from stderr
+# Py3 is always at least line buffered
+assert data == '\x00(STDOUT)\n\x00'# from stdout
 child_in.close()
 data = child_out_err.read(11)
-assert data == '\x00(STDOUT)\n\x00'# from stdout
+assert data == '\x00[STDERR]\n\x00'# from stderr
 child_out_err.close()
 
 def test_non_interactive_stdout_unbuffered(self, monkeypatch):
@@ -758,7 +759,7 @@
 time.sleep(1)
 # stdout flushed automatically here
 """)
-cmdline = '%s -E "%s" %s' % (sys.executable, app_main, path)
+cmdline = '%s -E "%s" %s' % (python3, app_main, path)
 print 'POPEN:', cmdline
 child_in, child_out_err = os.popen4(cmdline)

[pypy-commit] pypy py3k: 2to3

2013-02-15 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r61298:402939c23428
Date: 2013-02-15 16:52 -0800
http://bitbucket.org/pypy/pypy/changeset/402939c23428/

Log:2to3

diff --git a/pypy/module/fcntl/test/test_fcntl.py 
b/pypy/module/fcntl/test/test_fcntl.py
--- a/pypy/module/fcntl/test/test_fcntl.py
+++ b/pypy/module/fcntl/test/test_fcntl.py
@@ -32,13 +32,13 @@
 
 fcntl.fcntl(f, 1, 0)
 fcntl.fcntl(f, 1)
-fcntl.fcntl(F(long(f.fileno())), 1)
+fcntl.fcntl(F(int(f.fileno())), 1)
 raises(TypeError, fcntl.fcntl, "foo")
 raises(TypeError, fcntl.fcntl, f, "foo")
 raises(TypeError, fcntl.fcntl, F("foo"), 1)
 raises(ValueError, fcntl.fcntl, -1, 1, 0)
 raises(ValueError, fcntl.fcntl, F(-1), 1, 0)
-raises(ValueError, fcntl.fcntl, F(long(-1)), 1, 0)
+raises(ValueError, fcntl.fcntl, F(int(-1)), 1, 0)
 assert fcntl.fcntl(f, 1, 0) == 0
 assert fcntl.fcntl(f, 2, "foo") == b"foo"
 assert fcntl.fcntl(f, 2, memoryview(b"foo")) == b"foo"
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2013-02-15 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r61293:186e137b1c19
Date: 2013-02-15 16:21 -0800
http://bitbucket.org/pypy/pypy/changeset/186e137b1c19/

Log:2to3

diff --git a/pypy/module/_io/test/test_bufferedio.py 
b/pypy/module/_io/test/test_bufferedio.py
--- a/pypy/module/_io/test/test_bufferedio.py
+++ b/pypy/module/_io/test/test_bufferedio.py
@@ -563,9 +563,9 @@
 import _io
 raw = _io.FileIO(self.tmpfile, 'wb+')
 f = _io.BufferedRandom(raw)
-f.write('abc')
+f.write(b'abc')
 f.seek(0)
-assert f.read() == 'abc'
+assert f.read() == b'abc'
 
 def test_write_rewind_write(self):
 # Various combinations of reading / writing / seeking
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3, fix popen tests, reapply our darwin fix

2012-12-07 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r59368:b27d0ede020e
Date: 2012-12-07 17:02 -0800
http://bitbucket.org/pypy/pypy/changeset/b27d0ede020e/

Log:2to3, fix popen tests, reapply our darwin fix

diff --git a/pypy/module/posix/test/test_posix2.py 
b/pypy/module/posix/test/test_posix2.py
--- a/pypy/module/posix/test/test_posix2.py
+++ b/pypy/module/posix/test/test_posix2.py
@@ -13,11 +13,11 @@
 import signal
 
 def setup_module(mod):
-usemodules = ['binascii', 'posix', 'struct', 'rctime']
+usemodules = ['binascii', 'posix', 'signal', 'struct', 'rctime']
+# py3k os.open uses subprocess, requiring the following per platform
 if os.name != 'nt':
-usemodules += ['fcntl']
+usemodules += ['fcntl', 'select']
 else:
-# On windows, os.popen uses the subprocess module
 usemodules += ['_rawffi', 'thread']
 mod.space = gettestobjspace(usemodules=usemodules)
 mod.path = udir.join('posixtestfile.txt')
@@ -25,7 +25,7 @@
 mod.path2 = udir.join('test_posix2-')
 pdir = udir.ensure('posixtestdir', dir=True)
 pdir.join('file1').write("test1")
-os.chmod(str(pdir.join('file1')), 0600)
+os.chmod(str(pdir.join('file1')), 0o600)
 pdir.join('file2').write("test2")
 pdir.join('another_longer_file_name').write("test3")
 mod.pdir = pdir
@@ -300,7 +300,8 @@
 result = posix.listdir(bytes_dir)
 assert all(type(x) is bytes for x in result)
 assert b'somefile' in result
-assert b'caf\xe9' in result
+expected = b'caf%E9' if sys.platform == 'darwin' else b'caf\xe9'
+assert expected in result
 
 def test_undecodable_filename(self):
 posix = self.posix
@@ -801,21 +802,21 @@
 def test_chmod(self):
 os = self.posix
 os.unlink(self.path)
-raises(OSError, os.chmod, self.path, 0600)
+raises(OSError, os.chmod, self.path, 0o600)
 f = open(self.path, "w")
 f.write("this is a test")
 f.close()
-os.chmod(self.path, 0200)
-assert (os.stat(self.path).st_mode & 0777) == 0200
+os.chmod(self.path, 0o200)
+assert (os.stat(self.path).st_mode & 0o777) == 0o200
 
 if hasattr(os, 'fchmod'):
 def test_fchmod(self):
 os = self.posix
 f = open(self.path, "w")
-os.fchmod(f.fileno(), 0200)
-assert (os.fstat(f.fileno()).st_mode & 0777) == 0200
+os.fchmod(f.fileno(), 0o200)
+assert (os.fstat(f.fileno()).st_mode & 0o777) == 0o200
 f.close()
-assert (os.stat(self.path).st_mode & 0777) == 0200
+assert (os.stat(self.path).st_mode & 0o777) == 0o200
 
 if hasattr(os, 'mkfifo'):
 def test_mkfifo(self):
@@ -876,11 +877,11 @@
 if hasattr(os, 'symlink'):
 def test_symlink(self):
 posix = self.posix
-unicode_dir = self.unicode_dir
-if unicode_dir is None:
+bytes_dir = self.bytes_dir
+if bytes_dir is None:
 skip("encoding not good enough")
-dest = "%s/file.txt" % unicode_dir
-posix.symlink("%s/somefile" % unicode_dir, dest)
+dest = bytes_dir + b"%s/file.txt"
+posix.symlink(bytes_dir + b"%s/somefile", dest)
 with open(dest) as f:
 data = f.read()
 assert data == "who cares?"
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2012-11-19 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r59015:19a423e4d4f2
Date: 2012-11-19 21:00 -0800
http://bitbucket.org/pypy/pypy/changeset/19a423e4d4f2/

Log:2to3

diff --git a/lib-python/3.2/distutils/sysconfig_pypy.py 
b/lib-python/3.2/distutils/sysconfig_pypy.py
--- a/lib-python/3.2/distutils/sysconfig_pypy.py
+++ b/lib-python/3.2/distutils/sysconfig_pypy.py
@@ -123,6 +123,6 @@
 compiler.linker_so.append(cflags)
 
 
-from sysconfig_cpython import (
+from .sysconfig_cpython import (
 parse_makefile, _variable_rx, expand_makefile_vars)
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3 most of lib_pypy except _ctypes/numpypy/pyrepl

2012-10-24 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r58403:c1aa74c06e86
Date: 2012-10-24 13:55 -0700
http://bitbucket.org/pypy/pypy/changeset/c1aa74c06e86/

Log:2to3 most of lib_pypy except _ctypes/numpypy/pyrepl

diff --git a/lib_pypy/__init__.py b/lib_pypy/__init__.py
--- a/lib_pypy/__init__.py
+++ b/lib_pypy/__init__.py
@@ -1,4 +1,4 @@
 # This __init__.py shows up in PyPy's app-level standard library.
 # Let's try to prevent that confusion...
 if __name__ != 'lib_pypy':
-raise ImportError, '__init__'
+raise ImportError('__init__')
diff --git a/lib_pypy/_collections.py b/lib_pypy/_collections.py
--- a/lib_pypy/_collections.py
+++ b/lib_pypy/_collections.py
@@ -7,7 +7,7 @@
 
 import operator
 try:
-from thread import get_ident as _thread_ident
+from _thread import get_ident as _thread_ident
 except ImportError:
 def _thread_ident():
 return -1
@@ -369,7 +369,7 @@
 self._gen = itergen(deq.state, giveup)
 
 def __next__(self):
-res =  self._gen.next()
+res = next(self._gen)
 self.counter -= 1
 return res
 
@@ -423,5 +423,5 @@
 
This API is used by pickle.py and copy.py.
 """
-return (type(self), (self.default_factory,), None, None, 
self.iteritems())
+return (type(self), (self.default_factory,), None, None, 
iter(self.items()))
 
diff --git a/lib_pypy/_csv.py b/lib_pypy/_csv.py
--- a/lib_pypy/_csv.py
+++ b/lib_pypy/_csv.py
@@ -82,12 +82,12 @@
 (name,))
 
 if dialect is not None:
-if isinstance(dialect, basestring):
+if isinstance(dialect, str):
 dialect = get_dialect(dialect)
 
 # Can we reuse this instance?
 if (isinstance(dialect, Dialect)
-and all(value is None for value in kwargs.itervalues())):
+and all(value is None for value in kwargs.values())):
 return dialect
 
 self = object.__new__(cls)
@@ -167,7 +167,7 @@
 def register_dialect(name, dialect=None, **kwargs):
 """Create a mapping from a string name to a dialect class.
 dialect = csv.register_dialect(name, dialect)"""
-if not isinstance(name, basestring):
+if not isinstance(name, str):
 raise TypeError("dialect name must be a string or unicode")
 
 dialect = _call_dialect(dialect, kwargs)
@@ -221,11 +221,11 @@
 def __iter__(self):
 return self
 
-def next(self):
+def __next__(self):
 self._parse_reset()
 while True:
 try:
-line = self.input_iter.next()
+line = next(self.input_iter)
 except StopIteration:
 # End of input OR exception
 if len(self.field) > 0:
@@ -565,7 +565,7 @@
 old_limit = _field_limit
 
 if limit is not undefined:
-if not isinstance(limit, (int, long)):
+if not isinstance(limit, int):
 raise TypeError("int expected, got %s" %
 (limit.__class__.__name__,))
 _field_limit = limit
diff --git a/lib_pypy/_marshal.py b/lib_pypy/_marshal.py
--- a/lib_pypy/_marshal.py
+++ b/lib_pypy/_marshal.py
@@ -5,6 +5,7 @@
 
 import types
 from _codecs import utf_8_decode, utf_8_encode
+import sys
 
 try: from __pypy__ import builtinify
 except ImportError: builtinify = lambda f: f
@@ -49,7 +50,7 @@
 if func:
 break
 else:
-raise ValueError, "unmarshallable object"
+raise ValueError("unmarshallable object")
 func(self, x)
 
 def w_long64(self, x):
@@ -72,7 +73,7 @@
 
 def dump_none(self, x):
 self._write(TYPE_NONE)
-dispatch[types.NoneType] = dump_none
+dispatch[type(None)] = dump_none
 
 def dump_bool(self, x):
 if x:
@@ -83,7 +84,7 @@
 
 def dump_stopiter(self, x):
 if x is not StopIteration:
-raise ValueError, "unmarshallable object"
+raise ValueError("unmarshallable object")
 self._write(TYPE_STOPITER)
 dispatch[type(StopIteration)] = dump_stopiter
 
@@ -91,7 +92,7 @@
 self._write(TYPE_ELLIPSIS)
 
 try:
-dispatch[types.EllipsisType] = dump_ellipsis
+dispatch[type(Ellipsis)] = dump_ellipsis
 except NameError:
 pass
 
@@ -103,7 +104,7 @@
 else:
 self._write(TYPE_INT)
 self.w_long(x)
-dispatch[types.IntType] = dump_int
+dispatch[int] = dump_int
 
 def dump_long(self, x):
 self._write(TYPE_LONG)
@@ -118,27 +119,27 @@
 self.w_long(len(digits) * sign)
 for d in digits:
 self.w_short(d)
-dispatch[types.LongType] = dump_long
+dispatch[int] = dump_long
 
 def dump_float(self, x):
 write = self._write
 write(TYPE_FLOAT)
-s = `x`
+s = repr(x)
 write(chr(len(s)))
 write(s)
-dispatch[types.FloatType] = dump_fl

[pypy-commit] pypy py3k: 2to3

2012-03-21 Thread antocuni
Author: Antonio Cuni 
Branch: py3k
Changeset: r53872:4e43431597f2
Date: 2012-03-21 20:10 +0100
http://bitbucket.org/pypy/pypy/changeset/4e43431597f2/

Log:2to3

diff --git a/pypy/objspace/std/test/test_stringobject.py 
b/pypy/objspace/std/test/test_stringobject.py
--- a/pypy/objspace/std/test/test_stringobject.py
+++ b/pypy/objspace/std/test/test_stringobject.py
@@ -752,10 +752,10 @@
 
 def test_replace_overflow(self):
 import sys
-if sys.maxint > 2**31-1:
+if sys.maxsize > 2**31-1:
 skip("Wrong platform")
 s = b"a" * (2**16)
-raises(OverflowError, s.replace, "", s)
+raises(OverflowError, s.replace, b"", s)
 
 def test_getslice(self):
 s = b"abc"
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2012-03-19 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r53826:ecf6e68ff8c5
Date: 2012-03-19 18:21 -0700
http://bitbucket.org/pypy/pypy/changeset/ecf6e68ff8c5/

Log:2to3

diff --git a/pypy/module/micronumpy/test/test_dtypes.py 
b/pypy/module/micronumpy/test/test_dtypes.py
--- a/pypy/module/micronumpy/test/test_dtypes.py
+++ b/pypy/module/micronumpy/test/test_dtypes.py
@@ -32,14 +32,14 @@
 
 assert dtype(bool).num == 0
 assert dtype(int).num == 7
-assert dtype(long).num == 9
+assert dtype(int).num == 9
 assert dtype(float).num == 12
 
 def test_array_dtype_attr(self):
 from _numpypy import array, dtype
 
-a = array(range(5), long)
-assert a.dtype is dtype(long)
+a = array(list(range(5)), int)
+assert a.dtype is dtype(int)
 
 def test_repr_str(self):
 from _numpypy import dtype
@@ -54,13 +54,13 @@
 
 a = array([0, 1, 2, 2.5], dtype='?')
 assert a[0] is False_
-for i in xrange(1, 4):
+for i in range(1, 4):
 assert a[i] is True_
 
 def test_copy_array_with_dtype(self):
 from _numpypy import array, False_, longlong
 
-a = array([0, 1, 2, 3], dtype=long)
+a = array([0, 1, 2, 3], dtype=int)
 # int on 64-bit, long in 32-bit
 assert isinstance(a[0], longlong)
 b = a.copy()
@@ -87,14 +87,14 @@
 
 def test_zeros_long(self):
 from _numpypy import zeros, longlong
-a = zeros(10, dtype=long)
+a = zeros(10, dtype=int)
 for i in range(10):
 assert isinstance(a[i], longlong)
 assert a[1] == 0
 
 def test_ones_long(self):
 from _numpypy import ones, longlong
-a = ones(10, dtype=long)
+a = ones(10, dtype=int)
 for i in range(10):
 assert isinstance(a[i], longlong)
 assert a[1] == 1
@@ -145,7 +145,7 @@
 def test_add_int8(self):
 from _numpypy import array, dtype
 
-a = array(range(5), dtype="int8")
+a = array(list(range(5)), dtype="int8")
 b = a + a
 assert b.dtype is dtype("int8")
 for i in range(5):
@@ -154,7 +154,7 @@
 def test_add_int16(self):
 from _numpypy import array, dtype
 
-a = array(range(5), dtype="int16")
+a = array(list(range(5)), dtype="int16")
 b = a + a
 assert b.dtype is dtype("int16")
 for i in range(5):
@@ -163,7 +163,7 @@
 def test_add_uint32(self):
 from _numpypy import array, dtype
 
-a = array(range(5), dtype="I")
+a = array(list(range(5)), dtype="I")
 b = a + a
 assert b.dtype is dtype("I")
 for i in range(5):
@@ -172,7 +172,7 @@
 def test_shape(self):
 from _numpypy import dtype
 
-assert dtype(long).shape == ()
+assert dtype(int).shape == ()
 
 def test_cant_subclass(self):
 from _numpypy import dtype
@@ -296,7 +296,7 @@
 assert x == 23
 assert numpy.int32(2147483647) == 2147483647
 assert numpy.int32('2147483647') == 2147483647
-if sys.maxint > 2 ** 31 - 1:
+if sys.maxsize > 2 ** 31 - 1:
 assert numpy.int32(2147483648) == -2147483648
 assert numpy.int32('2147483648') == -2147483648
 else:
@@ -309,7 +309,7 @@
 
 assert numpy.uint32(10) == 10
 
-if sys.maxint > 2 ** 31 - 1:
+if sys.maxsize > 2 ** 31 - 1:
 assert numpy.uint32(4294967295) == 4294967295
 assert numpy.uint32(4294967296) == 0
 assert numpy.uint32('4294967295') == 4294967295
@@ -325,7 +325,7 @@
 import sys
 import _numpypy as numpy
 
-if sys.maxint == 2 ** 63 -1:
+if sys.maxsize == 2 ** 63 -1:
 assert numpy.int64.mro() == [numpy.int64, numpy.signedinteger, 
numpy.integer, numpy.number, numpy.generic, int, object]
 else:
 assert numpy.int64.mro() == [numpy.int64, numpy.signedinteger, 
numpy.integer, numpy.number, numpy.generic, object]
@@ -333,7 +333,7 @@
 assert numpy.dtype(numpy.int64).type is numpy.int64
 assert numpy.int64(3) == 3
 
-if sys.maxint >= 2 ** 63 - 1:
+if sys.maxsize >= 2 ** 63 - 1:
 assert numpy.int64(9223372036854775807) == 9223372036854775807
 assert numpy.int64('9223372036854775807') == 9223372036854775807
 else:
@@ -403,7 +403,7 @@
 import sys
 from _numpypy import int32, int64, int_
 assert issubclass(int_, int)
-if sys.maxint == (1<<31) - 1:
+if sys.maxsize == (1<<31) - 1:
 assert issubclass(int32, int)
 assert int_ is int32
 else:
@@ -417,7 +417,7 @@
 assert numpy.int16 is numpy.short
 assert numpy.int8 is numpy.byte
 assert numpy.bool_ is numpy.bool8
-if sys.maxint == (1 << 63) - 1:
+if sys.maxsize == (1 << 63) - 1:
 assert numpy.intp is numpy.in

[pypy-commit] pypy py3k: 2to3

2012-03-15 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r53710:89a8ed70f4fd
Date: 2012-03-15 16:15 -0700
http://bitbucket.org/pypy/pypy/changeset/89a8ed70f4fd/

Log:2to3

diff --git a/pypy/objspace/std/test/test_bytearrayobject.py 
b/pypy/objspace/std/test/test_bytearrayobject.py
--- a/pypy/objspace/std/test/test_bytearrayobject.py
+++ b/pypy/objspace/std/test/test_bytearrayobject.py
@@ -27,14 +27,14 @@
 assert x == b"abcd"
 
 def test_encoding(self):
-data = u"Hello world\n\u1234\u5678\u9abc\def0\def0"
+data = "Hello world\n\u1234\u5678\u9abc\def0\def0"
 for encoding in 'utf8', 'utf16':
 b = bytearray(data, encoding)
 assert b == data.encode(encoding)
 raises(TypeError, bytearray, 9, 'utf8')
 
 def test_encoding_with_ignore_errors(self):
-data = u"H\u1234"
+data = "H\u1234"
 b = bytearray(data, "latin1", errors="ignore")
 assert b == b"H"
 
@@ -82,7 +82,7 @@
 assert bytearray(b'll') in bytearray(b'hello')
 assert memoryview(b'll') in bytearray(b'hello')
 
-raises(TypeError, lambda: u'foo' in bytearray(b'foobar'))
+raises(TypeError, lambda: 'foo' in bytearray(b'foobar'))
 
 def test_splitlines(self):
 b = bytearray(b'1234')
@@ -145,10 +145,10 @@
 assert bytearray(b'hello3') != 'hello3'
 assert 'hello3' != bytearray(b'world')
 assert 'hello4' != bytearray(b'hello4')
-assert not (bytearray(b'') == u'')
-assert not (u'' == bytearray(b''))
-assert bytearray(b'') != u''
-assert u'' != bytearray(b'')
+assert not (bytearray(b'') == '')
+assert not ('' == bytearray(b''))
+assert bytearray(b'') != ''
+assert '' != bytearray(b'')
 
 def test_stringlike_operations(self):
 assert bytearray(b'hello').islower()
@@ -281,13 +281,13 @@
 assert b == b'heo'
 raises(ValueError, b.remove, ord('l'))
 raises(ValueError, b.remove, 400)
-raises(TypeError, b.remove, u'e')
+raises(TypeError, b.remove, 'e')
 raises(TypeError, b.remove, 2.3)
 # remove first and last
 b.remove(ord('o'))
 b.remove(ord('h'))
 assert b == b'e'
-raises(TypeError, b.remove, u'e')
+raises(TypeError, b.remove, 'e')
 b.remove(Indexable())
 assert b == b''
 
@@ -314,7 +314,7 @@
 b += b'def'
 assert b == b'abcdef'
 assert isinstance(b, bytearray)
-raises(TypeError, b.__iadd__, u"")
+raises(TypeError, b.__iadd__, "")
 
 def test_add(self):
 b1 = bytearray(b"abc")
@@ -329,27 +329,27 @@
 check(b1, b"def", b"abcdef")
 check(b"def", b1, b"defabc")
 check(b1, memoryview(b"def"), b"abcdef")
-raises(TypeError, lambda: b1 + u"def")
-raises(TypeError, lambda: u"abc" + b2)
+raises(TypeError, lambda: b1 + "def")
+raises(TypeError, lambda: "abc" + b2)
 
 def test_fromhex(self):
 raises(TypeError, bytearray.fromhex, 9)
 
 assert bytearray.fromhex('') == bytearray()
-assert bytearray.fromhex(u'') == bytearray()
+assert bytearray.fromhex('') == bytearray()
 
 b = bytearray([0x1a, 0x2b, 0x30])
 assert bytearray.fromhex('1a2B30') == b
 assert bytearray.fromhex('  1A 2B  30   ') == b
 assert bytearray.fromhex('') == b'\0\0'
 
-raises(ValueError, bytearray.fromhex, u'a')
-raises(ValueError, bytearray.fromhex, u'A')
-raises(ValueError, bytearray.fromhex, u'rt')
-raises(ValueError, bytearray.fromhex, u'1a b cd')
-raises(ValueError, bytearray.fromhex, u'\x00')
-raises(ValueError, bytearray.fromhex, u'12   \x00   34')
-raises(ValueError, bytearray.fromhex, u'\u1234')
+raises(ValueError, bytearray.fromhex, 'a')
+raises(ValueError, bytearray.fromhex, 'A')
+raises(ValueError, bytearray.fromhex, 'rt')
+raises(ValueError, bytearray.fromhex, '1a b cd')
+raises(ValueError, bytearray.fromhex, '\x00')
+raises(ValueError, bytearray.fromhex, '12   \x00   34')
+raises(ValueError, bytearray.fromhex, '\u1234')
 
 def test_extend(self):
 b = bytearray(b'abc')
@@ -430,14 +430,14 @@
 b = bytearray(b'abcdefghi')
 u = b.decode('utf-8')
 assert isinstance(u, str)
-assert u == u'abcdefghi'
+assert u == 'abcdefghi'
 
 def test_int(self):
 assert int(bytearray(b'-1234')) == -1234
 
 def test_reduce(self):
 assert bytearray(b'caf\xe9').__reduce__() == (
-bytearray, (u'caf\xe9', 'latin-1'), None)
+bytearray, ('caf\xe9', 'latin-1'), None)
 
 def test_setitem_slice_performance(self):
 # because of a complexity bug, this used to take forever on a
diff --git a/pypy/objspace/std/test/test_callmethod.py 
b/pypy/objspace/std/test/test_callmethod.py
--- a/pypy/objspace/std/

[pypy-commit] pypy py3k: 2to3

2012-03-12 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r53394:e9c4247d5440
Date: 2012-03-12 16:35 -0700
http://bitbucket.org/pypy/pypy/changeset/e9c4247d5440/

Log:2to3

diff --git a/pypy/objspace/std/test/test_typeobject.py 
b/pypy/objspace/std/test/test_typeobject.py
--- a/pypy/objspace/std/test/test_typeobject.py
+++ b/pypy/objspace/std/test/test_typeobject.py
@@ -118,7 +118,7 @@
 C = type('C', (object,), {'x': lambda: 42})
 unbound_meth = C.x
 raises(TypeError, unbound_meth)
-assert unbound_meth.im_func() == 42
+assert unbound_meth.__func__() == 42
 raises(TypeError, type)
 raises(TypeError, type, 'test', (object,))
 raises(TypeError, type, 'test', (object,), {}, 42)
@@ -220,7 +220,7 @@
 
 try:
 D.__bases__ = ()
-except TypeError, msg:
+except TypeError as msg:
 if str(msg) == "a new-style class can't have only classic bases":
 assert 0, "wrong error message for .__bases__ = ()"
 else:
@@ -278,7 +278,7 @@
 return super(WorkOnce, self).__new__(WorkOnce, name, bases, ns)
 def mro(instance):
 if instance.flag > 0:
-raise RuntimeError, "bozo"
+raise RuntimeError("bozo")
 else:
 instance.flag += 1
 return type.mro(instance)
@@ -345,7 +345,7 @@
 except TypeError:
 pass
 else:
-raise TestFailed, "didn't catch MRO conflict"
+raise TestFailed("didn't catch MRO conflict")
 
 def test_mutable_bases_versus_nonheap_types(self):
 class A(int):
@@ -479,7 +479,7 @@
 except TypeError:
 pass
 else:
-raise AssertionError, "this multiple inheritance should fail"
+raise AssertionError("this multiple inheritance should fail")
 
 def test_outer_metaclass(self):
 class OuterMetaClass(type):
@@ -503,7 +503,7 @@
 pass
 
 g = {'__metaclass__': __metaclass__}
-exec "class HasImplicitMetaclass: pass\n" in g
+exec("class HasImplicitMetaclass: pass\n", g)
 
 HasImplicitMetaclass = g['HasImplicitMetaclass']
 assert type(HasImplicitMetaclass) == __metaclass__
@@ -549,7 +549,7 @@
 try:
 assert NoDoc.__doc__ == None
 except AttributeError:
-raise AssertionError, "__doc__ missing!"
+raise AssertionError("__doc__ missing!")
 
 def test_explicitdoc(self):
 class ExplicitDoc(object):
@@ -576,7 +576,7 @@
 #   we always raise AttributeError.
 pass
 else:
-raise AssertionError, '__doc__ should not be writable'
+raise AssertionError('__doc__ should not be writable')
 
 assert ImmutableDoc.__doc__ == 'foo'
 
@@ -693,7 +693,7 @@
 __slots__ = "abc"
 
 class B(object):
-__slots__ = u"abc"
+__slots__ = "abc"
 
 a = A()
 a.abc = "awesome"
@@ -980,12 +980,12 @@
 
 def test_module(self):
 def f(): pass
-assert object.__module__ == '__builtin__'
-assert int.__module__ == '__builtin__'
-assert type.__module__ == '__builtin__'
-assert type(f).__module__ == '__builtin__'
+assert object.__module__ == 'builtins'
+assert int.__module__ == 'builtins'
+assert type.__module__ == 'builtins'
+assert type(f).__module__ == 'builtins'
 d = {'__name__': 'yay'}
-exec """class A(object):\n  pass\n""" in d
+exec("""class A(object):\n  pass\n""", d)
 A = d['A']
 assert A.__module__ == 'yay'
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: 2to3

2011-11-07 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r48889:3e341a64f85c
Date: 2011-11-07 14:25 -0800
http://bitbucket.org/pypy/pypy/changeset/3e341a64f85c/

Log:2to3

diff --git a/pypy/conftest.py b/pypy/conftest.py
--- a/pypy/conftest.py
+++ b/pypy/conftest.py
@@ -72,7 +72,7 @@
 """
 try:
 config = make_config(option, objspace=name, **kwds)
-except ConflictConfigError, e:
+except ConflictConfigError as e:
 # this exception is typically only raised if a module is not available.
 # in this case the test should be skipped
 py.test.skip(str(e))
@@ -96,7 +96,7 @@
 config = make_config(option)
 try:
 space = make_objspace(config)
-except OperationError, e:
+except OperationError as e:
 check_keyboard_interrupt(e)
 if option.verbose:
 import traceback
@@ -118,7 +118,7 @@
 def __init__(self, **kwds):
 import sys
 info = getattr(sys, 'pypy_translation_info', None)
-for key, value in kwds.iteritems():
+for key, value in kwds.items():
 if key == 'usemodules':
 if info is not None:
 for modname in value:
@@ -148,7 +148,7 @@
 assert body.startswith('(')
 src = py.code.Source("def anonymous" + body)
 d = {}
-exec src.compile() in d
+exec(src.compile(), d)
 return d['anonymous'](*args)
 
 def wrap(self, obj):
@@ -210,9 +210,9 @@
 source = py.code.Source(target)[1:].deindent()
 res, stdout, stderr = runsubprocess.run_subprocess(
 python, ["-c", helpers + str(source)])
-print source
-print >> sys.stdout, stdout
-print >> sys.stderr, stderr
+print(source)
+print(stdout, file=sys.stdout)
+print(stderr, file=sys.stderr)
 if res > 0:
 raise AssertionError("Subprocess failed")
 
@@ -225,7 +225,7 @@
 try:
 if e.w_type.name == 'KeyboardInterrupt':
 tb = sys.exc_info()[2]
-raise OpErrKeyboardInterrupt, OpErrKeyboardInterrupt(), tb
+raise OpErrKeyboardInterrupt().with_traceback(tb)
 except AttributeError:
 pass
 
@@ -240,7 +240,7 @@
 apparently earlier on "raises" was already added
 to module's globals.
 """
-import __builtin__
+import builtins
 for helper in helpers:
 if not hasattr(__builtin__, helper):
 setattr(__builtin__, helper, getattr(py.test, helper))
@@ -304,10 +304,10 @@
 
 elif hasattr(obj, 'func_code') and self.funcnamefilter(name):
 if name.startswith('app_test_'):
-assert not obj.func_code.co_flags & 32, \
+assert not obj.__code__.co_flags & 32, \
 "generator app level functions? you must be joking"
 return AppTestFunction(name, parent=self)
-elif obj.func_code.co_flags & 32: # generator function
+elif obj.__code__.co_flags & 32: # generator function
 return pytest.Generator(name, parent=self)
 else:
 return IntTestFunction(name, parent=self)
@@ -321,7 +321,7 @@
  "(btw, i would need options: %s)" %
  (ropts,))
 for opt in ropts:
-if not options.has_key(opt) or options[opt] != ropts[opt]:
+if opt not in options or options[opt] != ropts[opt]:
 break
 else:
 return
@@ -387,10 +387,10 @@
 def runtest(self):
 try:
 super(IntTestFunction, self).runtest()
-except OperationError, e:
+except OperationError as e:
 check_keyboard_interrupt(e)
 raise
-except Exception, e:
+except Exception as e:
 cls = e.__class__
 while cls is not Exception:
 if cls.__name__ == 'DistutilsPlatformError':
@@ -411,13 +411,13 @@
 def execute_appex(self, space, target, *args):
 try:
 target(*args)
-except OperationError, e:
+except OperationError as e:
 tb = sys.exc_info()[2]
 if e.match(space, space.w_KeyboardInterrupt):
-raise OpErrKeyboardInterrupt, OpErrKeyboardInterrupt(), tb
+raise OpErrKeyboardInterrupt().with_traceback(tb)
 appexcinfo = appsupport.AppExceptionInfo(space, e)
 if appexcinfo.traceback:
-raise AppError, AppError(appexcinfo), tb
+raise AppError(appexcinfo).with_traceback(tb)
 raise
 
 def runtest(self):
@@ -429,7 +429,7 @@
 space = gettestobjspace()
 filename = self._getdynfilename(target)
 func = app2interp_temp(target, filename=filename)
-print "executing", func
+print("executing", func)
 self.execute_appex(space, func, space)
 
 def repr_failure(self, excinfo):
@@ -438,7 +438,7 @@
 return super(AppTestFunction, self).repr_failure(excinfo)
 
 def _ge