Beispiel #1
0
 def __init__(self, space, fields, size, alignment, is_union=False, pack=0):
     name_to_index = {}
     if fields is not None:
         for i in range(len(fields)):
             name, tp, bitsize = fields[i]
             if name in name_to_index:
                 raise oefmt(space.w_ValueError, "duplicate field name %s",
                             name)
             try:
                 rutf8.check_ascii(name)
             except rutf8.CheckError:
                 raise oefmt(space.w_TypeError, 'non-ascii field name')
             name_to_index[name] = i
         size, alignment, pos, bitsizes = size_alignment_pos(
             fields, is_union, pack)
     else:  # opaque case
         fields = []
         pos = []
         bitsizes = None
     self.fields = fields
     self.size = size
     self.alignment = alignment
     self.ll_positions = pos
     self.ll_bitsizes = bitsizes
     self.name_to_index = name_to_index
Beispiel #2
0
 def f(x, y):
     z = 0
     while z < 10:
         jitdriver.jit_merge_point(x=x, y=y, z=z)
         if x > 0:
             s = "abc"
         else:
             s = "def"
         check_ascii(s)
         z += 1
     return 0
Beispiel #3
0
def test_check_ascii(s):
    raised = False
    try:
        s.decode('ascii')
    except UnicodeDecodeError as e:
        raised = True
    try:
        rutf8.check_ascii(s)
    except rutf8.CheckError:
        assert raised
    else:
        assert not raised