Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #94271
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: Should non-security 2.7 bugs be fixed? |
| Date | 2015-07-21 01:14 -0400 |
| References | <moenuj$f11$1@ger.gmane.org> <CABicbJ+Fy=Jhj63VnOmS3BJD3He+i3J+P+ASMmjJDMi9X7rt-w@mail.gmail.com> <mof14q$b47$1@ger.gmane.org> <CAKJDb-Mqf7tc9osDBf+pSxjwpdgDDv4zJe8wP+rg+do_axsggA@mail.gmail.com> <moh7pg$bvq$1@ger.gmane.org> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.806.1437455717.3674.python-list@python.org> (permalink) |
On 7/19/2015 6:19 PM, Terry Reedy wrote:
> I, and others, have already made some changes to eliminate differences
> that are unnecessary, at least for 2.7 versus 3.3+ or now 3.4+.
I just got smacked in the face by a difference I had not run into
before. I added about 10 lines to a test file is a section that is
identical in 2.7 and 3.4+. One line is
self.assertEqual(type(obj), intended class)
It failed in 2.7.
Quiz: when is the type of an instance not the class that the instance is
an instance of. (I expect Steven A. is raising his hand now.)
Give up?
Answer: When you write a class in 2.x without making it a subclass of
object.
>>> class Class():
pass
>>> inst = Class()
>>> type(inst) is Class
False
>>> type(inst)
<type 'instance'>
Since I do not remember how to fix the assert, and was not prepared to
make the class, in a file other than the one tested, new-style, I just
commented it out.
This is an example of my claim that backports are best written by
someone who is a current 2.x user with the particular 2.x knowledge
needed. I am not sure I ever had all the knowledge needed to handle the
backport properly and I now I would prefer to forget about old-style
classes.
--
Terry Jan Reedy
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Should non-security 2.7 bugs be fixed? Terry Reedy <tjreedy@udel.edu> - 2015-07-21 01:14 -0400
csiph-web