Previously it was called another time via hasattr(), and both calls were
made once for dir(f) and again for dir(f.__class__). This includes a
backport of changing from a list to a set from revision 4dbb315fe667.
I have compared output between pre- and post-patch runs of these tests
to make sure there's nothing missing and nothing broken, on both
Windows and Linux. The only differences I found were actually tests
that were previously *not* run.