[pypy-commit] pypy faster-rstruct-2: I don't know why this popped out now as it seems unrelated with my recent changes: scoped_nonmovingbuffer expects data to be non-null, so we enforce the annotation to get an early error. Then, we fix the problem in interp_bz2.py
antocuni
pypy.commits at gmail.com
Thu May 11 05:03:54 EDT 2017
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: faster-rstruct-2
Changeset: r91240:beae5a5ccb0b
Date: 2017-05-11 10:03 +0100
http://bitbucket.org/pypy/pypy/changeset/beae5a5ccb0b/
Log: I don't know why this popped out now as it seems unrelated with my
recent changes: scoped_nonmovingbuffer expects data to be non-null,
so we enforce the annotation to get an early error. Then, we fix the
problem in interp_bz2.py
diff --git a/pypy/module/bz2/interp_bz2.py b/pypy/module/bz2/interp_bz2.py
--- a/pypy/module/bz2/interp_bz2.py
+++ b/pypy/module/bz2/interp_bz2.py
@@ -1,4 +1,5 @@
from __future__ import with_statement
+from rpython.annotator import model as annmodel
from rpython.rtyper.tool import rffi_platform as platform
from rpython.rtyper.lltypesystem import rffi
from rpython.rtyper.lltypesystem import lltype
@@ -552,6 +553,7 @@
to compress, call the flush() method to finish the compression process,
and return what is left in the internal buffers."""
+ assert data is not None
datasize = len(data)
if datasize == 0:
@@ -662,6 +664,7 @@
was found after the end of stream, it'll be ignored and saved in
unused_data attribute."""
+ assert data is not None
if not self.running:
raise oefmt(self.space.w_EOFError,
"end of stream was already found")
@@ -715,6 +718,7 @@
use an instance of BZ2Compressor instead. The compresslevel parameter, if
given, must be a number between 1 and 9."""
+ assert data is not None
if compresslevel < 1 or compresslevel > 9:
raise oefmt(space.w_ValueError,
"compresslevel must be between 1 and 9")
@@ -757,6 +761,7 @@
Decompress data in one shot. If you want to decompress data sequentially,
use an instance of BZ2Decompressor instead."""
+ assert data is not None
in_bufsize = len(data)
if in_bufsize == 0:
return space.newbytes("")
diff --git a/rpython/rtyper/lltypesystem/rffi.py b/rpython/rtyper/lltypesystem/rffi.py
--- a/rpython/rtyper/lltypesystem/rffi.py
+++ b/rpython/rtyper/lltypesystem/rffi.py
@@ -1232,8 +1232,11 @@
class scoped_nonmovingbuffer:
+
def __init__(self, data):
self.data = data
+ __init__._annenforceargs_ = [None, annmodel.SomeString(can_be_None=False)]
+
def __enter__(self):
self.buf, self.flag = get_nonmovingbuffer(self.data)
return self.buf
More information about the pypy-commit
mailing list