[pypy-commit] pypy result-in-resops: merge default again
fijal
noreply at buildbot.pypy.org
Tue Aug 28 13:36:00 CEST 2012
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: result-in-resops
Changeset: r56901:49ab8b97e324
Date: 2012-08-28 13:35 +0200
http://bitbucket.org/pypy/pypy/changeset/49ab8b97e324/
Log: merge default again
diff --git a/pypy/conftest.py b/pypy/conftest.py
--- a/pypy/conftest.py
+++ b/pypy/conftest.py
@@ -19,6 +19,17 @@
#
option = None
+
+def braindead_deindent(self):
+ """monkeypatch that wont end up doing stupid in the python tokenizer"""
+ text = '\n'.join(self.lines)
+ short = py.std.textwrap.dedent(text)
+ newsource = py.code.Source()
+ newsource.lines[:] = short.splitlines()
+ return newsource
+
+py.code.Source.deindent = braindead_deindent
+
def pytest_report_header():
return "pytest-%s from %s" %(pytest.__version__, pytest.__file__)
diff --git a/pypy/module/_cffi_backend/newtype.py b/pypy/module/_cffi_backend/newtype.py
--- a/pypy/module/_cffi_backend/newtype.py
+++ b/pypy/module/_cffi_backend/newtype.py
@@ -211,13 +211,13 @@
if is_union:
assert offset == 0
offset = maxsize
- else:
- if offset == 0:
- offset = 1
- offset = (offset + alignment - 1) & ~(alignment-1)
+ offset = (offset + alignment - 1) & ~(alignment-1)
+ # Like C, if the size of this structure would be zero, we compute it
+ # as 1 instead. But for ctypes support, we allow the manually-
+ # specified totalsize to be zero in this case.
if totalsize < 0:
- totalsize = offset
+ totalsize = offset or 1
elif totalsize < offset:
raise operationerrfmt(space.w_TypeError,
"%s cannot be of size %d: there are fields at least "
diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py b/pypy/module/_cffi_backend/test/_backend_test_c.py
--- a/pypy/module/_cffi_backend/test/_backend_test_c.py
+++ b/pypy/module/_cffi_backend/test/_backend_test_c.py
@@ -2035,3 +2035,21 @@
assert d[2][1].offset == sizeof(BInt) * 2
assert d[2][1].bitshift == -1
assert d[2][1].bitsize == -1
+
+def test_sizeof_union():
+ # a union has the largest alignment of its members, and a total size
+ # that is the largest of its items *possibly further aligned* if
+ # another smaller item has a larger alignment...
+ BChar = new_primitive_type("char")
+ BShort = new_primitive_type("short")
+ assert sizeof(BShort) == alignof(BShort) == 2
+ BStruct = new_struct_type("foo")
+ complete_struct_or_union(BStruct, [('a1', BChar),
+ ('a2', BChar),
+ ('a3', BChar)])
+ assert sizeof(BStruct) == 3 and alignof(BStruct) == 1
+ BUnion = new_union_type("u")
+ complete_struct_or_union(BUnion, [('s', BStruct),
+ ('i', BShort)])
+ assert sizeof(BUnion) == 4
+ assert alignof(BUnion) == 2
diff --git a/pypy/module/_io/interp_iobase.py b/pypy/module/_io/interp_iobase.py
--- a/pypy/module/_io/interp_iobase.py
+++ b/pypy/module/_io/interp_iobase.py
@@ -326,13 +326,11 @@
try:
space.call_method(w_iobase, 'flush')
except OperationError, e:
- # if it's an IOError or ValueError, ignore it (ValueError is
- # raised if by chance we are trying to flush a file which has
- # already been closed)
- if not (e.match(space, space.w_IOError) or
- e.match(space, space.w_ValueError)):
- raise
-
+ # Silencing all errors is bad, but getting randomly
+ # interrupted here is equally as bad, and potentially
+ # more frequent (because of shutdown issues).
+ pass
+
class AutoFlusher(object):
More information about the pypy-commit
mailing list