def main(n): assert n >= 0 pattern = [n] * n string = chr(n) * n rsre_core.search(pattern, string) # unicodestr = unichr(n) * n ctx = rsre_core.UnicodeMatchContext(pattern, unicodestr, 0, len(unicodestr), 0) rsre_core.search_context(ctx) # return 0
def searchcontext(space, ctx): try: return rsre_core.search_context(ctx) except rsre_core.Error, e: raise OperationError(space.w_RuntimeError, space.wrap(e.msg))