[pypy-svn] pypy default: Merge heads
rguillebert
commits-noreply at bitbucket.org
Thu Apr 28 17:21:56 CEST 2011
Author: Romain Guillebert <romain.py at gmail.com>
Branch:
Changeset: r43722:cc753d45bee3
Date: 2011-04-28 17:21 +0200
http://bitbucket.org/pypy/pypy/changeset/cc753d45bee3/
Log: Merge heads
diff --git a/pypy/module/test_lib_pypy/ctypes_tests/test_functions.py b/pypy/module/test_lib_pypy/ctypes_tests/test_functions.py
--- a/pypy/module/test_lib_pypy/ctypes_tests/test_functions.py
+++ b/pypy/module/test_lib_pypy/ctypes_tests/test_functions.py
@@ -427,3 +427,28 @@
a[1].x = 33
u = dll.ret_un_func(a[1])
assert u.y == 33*10000
+
+ def test_warnings(self):
+ import warnings
+ warnings.simplefilter("always")
+ with warnings.catch_warnings(record=True) as w:
+ dll.get_an_integer()
+ assert len(w) == 2
+ assert issubclass(w[0].category, RuntimeWarning)
+ assert issubclass(w[1].category, RuntimeWarning)
+ assert "C function without declared arguments called" in str(w[0].message)
+ assert "C function without declared return type called" in str(w[1].message)
+
+ with warnings.catch_warnings(record=True) as w:
+ dll.get_an_integer.argtypes = []
+ dll.get_an_integer()
+ assert len(w) == 1
+ assert issubclass(w[0].category, RuntimeWarning)
+ assert "C function without declared return type called" in str(w[0].message)
+
+ with warnings.catch_warnings(record=True) as w:
+ dll.get_an_integer.restype = None
+ dll.get_an_integer()
+ assert len(w) == 0
+
+ warnings.resetwarnings()
diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -177,6 +177,7 @@
sqlite.sqlite3_errmsg.restype = c_char_p
sqlite.sqlite3_get_autocommit.argtypes = [c_void_p]
sqlite.sqlite3_get_autocommit.restype = c_int
+sqlite.sqlite3_libversion.argtypes = []
sqlite.sqlite3_libversion.restype = c_char_p
sqlite.sqlite3_open.argtypes = [c_char_p, c_void_p]
sqlite.sqlite3_prepare_v2.argtypes = [c_void_p, c_char_p, c_int, c_void_p, POINTER(c_char_p)]
diff --git a/pypy/module/test_lib_pypy/ctypes_tests/test_callbacks.py b/pypy/module/test_lib_pypy/ctypes_tests/test_callbacks.py
--- a/pypy/module/test_lib_pypy/ctypes_tests/test_callbacks.py
+++ b/pypy/module/test_lib_pypy/ctypes_tests/test_callbacks.py
@@ -217,6 +217,7 @@
CTP = CFUNCTYPE(None)
cfunc = dll._testfunc_callback_void
cfunc.argtypes = [CTP]
+ cfunc.restype = int
cfunc(CTP(callback))
out, err = capsys.readouterr()
assert (out, err) == ("", "")
diff --git a/lib_pypy/_ctypes/function.py b/lib_pypy/_ctypes/function.py
--- a/lib_pypy/_ctypes/function.py
+++ b/lib_pypy/_ctypes/function.py
@@ -1,6 +1,7 @@
import _rawffi
import sys
import traceback
+import warnings
from _ctypes.basics import ArgumentError, keepalive_key
from _ctypes.basics import _CData, _CDataMeta, cdata_from_address
@@ -69,6 +70,8 @@
_com_index = None
_com_iid = None
+ __restype_set = False
+
def _getargtypes(self):
return self._argtypes_
@@ -134,6 +137,7 @@
return self._restype_
def _setrestype(self, restype):
+ self.__restype_set = True
self._ptr = None
if restype is int:
from ctypes import c_int
@@ -288,7 +292,13 @@
return
if argtypes is None:
+ warnings.warn('C function without declared arguments called',
+ RuntimeWarning, stacklevel=2)
argtypes = []
+
+ if not self.__restype_set:
+ warnings.warn('C function without declared return type called',
+ RuntimeWarning, stacklevel=2)
if self._com_index:
from ctypes import cast, c_void_p, POINTER
diff --git a/pypy/module/posix/test/test_posix2.py b/pypy/module/posix/test/test_posix2.py
--- a/pypy/module/posix/test/test_posix2.py
+++ b/pypy/module/posix/test/test_posix2.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
+from __future__ import with_statement
from pypy.objspace.std import StdObjSpace
from pypy.tool.udir import udir
from pypy.conftest import gettestobjspace
@@ -506,6 +507,7 @@
if hasattr(os, 'setuid'):
def test_os_setuid_error(self):
+ skip("overflow checking disabled for now")
os = self.posix
raises((OSError, ValueError, OverflowError), os.setuid, -100000)
@@ -527,6 +529,7 @@
if hasattr(os, 'setgid'):
def test_os_setgid_error(self):
+ skip("overflow checking disabled for now")
os = self.posix
raises((OSError, ValueError, OverflowError), os.setgid, -100000)
@@ -534,7 +537,7 @@
def test_os_getsid(self):
os = self.posix
assert os.getsid(0) == self.getsid0
- raises((OSError, ValueError, OverflowError), os.getsid, -100000)
+ raises(OSError, os.getsid, -100000)
if hasattr(os, 'sysconf'):
def test_os_sysconf(self):
diff --git a/pypy/module/posix/interp_posix.py b/pypy/module/posix/interp_posix.py
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -15,7 +15,12 @@
_WIN = sys.platform == 'win32'
c_int = "c_int"
-c_nonnegint = "c_nonnegint"
+
+# CPython 2.7 semantics are too messy to follow exactly,
+# e.g. setuid(-2) works on 32-bit but not on 64-bit. As a result,
+# we decided to just accept any 'int', i.e. any C signed long.
+c_uid_t = int
+c_gid_t = int
class FileEncoder(object):
def __init__(self, space, w_obj):
@@ -823,7 +828,7 @@
"""
return space.wrap(os.getuid())
- at unwrap_spec(arg=c_nonnegint)
+ at unwrap_spec(arg=int)
def setuid(space, arg):
""" setuid(uid)
@@ -835,7 +840,7 @@
raise wrap_oserror(space, e)
return space.w_None
- at unwrap_spec(arg=c_nonnegint)
+ at unwrap_spec(arg=c_uid_t)
def seteuid(space, arg):
""" seteuid(uid)
@@ -847,7 +852,7 @@
raise wrap_oserror(space, e)
return space.w_None
- at unwrap_spec(arg=c_nonnegint)
+ at unwrap_spec(arg=c_gid_t)
def setgid(space, arg):
""" setgid(gid)
@@ -859,7 +864,7 @@
raise wrap_oserror(space, e)
return space.w_None
- at unwrap_spec(arg=c_nonnegint)
+ at unwrap_spec(arg=c_gid_t)
def setegid(space, arg):
""" setegid(gid)
@@ -960,7 +965,7 @@
raise wrap_oserror(space, e)
return space.w_None
- at unwrap_spec(ruid=c_int, euid=c_int)
+ at unwrap_spec(ruid=c_uid_t, euid=c_uid_t)
def setreuid(space, ruid, euid):
""" setreuid(ruid, euid)
@@ -972,7 +977,7 @@
raise wrap_oserror(space, e)
return space.w_None
- at unwrap_spec(rgid=c_int, egid=c_int)
+ at unwrap_spec(rgid=c_gid_t, egid=c_gid_t)
def setregid(space, rgid, egid):
""" setregid(rgid, egid)
@@ -1056,7 +1061,7 @@
except OSError, e:
raise wrap_oserror(space, e)
- at unwrap_spec(path=str, uid=c_int, gid=c_int)
+ at unwrap_spec(path=str, uid=c_uid_t, gid=c_gid_t)
def chown(space, path, uid, gid):
try:
os.chown(path, uid, gid)
@@ -1064,7 +1069,7 @@
raise wrap_oserror(space, e, path)
return space.w_None
- at unwrap_spec(path=str, uid=c_int, gid=c_int)
+ at unwrap_spec(path=str, uid=c_uid_t, gid=c_gid_t)
def lchown(space, path, uid, gid):
try:
os.lchown(path, uid, gid)
More information about the Pypy-commit
mailing list