Author: mattip
Branch: missing-ndarray-attributes
Changeset: r60673:7f7a5ee5c4f8
Date: 2013-01-29 14:42 +0200
http://bitbucket.org/pypy/pypy/changeset/7f7a5ee5c4f8/

Log:    use single logic statements, translation produces incorrect code
        otherwise

diff --git a/pypy/module/micronumpy/arrayimpl/sort.py 
b/pypy/module/micronumpy/arrayimpl/sort.py
--- a/pypy/module/micronumpy/arrayimpl/sort.py
+++ b/pypy/module/micronumpy/arrayimpl/sort.py
@@ -82,10 +82,16 @@
 
 def argsort_array(arr, space, w_axis):
     itemtype = arr.dtype.itemtype
-    # this is for runtime
-    if not (arr.dtype.is_int_type() or \
-            arr.dtype.is_float_type() or \
-            arr.dtype.is_complex_type()):
+    # this is for runtime - written like this to simplify
+    # logic since translation could not handle it as one 
+    # statement
+    if arr.dtype.is_int_type():
+        pass
+    elif arr.dtype.is_float_type():
+        pass
+    elif arr.dtype.is_complex_type():
+        pass
+    else:    
         raise OperationError(space.w_NotImplementedError,
            space.wrap("sorting of non-numeric types " + \
                       "'%s' is not implemented" % arr.dtype.get_name() ))
diff --git a/pypy/tool/watchdog_nt.py b/pypy/tool/watchdog_nt.py
new file mode 100644
--- /dev/null
+++ b/pypy/tool/watchdog_nt.py
@@ -0,0 +1,33 @@
+import sys, os
+import threading
+import ctypes
+
+def childkill(pid):
+    global timedout
+    timedout = True
+    sys.stderr.write("==== test running for %d seconds ====\n" % timeout)
+    sys.stderr.write("="*26 + "timedout" + "="*26 + "\n")
+    ctypes.windll.kernel32.TerminateProcess(pid, 1)
+
+if __name__ == '__main__':
+    PROCESS_TERMINATE = 0x1
+
+    timeout = float(sys.argv[1])
+    timedout = False
+
+    pid = os.spawnv(os.P_NOWAIT, sys.argv[2], sys.argv[2:])
+
+    t = threading.Timer(timeout, childkill, (pid,))
+    t.start()
+    while True:
+        try:
+            pid, status = os.waitpid(pid, 0)
+        except KeyboardInterrupt:
+            continue
+        else:
+            t.cancel()
+            break
+
+    #print 'status ', status >> 8
+    sys.exit(status >> 8)
+
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to