[pypy-commit] pypy faster-rstruct-2: if we don't ensure that StringBuffer.value is not None, the annotator crashes as soon as you call str2chap(buf.as_str()). There are lots of places which do the assert before calling StringBuffer(), but I think it's simpler and better to just do it in the __init__, as it has no chances to work if value is None

antocuni pypy.commits at gmail.com
Fri May 5 11:29:35 EDT 2017


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: faster-rstruct-2
Changeset: r91185:037cc12c66ea
Date: 2017-05-05 15:29 +0000
http://bitbucket.org/pypy/pypy/changeset/037cc12c66ea/

Log:	if we don't ensure that StringBuffer.value is not None, the
	annotator crashes as soon as you call str2chap(buf.as_str()). There
	are lots of places which do the assert before calling
	StringBuffer(), but I think it's simpler and better to just do it in
	the __init__, as it has no chances to work if value is None

diff --git a/rpython/rlib/buffer.py b/rpython/rlib/buffer.py
--- a/rpython/rlib/buffer.py
+++ b/rpython/rlib/buffer.py
@@ -95,6 +95,7 @@
     _immutable_ = True
 
     def __init__(self, value):
+        assert value  is not None
         self.value = value
         self.readonly = 1
 


More information about the pypy-commit mailing list