Author: Armin Rigo <[email protected]>
Branch: release-1.1
Changeset: r2167:ad072efcccfd
Date: 2015-06-07 15:13 +0200
http://bitbucket.org/cffi/cffi/changeset/ad072efcccfd/
Log: Some details
diff --git a/c/lib_obj.c b/c/lib_obj.c
--- a/c/lib_obj.c
+++ b/c/lib_obj.c
@@ -300,7 +300,7 @@
case _CFFI_OP_GLOBAL_VAR:
{
/* global variable of the exact type specified here */
- size_t g_size = (size_t)g->size_or_direct_fn;
+ Py_ssize_t g_size = (Py_ssize_t)g->size_or_direct_fn;
ct = realize_c_type(types_builder, types_builder->ctx.types,
_CFFI_GETARG(g->type_op));
if (ct == NULL)
diff --git a/c/realize_c_type.c b/c/realize_c_type.c
--- a/c/realize_c_type.c
+++ b/c/realize_c_type.c
@@ -60,7 +60,7 @@
static void free_builder_c(builder_c_t *builder, int ctx_is_static)
{
if (!ctx_is_static) {
- int i;
+ size_t i;
const void *mem[] = {builder->ctx.types,
builder->ctx.globals,
builder->ctx.struct_unions,
diff --git a/testing/cffi0/test_zintegration.py
b/testing/cffi0/test_zintegration.py
--- a/testing/cffi0/test_zintegration.py
+++ b/testing/cffi0/test_zintegration.py
@@ -1,5 +1,4 @@
import py, os, sys, shutil
-import imp
import subprocess
from testing.udir import udir
@@ -15,28 +14,12 @@
except OSError as e:
py.test.skip("Cannot execute virtualenv: %s" % (e,))
- try:
- deepcopy = os.symlink
- except:
- import shutil, errno
- def deepcopy(src, dst):
- try:
- shutil.copytree(src, dst)
- except OSError as e:
- if e.errno in (errno.ENOTDIR, errno.EINVAL):
- shutil.copy(src, dst)
- else:
- print('got errno')
- print(e.errno)
- print('not')
- print(errno.ENOTDIR)
- raise
-
site_packages = None
for dirpath, dirnames, filenames in os.walk(str(tmpdir)):
if os.path.basename(dirpath) == 'site-packages':
site_packages = dirpath
break
+ paths = ""
if site_packages:
try:
from cffi import _pycparser
@@ -49,15 +32,22 @@
pass
else:
modules += ('ply',) # needed for older versions of pycparser
+ paths = []
for module in modules:
- target = imp.find_module(module)[1]
- deepcopy(target, os.path.join(site_packages,
- os.path.basename(target)))
- return tmpdir
+ target = __import__(module, None, None, [])
+ src = os.path.abspath(target.__file__)
+ for end in ['__init__.pyc', '__init__.pyo', '__init__.py']:
+ if src.lower().endswith(end):
+ src = src[:-len(end)-1]
+ break
+ paths.append(os.path.dirname(src))
+ paths = os.pathsep.join(paths)
+ return tmpdir, paths
SNIPPET_DIR = py.path.local(__file__).join('..', 'snippets')
-def really_run_setup_and_program(dirname, venv_dir, python_snippet):
+def really_run_setup_and_program(dirname, venv_dir_and_paths, python_snippet):
+ venv_dir, paths = venv_dir_and_paths
def remove(dir):
dir = str(SNIPPET_DIR.join(dirname, dir))
shutil.rmtree(dir, ignore_errors=True)
@@ -75,9 +65,11 @@
else:
bindir = 'bin'
vp = str(venv_dir.join(bindir).join('python'))
- subprocess.check_call((vp, 'setup.py', 'clean'))
- subprocess.check_call((vp, 'setup.py', 'install'))
- subprocess.check_call((vp, str(python_f)))
+ env = os.environ.copy()
+ env['PYTHONPATH'] = paths
+ subprocess.check_call((vp, 'setup.py', 'clean'), env=env)
+ subprocess.check_call((vp, 'setup.py', 'install'), env=env)
+ subprocess.check_call((vp, str(python_f)), env=env)
finally:
os.chdir(olddir)
diff --git a/testing/cffi1/test_ffi_obj.py b/testing/cffi1/test_ffi_obj.py
--- a/testing/cffi1/test_ffi_obj.py
+++ b/testing/cffi1/test_ffi_obj.py
@@ -159,9 +159,10 @@
"struct never_heard_of_s\n"
" ^")
e = py.test.raises(ffi.error, ffi.cast, "\t\n\x01\x1f~\x7f\x80\xff", 0)
+ marks = "?" if sys.version_info < (3,) else "??"
assert str(e.value) == ("identifier expected\n"
- " ??~???\n"
- " ^")
+ " ??~?%s%s\n"
+ " ^" % (marks, marks))
e = py.test.raises(ffi.error, ffi.cast, "X" * 600, 0)
assert str(e.value) == ("undefined type name")
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit