[Python-3000] backported ABC

Benjamin Aranguren baranguren at gmail.com
Tue Sep 4 05:37:00 CEST 2007


Thanks!  This helps.

I was just not sure if I was on the right track or not.  I did try
disabling &list_nohash in listobject.c

I think I have the right idea and just needed some reassurance.  I'll
give it another try.

Thanks again.

On 9/3/07, Guido van Rossum <guido at python.org> wrote:
> You're going to have to do some spelunking in the 3.0 source (because
> I don't have time right now :-), but I think 3.0 has some magic that
> solves this. I *think* it is done by not inheriting tp_hash unless
> tp_richcompare is also inherited. The details are probably in
> typeobject.c.
>
> Ask me again tomorrow if you can't figure it out.
>
> --Guido
>
> On 9/3/07, Benjamin Aranguren <baranguren at gmail.com> wrote:
> > 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/)
> > > > >
> > > >
> > >
> > _______________________________________________
> > Python-3000 mailing list
> > Python-3000 at python.org
> > http://mail.python.org/mailman/listinfo/python-3000
> > Unsubscribe: http://mail.python.org/mailman/options/python-3000/guido%40python.org
> >
>
>
> --
> --Guido van Rossum (home page: http://www.python.org/~guido/)
>


More information about the Python-3000 mailing list