Commits

Jason R. Coombs committed acc6c5d

Add compatibility for Python 2.4 when querying the hash name. Fixes #44

Comments (0)

Files changed (5)

 =======
 
 -----
+0.9.6
+-----
+
+* Issue #44: Test failure on Python 2.4 when MD5 hash doesn't have a `.name`
+  attribute.
+
+-----
 0.9.5
 -----
 

setuptools.egg-info/entry_points.txt

-[setuptools.installation]
-eggsecutable = setuptools.command.easy_install:bootstrap
-
-[console_scripts]
-easy_install-3.3 = setuptools.command.easy_install:main
-easy_install = setuptools.command.easy_install:main
-
-[setuptools.file_finders]
-svn_cvs = setuptools.command.sdist:_default_revctrl
-
-[egg_info.writers]
-PKG-INFO = setuptools.command.egg_info:write_pkg_info
-top_level.txt = setuptools.command.egg_info:write_toplevel_names
-entry_points.txt = setuptools.command.egg_info:write_entries
-eager_resources.txt = setuptools.command.egg_info:overwrite_arg
-depends.txt = setuptools.command.egg_info:warn_depends_obsolete
-namespace_packages.txt = setuptools.command.egg_info:overwrite_arg
-requires.txt = setuptools.command.egg_info:write_requirements
-dependency_links.txt = setuptools.command.egg_info:overwrite_arg
-
-[distutils.commands]
-install_egg_info = setuptools.command.install_egg_info:install_egg_info
-egg_info = setuptools.command.egg_info:egg_info
-saveopts = setuptools.command.saveopts:saveopts
-develop = setuptools.command.develop:develop
-test = setuptools.command.test:test
-rotate = setuptools.command.rotate:rotate
-build_py = setuptools.command.build_py:build_py
-register = setuptools.command.register:register
-bdist_rpm = setuptools.command.bdist_rpm:bdist_rpm
-easy_install = setuptools.command.easy_install:easy_install
-install = setuptools.command.install:install
-setopt = setuptools.command.setopt:setopt
-build_ext = setuptools.command.build_ext:build_ext
-upload_docs = setuptools.command.upload_docs:upload_docs
-alias = setuptools.command.alias:alias
-bdist_wininst = setuptools.command.bdist_wininst:bdist_wininst
-sdist = setuptools.command.sdist:sdist
-bdist_egg = setuptools.command.bdist_egg:bdist_egg
-install_scripts = setuptools.command.install_scripts:install_scripts
-install_lib = setuptools.command.install_lib:install_lib
-
-[distutils.setup_keywords]
-zip_safe = setuptools.dist:assert_bool
-test_suite = setuptools.dist:check_test_suite
-use_2to3_exclude_fixers = setuptools.dist:assert_string_list
-test_loader = setuptools.dist:check_importable
-entry_points = setuptools.dist:check_entry_points
-tests_require = setuptools.dist:check_requirements
-package_data = setuptools.dist:check_package_data
-eager_resources = setuptools.dist:assert_string_list
-namespace_packages = setuptools.dist:check_nsp
-include_package_data = setuptools.dist:assert_bool
-extras_require = setuptools.dist:check_extras
-dependency_links = setuptools.dist:assert_string_list
-packages = setuptools.dist:check_packages
-convert_2to3_doctests = setuptools.dist:assert_string_list
-use_2to3 = setuptools.dist:assert_bool
-exclude_package_data = setuptools.dist:check_package_data
-use_2to3_fixers = setuptools.dist:assert_string_list
-install_requires = setuptools.dist:check_requirements
-
+[setuptools.installation]
+eggsecutable = setuptools.command.easy_install:bootstrap
+
+[console_scripts]
+easy_install-3.3 = setuptools.command.easy_install:main
+easy_install = setuptools.command.easy_install:main
+
+[setuptools.file_finders]
+svn_cvs = setuptools.command.sdist:_default_revctrl
+
+[egg_info.writers]
+PKG-INFO = setuptools.command.egg_info:write_pkg_info
+top_level.txt = setuptools.command.egg_info:write_toplevel_names
+entry_points.txt = setuptools.command.egg_info:write_entries
+eager_resources.txt = setuptools.command.egg_info:overwrite_arg
+depends.txt = setuptools.command.egg_info:warn_depends_obsolete
+namespace_packages.txt = setuptools.command.egg_info:overwrite_arg
+requires.txt = setuptools.command.egg_info:write_requirements
+dependency_links.txt = setuptools.command.egg_info:overwrite_arg
+
+[distutils.commands]
+install_egg_info = setuptools.command.install_egg_info:install_egg_info
+egg_info = setuptools.command.egg_info:egg_info
+saveopts = setuptools.command.saveopts:saveopts
+develop = setuptools.command.develop:develop
+test = setuptools.command.test:test
+rotate = setuptools.command.rotate:rotate
+build_py = setuptools.command.build_py:build_py
+register = setuptools.command.register:register
+bdist_rpm = setuptools.command.bdist_rpm:bdist_rpm
+easy_install = setuptools.command.easy_install:easy_install
+install = setuptools.command.install:install
+setopt = setuptools.command.setopt:setopt
+build_ext = setuptools.command.build_ext:build_ext
+upload_docs = setuptools.command.upload_docs:upload_docs
+alias = setuptools.command.alias:alias
+bdist_wininst = setuptools.command.bdist_wininst:bdist_wininst
+sdist = setuptools.command.sdist:sdist
+bdist_egg = setuptools.command.bdist_egg:bdist_egg
+install_scripts = setuptools.command.install_scripts:install_scripts
+install_lib = setuptools.command.install_lib:install_lib
+
+[distutils.setup_keywords]
+zip_safe = setuptools.dist:assert_bool
+test_suite = setuptools.dist:check_test_suite
+use_2to3_exclude_fixers = setuptools.dist:assert_string_list
+test_loader = setuptools.dist:check_importable
+entry_points = setuptools.dist:check_entry_points
+tests_require = setuptools.dist:check_requirements
+package_data = setuptools.dist:check_package_data
+eager_resources = setuptools.dist:assert_string_list
+namespace_packages = setuptools.dist:check_nsp
+include_package_data = setuptools.dist:assert_bool
+extras_require = setuptools.dist:check_extras
+dependency_links = setuptools.dist:assert_string_list
+packages = setuptools.dist:check_packages
+convert_2to3_doctests = setuptools.dist:assert_string_list
+use_2to3 = setuptools.dist:assert_bool
+exclude_package_data = setuptools.dist:check_package_data
+use_2to3_fixers = setuptools.dist:assert_string_list
+install_requires = setuptools.dist:check_requirements
+

