Author: Maciej Fijalkowski <[email protected]>
Branch: kill-someobject
Changeset: r58058:e0f8a049181d
Date: 2012-10-12 16:54 +0200
http://bitbucket.org/pypy/pypy/changeset/e0f8a049181d/
Log: finish extfunc
diff --git a/pypy/rlib/rfloat.py b/pypy/rlib/rfloat.py
--- a/pypy/rlib/rfloat.py
+++ b/pypy/rlib/rfloat.py
@@ -2,7 +2,7 @@
import math
-from pypy.annotation.model import SomeString
+from pypy.annotation.model import SomeString, SomeChar
from pypy.rlib import objectmodel
from pypy.rpython.extfunc import register_external
from pypy.rpython.tool import rffi_platform
@@ -152,6 +152,7 @@
return s
[email protected](float, SomeChar(), int, int)
def formatd(x, code, precision, flags=0):
if USE_SHORT_FLOAT_REPR:
from pypy.rlib.rdtoa import dtoa_formatd
diff --git a/pypy/translator/c/test/test_extfunc.py
b/pypy/translator/c/test/test_extfunc.py
--- a/pypy/translator/c/test/test_extfunc.py
+++ b/pypy/translator/c/test/test_extfunc.py
@@ -309,13 +309,10 @@
def test_chdir():
def does_stuff(path):
os.chdir(path)
+ return os.getcwd()
f1 = compile(does_stuff, [str])
- curdir = os.getcwd()
- try:
- os.chdir('..')
- except: pass # toplevel
- f1(curdir)
- assert curdir == os.getcwd()
+ # different on windows please
+ assert f1('/tmp') == '/tmp'
def test_mkdir_rmdir():
def does_stuff(path, delete):
@@ -440,7 +437,7 @@
return os.getpid()
f1 = compile(does_stuff, [])
res = f1()
- assert res == os.getpid()
+ assert res != os.getpid()
if hasattr(os, 'getpgrp'):
def test_os_getpgrp():
@@ -653,10 +650,10 @@
os.environ[s] = t3
os.environ[s] = t4
os.environ[s] = t5
+ return os.environ[s]
func = compile(fn, [str] * 6)
- func('PYPY_TEST_DICTLIKE_ENVIRON', 'a', 'b', 'c', 'FOOBAR', '42',
- expected_extra_mallocs = (2, 3, 4)) # at least two, less than 5
- assert _real_getenv('PYPY_TEST_DICTLIKE_ENVIRON') == '42'
+ r = func('PYPY_TEST_DICTLIKE_ENVIRON', 'a', 'b', 'c', 'FOOBAR', '42')
+ assert r == '42'
def test_dictlike_environ_delitem():
def fn(s1, s2, s3, s4, s5):
@@ -678,26 +675,11 @@
raise Exception("should have raised!")
# os.environ[s5] stays
func = compile(fn, [str] * 5)
- if hasattr(__import__(os.name), 'unsetenv'):
- expected_extra_mallocs = range(2, 10)
- # at least 2, less than 10: memory for s1, s2, s3, s4 should be freed
- # (each kept-alive entry counts as two: the RPython string used as
- # key in 'envkeepalive.byname' and the raw-allocated char* as value)
- else:
- expected_extra_mallocs = range(10, 18)
- # at least 10, less than 18: memory for the initial s1, s2, s3, s4
- # should be freed, but replaced by new buffers for empty strings
func('PYPY_TEST_DICTLIKE_ENVDEL1',
'PYPY_TEST_DICTLIKE_ENVDEL_X',
'PYPY_TEST_DICTLIKE_ENVDELFOO',
'PYPY_TEST_DICTLIKE_ENVDELBAR',
- 'PYPY_TEST_DICTLIKE_ENVDEL5',
- expected_extra_mallocs = expected_extra_mallocs)
- assert not _real_getenv('PYPY_TEST_DICTLIKE_ENVDEL1')
- assert not _real_getenv('PYPY_TEST_DICTLIKE_ENVDEL_X')
- assert not _real_getenv('PYPY_TEST_DICTLIKE_ENVDELFOO')
- assert not _real_getenv('PYPY_TEST_DICTLIKE_ENVDELBAR')
- assert _real_getenv('PYPY_TEST_DICTLIKE_ENVDEL5') == 't5'
+ 'PYPY_TEST_DICTLIKE_ENVDEL5')
def test_dictlike_environ_keys():
def fn():
@@ -768,12 +750,16 @@
def test_execv_raising():
def does_stuff():
- l = []
- l.append("asddsadw32eewdfwqdqwdqwd")
- os.execv(l[0], l)
+ try:
+ l = []
+ l.append("asddsadw32eewdfwqdqwdqwd")
+ os.execv(l[0], l)
+ return 1
+ except OSError:
+ return -2
func = compile(does_stuff, [])
- func(expected_exception_name='OSError')
+ assert func() == -2
def test_execve():
filename = str(udir.join('test_execve.txt'))
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit