[Python-3000] backported ABC
Benjamin Aranguren
baranguren at gmail.com
Mon Sep 3 16:59:33 CEST 2007
I am having a problem backporting collections.py/_abcoll.py and would
like to get your input.
There's one test in test_collections that fails.
class TestOneTrickPonyABCs(unittest.TestCase):
def test_Hashable(self):
# Check some non-hashables
non_samples = [list(), set(), dict()]
for x in non_samples:
self.failIf(isinstance(x, Hashable), repr(x))
self.failIf(issubclass(type(x), Hashable), repr(type(x)))
The problem is list, set, dict all has __hash__ function so isinstance
and issubclass returns true even though none of list, set, and dict
was registered as a subclass of Hashable.
But, calling x.__hash__() on these types results to a TypeError: list
objects are unhashable.
Thanks!
On 8/26/07, Benjamin Aranguren <baranguren at gmail.com> wrote:
> I got it now. both modules need to be backported as well. I'm on it.
>
> On 8/26/07, Benjamin Aranguren <baranguren at gmail.com> wrote:
> > No problem. Created issue 1026 in tracker with a single patch file attached.
> >
> > I'm not aware of what changes need to be done with _abcoll.py and
> > collections.py. If you can point me to the right direction, I would
> > definitely like to work on it.
> >
> > On 8/26/07, Guido van Rossum <guido at python.org> wrote:
> > > Thanks!
> > >
> > > Would it inconvenience you terribly to upload this all to the new
> > > tracker (bugs.python.org)? Preferably as a single patch against the
> > > svn trunk (to use svn diff, you have to svn add the new files first!)
> > >
> > > Also, are you planning to work on _abcoll.py and the changes to collections.py?
> > >
> > > --Guido
> > >
> > > On 8/26/07, Benjamin Aranguren <baranguren at gmail.com> wrote:
> > > > We copied abc.py and test_abc.py from py3k svn and modified to work with 2.6.
> > > >
> > > > After making all the changes we ran all the tests to ensure that no
> > > > other modules were affected.
> > > >
> > > > Attached are abc.py, test_abc.py, and their relevant patches from 3.0 to 2.6.
> > > >
> > > > On 8/25/07, Guido van Rossum <guido at python.org> wrote:
> > > > > Um, that patch contains only the C code for overloading isinstance()
> > > > > and issubclass().
> > > > >
> > > > > Did you do anything about abc.py and _abcoll.py/collections.py and
> > > > > their respective unit tests? Or what about the unit tests for
> > > > > isinstance()/issubclass()?
> > > > >
> > > > > On 8/25/07, Benjamin Aranguren <baranguren at gmail.com> wrote:
> > > > > > Worked with Alex Martelli at the Goolge Python Sprint.
> > > > >
> > > > > --
> > > > > --Guido van Rossum (home page: http://www.python.org/~guido/)
> > > > >
> > > >
> > > >
> > >
> > >
> > > --
> > > --Guido van Rossum (home page: http://www.python.org/~guido/)
> > >
> >
>
More information about the Python-3000
mailing list