예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
파일: makers.py 프로젝트: dckc/typhon
 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)))
예제 #4
0
파일: makers.py 프로젝트: zarutian/typhon
 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)))
예제 #5
0
파일: dns.py 프로젝트: markrwilliams/typhon
 def toString(self):
     return u"IP6AddrInfo(%s, %s, %d, %d)" % (bytesToString(self.addr),
                                              self.socktype, self.protocol,
                                              self.flags)
예제 #6
0
 def toString(self):
     return u"IP6AddrInfo(%s, %s, %d, %d)" % (bytesToString(
         self.addr), self.socktype, self.protocol, self.flags)