Esempio n. 1
0
def _create_new_type(space, w_typetype, name, bases_w, dict_w, basicsize):
    pos = surrogate_in_utf8(name)
    if pos >= 0:
        raise oefmt(
            space.w_ValueError, "can't encode character in position "
            "%d, surrogates not allowed", pos)
    w_type = W_HPyTypeObject(space, name, bases_w or [space.w_object], dict_w,
                             basicsize)
    w_type.ready()
    return w_type
Esempio n. 2
0
def test_surrogate_in_utf8(unichars):
    uni = ''.join([u.encode('utf8') for u in unichars])
    result = rutf8.surrogate_in_utf8(uni) >= 0
    expected = any(uch for uch in unichars if u'\ud800' <= uch <= u'\udfff')
    assert result == expected