Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look up by bytes fails #35

Open
rjschwei opened this issue Mar 15, 2021 · 0 comments
Open

Look up by bytes fails #35

rjschwei opened this issue Mar 15, 2021 · 0 comments

Comments

@rjschwei
Copy link
Contributor

The byte lookup is coded for Little Endian systems and breaks on Big Endian machines, yes S390 is alive and kicking.

 self = <test.PyTriciaTests testMethod=testNonStringKey>
 
    def testNonStringKey(self):
         pyt = pytricia.PyTricia()
    
        # insert as string
        pyt['10.1.2.3/24'] = 'abc'
     
        # lookup as string
        for i in range(256):
             self.assertEqual(pyt['10.1.2.{}'.format(i)], 'abc')
     
        # lookup as bytes (or, ugh, another str in python2)
        b = socket.inet_aton('10.1.2.3')
        self.assertEqual(pyt[b], 'abc')
     
        # bytes in py3k.  python2 stinks.
        if sys.version_info.major == 3 and sys.version_info.minor >= 4:
            i = b[0] * 2**24 + b[1] * 2**16 + b[2] * 2**8
            for j in range(256):
>               self.assertEqual(pyt[i+j], 'abc')
E               KeyError: 'Prefix not found.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant