[pypy-svn] r15103 - in pypy/dist/pypy/translator/c: . test

arigo at codespeak.net arigo at codespeak.net
Tue Jul 26 13:35:18 CEST 2005


Author: arigo
Date: Tue Jul 26 13:35:16 2005
New Revision: 15103

Modified:
   pypy/dist/pypy/translator/c/node.py
   pypy/dist/pypy/translator/c/test/test_extfunc.py
Log:
Hack to reserve an extra byte at the end of the array
of characters in the STR objects.

(cfbolz, arigo)


Modified: pypy/dist/pypy/translator/c/node.py
==============================================================================
--- pypy/dist/pypy/translator/c/node.py	(original)
+++ pypy/dist/pypy/translator/c/node.py	Tue Jul 26 13:35:16 2005
@@ -8,6 +8,7 @@
 from pypy.translator.c.support import cdecl, somelettersfrom
 from pypy.translator.c.primitive import PrimitiveType
 from pypy.translator.c import extfunc
+from pypy.rpython.rstr import STR
 
 
 def needs_refcount(T):
@@ -173,12 +174,15 @@
         self.ARRAY = ARRAY
         self.LLTYPE = ARRAY
         self.varlength = varlength
+        self.original_varlength = varlength
+        if ARRAY is STR.chars:
+            self.varlength += 1   # for the NULL char at the end of the string
 
     def setup(self):
         db = self.db
         ARRAY = self.ARRAY
         varlength = self.varlength
-        if varlength == 1:
+        if self.original_varlength == 1:
             basename = 'array'
             with_number = True
         else:

Modified: pypy/dist/pypy/translator/c/test/test_extfunc.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_extfunc.py	(original)
+++ pypy/dist/pypy/translator/c/test/test_extfunc.py	Tue Jul 26 13:35:16 2005
@@ -16,7 +16,7 @@
     assert t0 <= t1 <= t2
 
 
-def INPROGRESStest_os_open():
+def test_os_open():
     tmpfile = str(udir.join('test_os_open.txt'))
     def does_stuff():
         fd = os.open(tmpfile, os.O_WRONLY | os.O_CREAT, 0777)
@@ -27,7 +27,7 @@
     os.close(fd)
     assert os.path.exists(tmpfile)
 
-def INPROGRESStest_failing_os_open():
+def test_failing_os_open():
     tmpfile = str(udir.join('test_failing_os_open.DOESNTEXIST'))
     def does_stuff():
         fd = os.open(tmpfile, os.O_RDONLY, 0777)
@@ -37,7 +37,7 @@
     py.test.raises(OSError, f1)
     assert not os.path.exists(tmpfile)
 
-def INPROGRESStest_open_read_write_close():
+def test_open_read_write_close():
     filename = str(udir.join('test_open_read_write_close.txt'))
     def does_stuff():
         fd = os.open(filename, os.O_WRONLY | os.O_CREAT, 0777)
@@ -54,7 +54,7 @@
     assert open(filename, 'r').read() == "hello world\n"
     os.unlink(filename)
 
-def INPROGRESStest_os_stat():
+def test_os_stat():
     filename = str(py.magic.autopath())
     def call_stat():
         st = os.stat(filename)
@@ -65,11 +65,12 @@
     assert result[1] == os.stat(filename)[1]
     assert result[2] == os.stat(filename)[2]
 
-def INPROGRESStest_os_fstat():
+def CRASHING_test_os_fstat():
     filename = str(py.magic.autopath())
     def call_fstat():
         fd = os.open(filename, os.O_RDONLY, 0777)
         st = os.fstat(fd)
+        os.close(fd)
         return st
     f = compile(call_fstat, [])
     result = f()
@@ -105,7 +106,7 @@
     f = compile(fn, [float])
     assert f(10.123) == modf(10.123)
 
-def INPROGRESStest_os_path_exists():
+def test_os_path_exists():
     tmpfile = str(udir.join('test_os_path_exists.TMP'))
     def fn():
         return os.path.exists(tmpfile)



More information about the Pypy-commit mailing list