Author: Brian Kearns <[email protected]>
Branch: stdlib-2.7.4
Changeset: r60707:ac5e46dfb1d8
Date: 2013-01-29 23:29 -0500
http://bitbucket.org/pypy/pypy/changeset/ac5e46dfb1d8/
Log: merge default
diff --git a/lib-python/2.7/inspect.py b/lib-python/2.7/inspect.py
--- a/lib-python/2.7/inspect.py
+++ b/lib-python/2.7/inspect.py
@@ -960,7 +960,7 @@
raise TypeError('%s() takes exactly 0 arguments '
'(%d given)' % (f_name, num_total))
else:
- raise TypeError('%s() takes no argument (%d given)' %
+ raise TypeError('%s() takes no arguments (%d given)' %
(f_name, num_total))
for arg in args:
if isinstance(arg, str) and arg in named:
diff --git a/lib-python/2.7/site.py b/lib-python/2.7/site.py
--- a/lib-python/2.7/site.py
+++ b/lib-python/2.7/site.py
@@ -75,6 +75,7 @@
USER_SITE = None
USER_BASE = None
+
def makepath(*paths):
dir = os.path.join(*paths)
try:
diff --git a/lib-python/2.7/test/test_capi.py b/lib-python/2.7/test/test_capi.py
--- a/lib-python/2.7/test/test_capi.py
+++ b/lib-python/2.7/test/test_capi.py
@@ -13,6 +13,20 @@
threading = None
import _testcapi
+skips = []
+if test_support.check_impl_detail(pypy=True):
+ skips += [
+ 'test_broken_memoryview',
+ 'test_capsule',
+ 'test_lazy_hash_inheritance',
+ 'test_long_api',
+ 'test_longlong_api',
+ 'test_null_strings',
+ 'test_widechar',
+ 'TestThreadState',
+ 'TestPendingCalls',
+ ]
+
@unittest.skipUnless(threading, 'Threading required for this test.')
class TestPendingCalls(unittest.TestCase):
@@ -99,7 +113,7 @@
def test_main():
for name in dir(_testcapi):
- if name.startswith('test_'):
+ if name.startswith('test_') and name not in skips:
test = getattr(_testcapi, name)
if test_support.verbose:
print "internal", name
@@ -126,7 +140,7 @@
raise test_support.TestFailed, \
"Couldn't find main thread correctly in the list"
- if threading:
+ if threading and 'TestThreadState' not in skips:
import thread
import time
TestThreadState()
@@ -134,7 +148,8 @@
t.start()
t.join()
- test_support.run_unittest(TestPendingCalls)
+ if 'TestPendingCalls' not in skips:
+ test_support.run_unittest(TestPendingCalls)
if __name__ == "__main__":
test_main()
diff --git a/lib-python/2.7/test/test_itertools.py
b/lib-python/2.7/test/test_itertools.py
--- a/lib-python/2.7/test/test_itertools.py
+++ b/lib-python/2.7/test/test_itertools.py
@@ -533,11 +533,11 @@
self.assertEqual(list(izip()), zip())
self.assertRaises(TypeError, izip, 3)
self.assertRaises(TypeError, izip, range(3), 3)
-
self.assertEqual([tuple(list(pair)) for pair in izip('abc', 'def')],
zip('abc', 'def'))
self.assertEqual([pair for pair in izip('abc', 'def')],
zip('abc', 'def'))
+
@test_support.impl_detail("tuple reuse is specific to CPython")
def test_izip_tuple_reuse(self):
ids = map(id, izip('abc', 'def'))
@@ -588,6 +588,7 @@
zip('abc', 'def'))
self.assertEqual([pair for pair in izip_longest('abc', 'def')],
zip('abc', 'def'))
+
@test_support.impl_detail("tuple reuse is specific to CPython")
def test_izip_longest_tuple_reuse(self):
ids = map(id, izip_longest('abc', 'def'))
diff --git a/lib-python/2.7/test/test_support.py
b/lib-python/2.7/test/test_support.py
--- a/lib-python/2.7/test/test_support.py
+++ b/lib-python/2.7/test/test_support.py
@@ -1181,7 +1181,6 @@
else:
runner = BasicTestRunner()
-
result = runner.run(suite)
if not result.wasSuccessful():
if len(result.errors) == 1 and not result.failures:
diff --git a/lib-python/conftest.py b/lib-python/conftest.py
--- a/lib-python/conftest.py
+++ b/lib-python/conftest.py
@@ -132,7 +132,7 @@
RegrTest('test_bz2.py', usemodules='bz2'),
RegrTest('test_calendar.py'),
RegrTest('test_call.py', core=True),
- RegrTest('test_capi.py', skip="not applicable"),
+ RegrTest('test_capi.py'),
RegrTest('test_cd.py'),
RegrTest('test_cfgparser.py'),
RegrTest('test_cgi.py'),
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -922,8 +922,8 @@
kwds["link_extra"] = ["msvcrt.lib"]
elif sys.platform.startswith('linux'):
compile_extra.append("-Werror=implicit-function-declaration")
+ compile_extra.append('-g')
export_symbols_eci.append('pypyAPI')
- compile_extra.append('-g')
else:
kwds["includes"] = ['Python.h'] # this is our Python.h
diff --git a/pypy/module/thread/test/support.py
b/pypy/module/thread/test/support.py
--- a/pypy/module/thread/test/support.py
+++ b/pypy/module/thread/test/support.py
@@ -2,6 +2,7 @@
import time
import thread
import os
+import errno
from pypy.interpreter.gateway import interp2app, unwrap_spec
from pypy.module.thread import gil
@@ -28,7 +29,12 @@
def kill():
for x in range(delay * 10):
time.sleep(0.1)
- os.kill(pid, 0)
+ try:
+ os.kill(pid, 0)
+ except OSError, e:
+ if e.errno == errno.ESRCH: # no such process
+ return
+ raise
os.kill(pid, 9)
print "process %s killed!" % (pid,)
thread.start_new_thread(kill, ())
diff --git a/pypy/module/thread/test/test_fork.py
b/pypy/module/thread/test/test_fork.py
--- a/pypy/module/thread/test/test_fork.py
+++ b/pypy/module/thread/test/test_fork.py
@@ -1,7 +1,7 @@
from pypy.module.thread.test.support import GenericTestThread
class AppTestFork(GenericTestThread):
- def test_fork(self):
+ def test_fork_with_thread(self):
# XXX This test depends on a multicore machine, as busy_thread must
# aquire the GIL the instant that the main thread releases it.
# It will incorrectly pass if the GIL is not grabbed in time.
@@ -12,45 +12,48 @@
if not hasattr(os, 'fork'):
skip("No fork on this platform")
- run = True
- done = []
def busy_thread():
while run:
time.sleep(0)
done.append(None)
- try:
- thread.start_new(busy_thread, ())
+ for i in range(1):
+ run = True
+ done = []
+ try:
+ thread.start_new(busy_thread, ())
+ print 'sleep'
- pid = os.fork()
-
- if pid == 0:
- os._exit(0)
-
- else:
- time.sleep(1)
- spid, status = os.waitpid(pid, os.WNOHANG)
- assert spid == pid
- finally:
- run = False
- self.waitfor(lambda: done)
+ pid = os.fork()
+ if pid == 0:
+ os._exit(0)
+ else:
+ self.timeout_killer(pid, 5)
+ exitcode = os.waitpid(pid, 0)[1]
+ assert exitcode == 0 # if 9, process was killed by timer!
+ finally:
+ run = False
+ self.waitfor(lambda: done)
+ assert done
def test_forked_can_thread(self):
"Checks that a forked interpreter can start a thread"
- import os, thread, time
+ import thread
+ import os
if not hasattr(os, 'fork'):
skip("No fork on this platform")
- # pre-allocate some locks
- thread.start_new_thread(lambda: None, ())
+ for i in range(10):
+ # pre-allocate some locks
+ thread.start_new_thread(lambda: None, ())
+ print 'sleep'
- pid = os.fork()
- if pid == 0:
- print 'in child'
- thread.start_new_thread(lambda: None, ())
- os._exit(0)
- else:
- self.timeout_killer(pid, 5)
- exitcode = os.waitpid(pid, 0)[1]
- assert exitcode == 0 # if 9, process was killed by timer!
+ pid = os.fork()
+ if pid == 0:
+ thread.start_new_thread(lambda: None, ())
+ os._exit(0)
+ else:
+ self.timeout_killer(pid, 5)
+ exitcode = os.waitpid(pid, 0)[1]
+ assert exitcode == 0 # if 9, process was killed by timer!
diff --git a/rpython/jit/metainterp/optimizeopt/rewrite.py
b/rpython/jit/metainterp/optimizeopt/rewrite.py
--- a/rpython/jit/metainterp/optimizeopt/rewrite.py
+++ b/rpython/jit/metainterp/optimizeopt/rewrite.py
@@ -239,6 +239,8 @@
def optimize_GUARD_VALUE(self, op):
value = self.getvalue(op.getarg(0))
+ if value.is_virtual():
+ raise InvalidLoop('A promote of a virtual (a recently allocated
object) never makes sense!')
if value.last_guard:
# there already has been a guard_nonnull or guard_class or
# guard_nonnull_class on this value, which is rather silly.
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py
b/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py
@@ -2623,7 +2623,7 @@
jump(p2)
"""
self.raises(InvalidLoop, self.optimize_loop,
- ops, ops)
+ ops, "crash!")
def test_invalid_loop_2(self):
ops = """
@@ -2635,7 +2635,7 @@
jump(p2)
"""
self.raises(InvalidLoop, self.optimize_loop,
- ops, ops)
+ ops, "crash!")
def test_invalid_loop_3(self):
ops = """
@@ -2648,8 +2648,17 @@
setfield_gc(p3, p4, descr=nextdescr)
jump(p3)
"""
- self.raises(InvalidLoop, self.optimize_loop, ops, ops)
-
+ self.raises(InvalidLoop, self.optimize_loop, ops, "crash!")
+
+ def test_invalid_loop_guard_value_of_virtual(self):
+ ops = """
+ [p1]
+ p2 = new_with_vtable(ConstClass(node_vtable))
+ guard_value(p2, ConstPtr(myptr)) []
+ jump(p2)
+ """
+ self.raises(InvalidLoop, self.optimize_loop,
+ ops, "crash!")
def test_merge_guard_class_guard_value(self):
ops = """
diff --git a/rpython/translator/c/src/thread_nt.c
b/rpython/translator/c/src/thread_nt.c
--- a/rpython/translator/c/src/thread_nt.c
+++ b/rpython/translator/c/src/thread_nt.c
@@ -13,6 +13,7 @@
/*
* Thread support.
*/
+/* In rpython, this file is pulled in by thread.c */
typedef struct RPyOpaque_ThreadLock NRMUTEX, *PNRMUTEX;
diff --git a/rpython/translator/c/src/thread_nt.h
b/rpython/translator/c/src/thread_nt.h
--- a/rpython/translator/c/src/thread_nt.h
+++ b/rpython/translator/c/src/thread_nt.h
@@ -9,6 +9,7 @@
} NRMUTEX, *PNRMUTEX;
/* prototypes */
+long RPyThreadGetIdent(void);
long RPyThreadStart(void (*func)(void));
int RPyThreadLockInit(struct RPyOpaque_ThreadLock *lock);
void RPyOpaqueDealloc_ThreadLock(struct RPyOpaque_ThreadLock *lock);
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit