mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
675b7da4ed
OptionValue and its derived classes are exposed to moz.configure files. As the previous bug fix showed, it is really easy to accidentally assume the type is a simple string value and do a string compare against it. To prevent this class of bugs, this commit adds additional type awareness to OptionValue.__eq__. We first check that the argument is a tuple (including any OptionValue types). If not, we raise a TypeError because the comparison is invalid. This is arguably a violation of __eq__. But since OptionValue is exposed to the moz.configure sandbox and typing '==' will invoke __eq__, we have to do something to prevent this foot gun. The change also changes the comparison logic. If we compare against a non-derived tuple instance, we do a tuple compare. Otherwise, we fall back to the previous logic of requiring an identical type then doing a tuple compare. MozReview-Commit-ID: 7IVSL2Asg9j --HG-- extra : rebase_source : edab573834da240df9ad7c2fc78c85d6159a6ef9 |
||
---|---|---|
.. | ||
devtools/migrate-l10n | ||
mach | ||
mozboot | ||
mozbuild | ||
mozlint | ||
mozversioncontrol/mozversioncontrol | ||
mach_commands.py | ||
moz.build | ||
README |
This directory contains common Python code. The basic rule is that if Python code is cross-module (that's "module" in the Mozilla meaning - as in "module ownership") and is MPL-compatible, it should go here. What should not go here: * Vendored python modules (use third_party/python instead) * Python that is not MPL-compatible (see other-licenses/) * Python that has good reason to remain close to its "owning" (Mozilla) module (e.g. it is only being consumed from there). Historical information can be found at https://bugzilla.mozilla.org/show_bug.cgi?id=775243 https://bugzilla.mozilla.org/show_bug.cgi?id=1346025