def recv(self, atom, args): if atom is RUN_1: return IntObject(int(unwrapStr(args[0]).encode('utf-8'))) if atom is RUN_2: inp = unwrapStr(args[0]) radix = unwrapInt(args[1]) try: v = int(inp.encode("utf-8"), radix) except ValueError: raise userError(u"Invalid literal for base %d: %s" % ( radix, inp)) return IntObject(v) if atom is FROMBYTES_1: return IntObject(int(unwrapBytes(args[0]))) if atom is FROMBYTES_2: bs = unwrapBytes(args[0]) radix = unwrapInt(args[1]) try: v = int(bs, radix) except ValueError: raise userError(u"Invalid literal for base %d: %s" % ( radix, bytesToString(bs))) return IntObject(v) raise Refused(self, atom, args)
def recv(self, atom, args): if atom is RUN_1: return IntObject(int(unwrapStr(args[0]).encode('utf-8'))) if atom is RUN_2: inp = unwrapStr(args[0]) radix = unwrapInt(args[1]) try: v = int(inp.encode("utf-8"), radix) except ValueError: raise userError(u"Invalid literal for base %d: %s" % (radix, inp)) return IntObject(v) if atom is FROMBYTES_1: return IntObject(int(unwrapBytes(args[0]))) if atom is FROMBYTES_2: bs = unwrapBytes(args[0]) radix = unwrapInt(args[1]) try: v = int(bs, radix) except ValueError: raise userError(u"Invalid literal for base %d: %s" % (radix, bytesToString(bs))) return IntObject(v) raise Refused(self, atom, args)
def fromBytes(self, bs, ej): # Ruby-style underscores are legal here but can't be handled by # RPython, so remove them. bs = ''.join([c for c in bs if c != '_']) try: return rbigint.fromstr(bs, self.radix) except ParseStringError: throwStr(ej, u"_makeInt: Couldn't make int in radix %d from %s" % (self.radix, bytesToString(bs)))
def toString(self): return u"IP6AddrInfo(%s, %s, %d, %d)" % (bytesToString(self.addr), self.socktype, self.protocol, self.flags)
def toString(self): return u"IP6AddrInfo(%s, %s, %d, %d)" % (bytesToString( self.addr), self.socktype, self.protocol, self.flags)