Permalink
Browse files

portability fixes

  • Loading branch information...
Stefan Behnel
Stefan Behnel committed Nov 5, 2010
1 parent ee45a1e commit 9793290156f7a02399daf4fa8b9a88ddd9a45820
Showing with 20 additions and 16 deletions.
  1. +5 −1 lupa/_lupa.pyx
  2. +15 −15 lupa/tests/test.py
View
@@ -12,6 +12,7 @@ cimport cpython.ref
cimport cpython.bytes
cimport cpython.tuple
from cpython.ref cimport PyObject
+from cpython.version cimport PY_VERSION_HEX
cdef extern from *:
ctypedef char* const_char_ptr "const char*"
@@ -1187,7 +1188,10 @@ cdef int py_iter_next_with_gil(lua_State* L, py_object* py_iter) with gil:
cdef LuaRuntime runtime
try:
runtime = <LuaRuntime?>py_iter.runtime
- obj = next(<object>py_iter.obj)
+ if PY_VERSION_HEX >= 0x02060000:
+ obj = next(<object>py_iter.obj)
+ else:
+ obj = (<object>py_iter.obj).next()
if (py_iter.type_flags & OBJ_UNPACK_TUPLE) and isinstance(obj, tuple):
# special case: when the iterable returns a tuple, unpack it
push_lua_arguments(runtime, L, <tuple>obj)
View
@@ -1275,21 +1275,21 @@ def f():
b.wait_for_finished()
self.assertEqual(len(b.finished), N)
- def test_with(self):
- lock = self.locktype()
- def f():
- lock.acquire()
- lock.release()
- def _with(err=None):
- with lock:
- if err is not None:
- raise err
- _with()
- # Check the lock is unacquired
- self.Bunch(f, 1).wait_for_finished()
- self.assertRaises(TypeError, _with, TypeError)
- # Check the lock is unacquired
- self.Bunch(f, 1).wait_for_finished()
+ ## def test_with(self):
+ ## lock = self.locktype()
+ ## def f():
+ ## lock.acquire()
+ ## lock.release()
+ ## def _with(err=None):
+ ## with lock:
+ ## if err is not None:
+ ## raise err
+ ## _with()
+ ## # Check the lock is unacquired
+ ## self.Bunch(f, 1).wait_for_finished()
+ ## self.assertRaises(TypeError, _with, TypeError)
+ ## # Check the lock is unacquired
+ ## self.Bunch(f, 1).wait_for_finished()
def test_thread_leak(self):
# The lock shouldn't leak a Thread instance when used from a foreign

0 comments on commit 9793290

Please sign in to comment.