Should non-security 2.7 bugs be fixed?
Terry Reedy
tjreedy at udel.edu
Tue Jul 21 01:14:48 EDT 2015
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
More information about the Python-list
mailing list