coleifer / micawber

a small library for extracting rich content from urls
http://micawber.readthedocs.org/
MIT License
635 stars 91 forks source link

add python 3 compatibility. all tests pass #46

Closed mgaitan closed 9 years ago

mgaitan commented 9 years ago

This patch fix the python3.4 compatibility. All tests pass. Fix #45

coleifer commented 9 years ago

Why is the call to list() necessary there?

mgaitan commented 9 years ago

because in python3(.4) you can't use reversed over a non-sequence iterable. all test fails like this

ERROR: test_register_unregister (micawber.tests.ProviderTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tin/lab/micawber/micawber/tests.py", line 19, in test_register_unregister
    self.assertEqual(pr.provider_for_url('1'), provider1)
  File "/home/tin/lab/micawber/micawber/providers.py", line 136, in provider_for_url
    for regex, provider in self:
  File "/home/tin/lab/micawber/micawber/providers.py", line 133, in __iter__
    return iter(reversed(self._registry.items()))
TypeError: argument to reversed() must be a sequence

why you are reversing them, btw?

coleifer commented 9 years ago

Thanks for this!