diff options
| author | Jack Nagel | 2013-07-22 11:41:46 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-07-22 11:41:46 -0500 |
| commit | 90ec8297d3bc35de1c3dc46b611f0449dacf6917 (patch) | |
| tree | bac0fe192e32861e8e4c3dfd2bc4d01a0e7cc11d /Library/Homebrew/requirements/python_dependency.rb | |
| parent | 0b77b3a1349efd539c3a1e3eb6a38bcb0f5f7fba (diff) | |
| download | homebrew-90ec8297d3bc35de1c3dc46b611f0449dacf6917.tar.bz2 | |
Fix python dependency hash equality
eql? should not depend on the hash value as hash values of uneql objects
can collide, but eql values may only collide for objects that are
actually eql.
Further, python dependencies are uniquely identified by the combination
of the name and imports attributes, so there is no reason to involved
the expensive binary computation for simple equality checks.
Fixes #20840.
Diffstat (limited to 'Library/Homebrew/requirements/python_dependency.rb')
| -rw-r--r-- | Library/Homebrew/requirements/python_dependency.rb | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Library/Homebrew/requirements/python_dependency.rb b/Library/Homebrew/requirements/python_dependency.rb index 1fb0730da..3e6206857 100644 --- a/Library/Homebrew/requirements/python_dependency.rb +++ b/Library/Homebrew/requirements/python_dependency.rb @@ -16,6 +16,7 @@ require 'requirement' class PythonInstalled < Requirement attr_reader :min_version attr_reader :if3then3 + attr_reader :imports attr_accessor :site_packages attr_accessor :binary # The python.rb formula needs to set the binary @@ -342,15 +343,14 @@ class PythonInstalled < Requirement binary.to_s end + # Objects of this class are used to represent dependencies on Python and + # dependencies on Python modules, so the combination of name + imports is + # enough to identify them uniquely. def eql?(other) - instance_of?(other.class) && hash == other.hash + instance_of?(other.class) && name == other.name && imports == other.imports end def hash - # Requirements are a ComparableSet. So we define our identity by the - # selected python binary plus the @imports in order to support multiple: - # depends_on :python => 'module1' - # depends_on :python => 'module2' - (binary.to_s+@imports.to_s).hash + [name, *imports].hash end end |
