Changeset 89808 in webkit


Ignore:
Timestamp:
Jun 27, 2011 1:41:55 AM (13 years ago)
Author:
eric@webkit.org
Message:

2011-06-27 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.

Remove evil uses of hasattr
https://bugs.webkit.org/show_bug.cgi?id=63430

For some reason these classes believe that they may be called with
various flavors of "option" elements and so carefully check to make
sure that the options element has their option before checking it.

We had a set_option_default method which was never called, so I made it
do what callsites seemed to want it to do and replaced 3 callers
who previously used hasattr manually to use set_option_default instead.

  • Scripts/webkitpy/layout_tests/port/base.py:
  • Scripts/webkitpy/layout_tests/port/webkit.py:
Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r89802 r89808  
     12011-06-27  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Remove evil uses of hasattr
     6        https://bugs.webkit.org/show_bug.cgi?id=63430
     7
     8        For some reason these classes believe that they may be called with
     9        various flavors of "option" elements and so carefully check to make
     10        sure that the options element has their option before checking it.
     11
     12        We had a set_option_default method which was never called, so I made it
     13        do what callsites seemed to want it to do and replaced 3 callers
     14        who previously used hasattr manually to use set_option_default instead.
     15
     16        * Scripts/webkitpy/layout_tests/port/base.py:
     17        * Scripts/webkitpy/layout_tests/port/webkit.py:
     18
    1192011-06-27  Kent Tamura  <tkent@chromium.org>
    220
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py

    r89798 r89808  
    137137        self._pretty_patch_available = None
    138138
    139         if not hasattr(self._options, 'configuration') or self._options.configuration is None:
    140             self._options.configuration = self.default_configuration()
     139        self.set_option_default('configuration', self.default_configuration())
    141140        self._test_configuration = None
    142141        self._multiprocessing_is_available = (multiprocessing is not None)
    143142        self._results_directory = None
    144 
    145         if not hasattr(self._options, 'use_apache') or self._options.use_apache is None:
    146             self._options.use_apache = self._default_to_apache()
     143        self.set_option_default('use_apache', self._default_to_apache())
    147144
    148145    def wdiff_available(self):
     
    583580
    584581    def set_option_default(self, name, default_value):
    585         if not hasattr(self._options, name):
     582        # FIXME: Callers could also use optparse_parser.Values.ensure_value,
     583        # since this should always be a optparse_parser.Values object.
     584        if not hasattr(self._options, name) or getattr(self._options, name) is None:
    586585            return setattr(self._options, name, default_value)
    587586
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit.py

    r88986 r89808  
    5656        self._cached_apache_path = None
    5757
    58         # FIXME: disable pixel tests until they are run by default on the
    59         # build machines.
    60         if not hasattr(self._options, "pixel_tests") or self._options.pixel_tests == None:
    61             self._options.pixel_tests = False
     58        # FIXME: disable pixel tests until they are run by default on the build machines.
     59        self.set_option_default("pixel_tests", False)
    6260
    6361    def baseline_search_path(self):
Note: See TracChangeset for help on using the changeset viewer.