Commits

Brian Kearns committed 9d7094c Merge

merge default

Comments (0)

Files changed (2)

pypy/module/_codecs/test/test_codecs.py

     def test_unicodedecodeerror(self):
         assert str(UnicodeDecodeError(
             "ascii", "g\xfcrk", 1, 2, "ouch")) == "'ascii' codec can't decode byte 0xfc in position 1: ouch"
-        
+
         assert str(UnicodeDecodeError(
             "ascii", "g\xfcrk", 1, 3, "ouch")) == "'ascii' codec can't decode bytes in position 1-2: ouch"
-        
 
     def test_unicodetranslateerror(self):
         import sys
         assert str(UnicodeTranslateError(
             u"g\xfcrk", 1, 2, "ouch"))== "can't translate character u'\\xfc' in position 1: ouch"
-        
+
         assert str(UnicodeTranslateError(
             u"g\u0100rk", 1, 2, "ouch"))== "can't translate character u'\\u0100' in position 1: ouch"
-        
+
         assert str(UnicodeTranslateError(
             u"g\uffffrk", 1, 2, "ouch"))== "can't translate character u'\\uffff' in position 1: ouch"
-        
+
         if sys.maxunicode > 0xffff and len(unichr(0x10000)) == 1:
             assert str(UnicodeTranslateError(
                 u"g\U00010000rk", 1, 2, "ouch"))== "can't translate character u'\\U00010000' in position 1: ouch"
-            
+
         assert str(UnicodeTranslateError(
             u"g\xfcrk", 1, 3, "ouch"))=="can't translate characters in position 1-2: ouch"
 
         import sys
         assert str(UnicodeEncodeError(
             "ascii", u"g\xfcrk", 1, 2, "ouch"))=="'ascii' codec can't encode character u'\\xfc' in position 1: ouch"
-            
+
         assert str(UnicodeEncodeError(
             "ascii", u"g\xfcrk", 1, 4, "ouch"))== "'ascii' codec can't encode characters in position 1-3: ouch"
-            
+
         assert str(UnicodeEncodeError(
             "ascii", u"\xfcx", 0, 1, "ouch"))=="'ascii' codec can't encode character u'\\xfc' in position 0: ouch"
 
         assert str(UnicodeEncodeError(
             "ascii", u"\u0100x", 0, 1, "ouch"))=="'ascii' codec can't encode character u'\\u0100' in position 0: ouch"
-       
+
         assert str(UnicodeEncodeError(
             "ascii", u"\uffffx", 0, 1, "ouch"))=="'ascii' codec can't encode character u'\\uffff' in position 0: ouch"
         if sys.maxunicode > 0xffff and len(unichr(0x10000)) == 1:
             assert str(UnicodeEncodeError(
                 "ascii", u"\U00010000x", 0, 1, "ouch")) =="'ascii' codec can't encode character u'\\U00010000' in position 0: ouch"
-    
+
     def test_indexerror(self):
         test =   "\\"     # trailing backslash
         raises (ValueError, test.decode,'string-escape')
                 u"\x00\xff\u07ff\u0800",
                 u"\x00\xff\u07ff\u0800\uffff",
             ]
-            
+
         buffer = ''
         result = u""
         for (c, partialresult) in zip(u"\x00\xff\u07ff\u0800\uffff".encode(encoding), check_partial):
             assert result == partialresult
 
     def test_bug1098990_a(self):
-
         import codecs, StringIO
         self.encoding = 'utf-8'
         s1 = u"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\r\n"
         s2 = u"offending line: ladfj askldfj klasdj fskla dfzaskdj fasklfj laskd fjasklfzzzzaa%whereisthis!!!\r\n"
         s3 = u"next line.\r\n"
-       
+
         s = (s1+s2+s3).encode(self.encoding)
         stream = StringIO.StringIO(s)
         reader = codecs.getreader(self.encoding)(stream)
         assert reader.readline() == s3
         assert reader.readline() == s4
         assert reader.readline() == s5
-        assert reader.readline() == u""    
-    
+        assert reader.readline() == u""
+
     def test_seek_utf16le(self):
         # all codecs should be able to encode these
         import codecs, StringIO
             line = reader.readline()
             assert s[:len(line)] == line
 
-
     def test_unicode_internal_encode(self):
         import sys
         class U(unicode):
         assert '\\0f'.decode('string_escape') == chr(0) + 'f'
         assert '\\08'.decode('string_escape') == chr(0) + '8'
 
+    def test_escape_decode_errors(self):
+        raises(ValueError, br"\x".decode, 'string_escape')
+        raises(ValueError, br"[\x]".decode, 'string_escape')
+        raises(ValueError, br"\x0".decode, 'string_escape')
+        raises(ValueError, br"[\x0]".decode, 'string_escape')
+
     def test_escape_encode(self):
         assert '"'.encode('string_escape') == '"'
         assert "'".encode('string_escape') == "\\'"

rpython/jit/backend/arm/opassembler.py

 from rpython.jit.backend.llsupport.descr import InteriorFieldDescr
 from rpython.jit.backend.llsupport.assembler import GuardToken, BaseAssembler
 from rpython.jit.metainterp.history import (Box, AbstractFailDescr,
-                                            INT, FLOAT)
+                                            INT, FLOAT, REF)
 from rpython.jit.metainterp.history import TargetToken
 from rpython.jit.metainterp.resoperation import rop
 from rpython.rlib.objectmodel import we_are_translated
         self.mc.gen_load_int(r.ip.value, fail_descr_loc.value)
         # XXX self.mov(fail_descr_loc, RawStackLoc(ofs))
         self.store_reg(self.mc, r.ip, r.fp, ofs, helper=r.lr)
-        gcmap = self.gcmap_for_finish
-        self.push_gcmap(self.mc, gcmap, store=True)
+        if op.numargs() > 0 and op.getarg(0).type == REF:
+            gcmap = self.gcmap_for_finish
+            self.push_gcmap(self.mc, gcmap, store=True)
+        else:
+            # note that the 0 here is redundant, but I would rather
+            # keep that one and kill all the others
+            ofs = self.cpu.get_ofs_of_frame_field('jf_gcmap')
+            self.mc.gen_load_int(r.ip.value, 0)
+            self.store_reg(self.mc, r.ip, r.fp, ofs)
         self.mc.MOV_rr(r.r0.value, r.fp.value)
         # exit function
         self.gen_func_epilog()