setuptools.egg-info/requires.txt

 
 
+[ssl:sys_platform=='win32' and python_version=='2.4']
+ctypes==1.0.2
+
 [ssl:sys_platform=='win32']
 wincertstore==0.1
 
 [certs]
 certifi==0.0.8
 
-[ssl:sys_platform=='win32' and python_version=='2.4']
-ctypes==1.0.2
-
 [ssl:python_version in '2.4, 2.5']
 ssl==1.16

setuptools/package_index.py

     def is_valid(self):
         return self.hash.hexdigest() == self.expected
 
+    def _get_hash_name(self):
+        """
+        Python 2.4 implementation of MD5 doesn't supply a .name attribute
+        so provide that name.
+
+        When Python 2.4 is no longer required, replace invocations of this
+        method with simply 'self.hash.name'.
+        """
+        try:
+            return self.hash.name
+        except AttributeError:
+            if 'md5' in str(type(self.hash)):
+                return 'md5'
+            raise
+
     def report(self, reporter, template):
-        msg = template % self.hash.name
+        msg = template % self._get_hash_name()
         return reporter(msg)
 
 

setuptools/tests/test_packageindex.py

     def test_md5(self):
         checker = setuptools.package_index.HashChecker.from_url(
             'http://foo/bar#md5=f12895fdffbd45007040d2e44df98478')
-        self.assertEqual(checker.hash.name, 'md5')
         checker.feed('You should probably not be using MD5'.encode('ascii'))
         self.assertEqual(checker.hash.hexdigest(),
             'f12895fdffbd45007040d2e44df98478')
             'http://foo/bar#md5=')
         checker.feed('anything'.encode('ascii'))
         self.assertTrue(checker.is_valid())
+
+    def test_get_hash_name_md5(self):
+        checker = setuptools.package_index.HashChecker.from_url(
+            'http://foo/bar#md5=f12895fdffbd45007040d2e44df98478')
+        if sys.version_info >= (2,5):
+            self.assertEqual(checker.hash.name, 'md5')
+        else:
+            # Python 2.4 compatability
+            self.assertEqual(checker._get_hash_name(), 'md5')
+
+    def test_report(self):
+        checker = setuptools.package_index.HashChecker.from_url(
+            'http://foo/bar#md5=f12895fdffbd45007040d2e44df98478')
+        rep = checker.report(lambda x: x, 'My message about %s')
+        self.assertEqual(rep, 'My message about md5')