prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  TestDepends.testRequire regression in 41.6.0 (py3)
  While trying to build the new release of setuptools, I get the following test failure:
  
  ```
  ==================================================================== FAILURES =====================================================================
  _____________________________________________________________ TestDepends.testRequire _____________________________________________________________
  
  self = <setuptools.tests.test_setuptools.TestDepends object at 0x7fbfae31d710>
  
      @needs_bytecode
      def testRequire(self):
          req = Require('Json', '1.0.3', 'json')
      
          assert req.name == 'Json'
          assert req.module == 'json'
          assert req.requested_version == '1.0.3'
          assert req.attribute == '__version__'
          assert req.full_name() == 'Json-1.0.3'
      
          from json import __version__
          assert req.get_version() == __version__
          assert req.version_ok('1.0.9')
          assert not req.version_ok('0.9.1')
          assert not req.version_ok('unknown')
      
          assert req.is_present()
          assert req.is_current()
      
          req = Require('Json 3000', '03000', 'json', format=LooseVersion)
          assert req.is_present()
          assert not req.is_current()
          assert not req.version_ok('unknown')
      
          req = Require('Do-what-I-mean', '1.0', 'd-w-i-m')
          assert not req.is_present()
          assert not req.is_current()
      
          req = Require('Tests', None, 'tests', homepage="http://example.com")
          assert req.format is None
          assert req.attribute is None
          assert req.requested_version is None
          assert req.full_name() == 'Tests'
          assert req.homepage == 'http://example.com'
      
          from setuptools.tests import __path__
          paths = [os.path.dirname(p) for p in __path__]
  >       assert req.is_present(paths)
  E       AssertionError: assert False
  E        +  where False = <bound method Require.is_present of <setuptools.depends.Require object at 0x7fbfae0d0b38>>(['/tmp/portage/dev-python/setuptools-41.6.0/work/setuptools-41.6.0-python3_5/setuptools'])
  E        +    where <bound method Require.is_present of <setuptools.depends.Require object at 0x7fbfae0d0b38>> = <setuptools.depends.Require object at 0x7fbfae0d0b38>.is_present
  
  setuptools/tests/test_setuptools.py:120: AssertionError
  ```
  
  I can reproduce it reliably with at least pypy3.6 (7.2.0) & python3.5 (3.5.7). I haven't tested other versions yet.
  
  Full build log: [dev-python:setuptools-41.6.0:20191030-083347.log](https://github.com/pypa/setuptools/files/3787797/dev-python.setuptools-41.6.0.20191030-083347.log)
  
  
  
  </issue>
  <code>
  [start of setuptools/_imp.py]
  1 """
  2 Re-implementation of find_module and get_frozen_object
  3 from the deprecated imp module.
  4 """
  5 
  6 import os
  7 import importlib.util
  8 import importlib.machinery
  9 
  10 from .py34compat import module_from_spec
  11 
  12 
  13 PY_SOURCE = 1
  14 PY_COMPILED = 2
  15 C_EXTENSION = 3
  16 C_BUILTIN = 6
  17 PY_FROZEN = 7
  18 
  19 
  20 def find_module(module, paths=None):
  21     """Just like 'imp.find_module()', but with package support"""
  22     spec = importlib.util.find_spec(module, paths)
  23     if spec is None:
  24         raise ImportError("Can't find %s" % module)
  25     if not spec.has_location and hasattr(spec, 'submodule_search_locations'):
  26         spec = importlib.util.spec_from_loader('__init__.py', spec.loader)
  27 
  28     kind = -1
  29     file = None
  30     static = isinstance(spec.loader, type)
  31     if spec.origin == 'frozen' or static and issubclass(
  32             spec.loader, importlib.machinery.FrozenImporter):
  33         kind = PY_FROZEN
  34         path = None  # imp compabilty
  35         suffix = mode = ''  # imp compability
  36     elif spec.origin == 'built-in' or static and issubclass(
  37             spec.loader, importlib.machinery.BuiltinImporter):
  38         kind = C_BUILTIN
  39         path = None  # imp compabilty
  40         suffix = mode = ''  # imp compability
  41     elif spec.has_location:
  42         path = spec.origin
  43         suffix = os.path.splitext(path)[1]
  44         mode = 'r' if suffix in importlib.machinery.SOURCE_SUFFIXES else 'rb'
  45 
  46         if suffix in importlib.machinery.SOURCE_SUFFIXES:
  47             kind = PY_SOURCE
  48         elif suffix in importlib.machinery.BYTECODE_SUFFIXES:
  49             kind = PY_COMPILED
  50         elif suffix in importlib.machinery.EXTENSION_SUFFIXES:
  51             kind = C_EXTENSION
  52 
  53         if kind in {PY_SOURCE, PY_COMPILED}:
  54             file = open(path, mode)
  55     else:
  56         path = None
  57         suffix = mode = ''
  58 
  59     return file, path, (suffix, mode, kind)
  60 
  61 
  62 def get_frozen_object(module, paths=None):
  63     spec = importlib.util.find_spec(module, paths)
  64     if not spec:
  65         raise ImportError("Can't find %s" % module)
  66     return spec.loader.get_code(module)
  67 
  68 
  69 def get_module(module, paths, info):
  70     spec = importlib.util.find_spec(module, paths)
  71     if not spec:
  72         raise ImportError("Can't find %s" % module)
  73     return module_from_spec(spec)
  74
  [end of setuptools/_imp.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/setuptools/_imp.py b/setuptools/_imp.py
  --- a/setuptools/_imp.py
  +++ b/setuptools/_imp.py
  @@ -17,9 +17,18 @@
   PY_FROZEN = 7
   
   
  +def find_spec(module, paths):
  +    finder = (
  +        importlib.machinery.PathFinder().find_spec
  +        if isinstance(paths, list) else
  +        importlib.util.find_spec
  +    )
  +    return finder(module, paths)
  +
  +
   def find_module(module, paths=None):
       """Just like 'imp.find_module()', but with package support"""
  -    spec = importlib.util.find_spec(module, paths)
  +    spec = find_spec(module, paths)
       if spec is None:
           raise ImportError("Can't find %s" % module)
       if not spec.has_location and hasattr(spec, 'submodule_search_locations'):
  @@ -60,14 +69,14 @@
   
   
   def get_frozen_object(module, paths=None):
  -    spec = importlib.util.find_spec(module, paths)
  +    spec = find_spec(module, paths)
       if not spec:
           raise ImportError("Can't find %s" % module)
       return spec.loader.get_code(module)
   
   
   def get_module(module, paths, info):
  -    spec = importlib.util.find_spec(module, paths)
  +    spec = find_spec(module, paths)
       if not spec:
           raise ImportError("Can't find %s" % module)
       return module_from_spec(spec)
  
verification_info: {"golden_diff": "diff --git a/setuptools/_imp.py b/setuptools/_imp.py\n--- a/setuptools/_imp.py\n+++ b/setuptools/_imp.py\n@@ -17,9 +17,18 @@\n PY_FROZEN = 7\n \n \n+def find_spec(module, paths):\n+    finder = (\n+        importlib.machinery.PathFinder().find_spec\n+        if isinstance(paths, list) else\n+        importlib.util.find_spec\n+    )\n+    return finder(module, paths)\n+\n+\n def find_module(module, paths=None):\n     \"\"\"Just like 'imp.find_module()', but with package support\"\"\"\n-    spec = importlib.util.find_spec(module, paths)\n+    spec = find_spec(module, paths)\n     if spec is None:\n         raise ImportError(\"Can't find %s\" % module)\n     if not spec.has_location and hasattr(spec, 'submodule_search_locations'):\n@@ -60,14 +69,14 @@\n \n \n def get_frozen_object(module, paths=None):\n-    spec = importlib.util.find_spec(module, paths)\n+    spec = find_spec(module, paths)\n     if not spec:\n         raise ImportError(\"Can't find %s\" % module)\n     return spec.loader.get_code(module)\n \n \n def get_module(module, paths, info):\n-    spec = importlib.util.find_spec(module, paths)\n+    spec = find_spec(module, paths)\n     if not spec:\n         raise ImportError(\"Can't find %s\" % module)\n     return module_from_spec(spec)\n", "issue": "TestDepends.testRequire regression in 41.6.0 (py3)\nWhile trying to build the new release of setuptools, I get the following test failure:\r\n\r\n```\r\n==================================================================== FAILURES =====================================================================\r\n_____________________________________________________________ TestDepends.testRequire _____________________________________________________________\r\n\r\nself = <setuptools.tests.test_setuptools.TestDepends object at 0x7fbfae31d710>\r\n\r\n    @needs_bytecode\r\n    def testRequire(self):\r\n        req = Require('Json', '1.0.3', 'json')\r\n    \r\n        assert req.name == 'Json'\r\n        assert req.module == 'json'\r\n        assert req.requested_version == '1.0.3'\r\n        assert req.attribute == '__version__'\r\n        assert req.full_name() == 'Json-1.0.3'\r\n    \r\n        from json import __version__\r\n        assert req.get_version() == __version__\r\n        assert req.version_ok('1.0.9')\r\n        assert not req.version_ok('0.9.1')\r\n        assert not req.version_ok('unknown')\r\n    \r\n        assert req.is_present()\r\n        assert req.is_current()\r\n    \r\n        req = Require('Json 3000', '03000', 'json', format=LooseVersion)\r\n        assert req.is_present()\r\n        assert not req.is_current()\r\n        assert not req.version_ok('unknown')\r\n    \r\n        req = Require('Do-what-I-mean', '1.0', 'd-w-i-m')\r\n        assert not req.is_present()\r\n        assert not req.is_current()\r\n    \r\n        req = Require('Tests', None, 'tests', homepage=\"http://example.com\")\r\n        assert req.format is None\r\n        assert req.attribute is None\r\n        assert req.requested_version is None\r\n        assert req.full_name() == 'Tests'\r\n        assert req.homepage == 'http://example.com'\r\n    \r\n        from setuptools.tests import __path__\r\n        paths = [os.path.dirname(p) for p in __path__]\r\n>       assert req.is_present(paths)\r\nE       AssertionError: assert False\r\nE        +  where False = <bound method Require.is_present of <setuptools.depends.Require object at 0x7fbfae0d0b38>>(['/tmp/portage/dev-python/setuptools-41.6.0/work/setuptools-41.6.0-python3_5/setuptools'])\r\nE        +    where <bound method Require.is_present of <setuptools.depends.Require object at 0x7fbfae0d0b38>> = <setuptools.depends.Require object at 0x7fbfae0d0b38>.is_present\r\n\r\nsetuptools/tests/test_setuptools.py:120: AssertionError\r\n```\r\n\r\nI can reproduce it reliably with at least pypy3.6 (7.2.0) & python3.5 (3.5.7). I haven't tested other versions yet.\r\n\r\nFull build log: [dev-python:setuptools-41.6.0:20191030-083347.log](https://github.com/pypa/setuptools/files/3787797/dev-python.setuptools-41.6.0.20191030-083347.log)\r\n\r\n\n", "before_files": [{"content": "\"\"\"\nRe-implementation of find_module and get_frozen_object\nfrom the deprecated imp module.\n\"\"\"\n\nimport os\nimport importlib.util\nimport importlib.machinery\n\nfrom .py34compat import module_from_spec\n\n\nPY_SOURCE = 1\nPY_COMPILED = 2\nC_EXTENSION = 3\nC_BUILTIN = 6\nPY_FROZEN = 7\n\n\ndef find_module(module, paths=None):\n    \"\"\"Just like 'imp.find_module()', but with package support\"\"\"\n    spec = importlib.util.find_spec(module, paths)\n    if spec is None:\n        raise ImportError(\"Can't find %s\" % module)\n    if not spec.has_location and hasattr(spec, 'submodule_search_locations'):\n        spec = importlib.util.spec_from_loader('__init__.py', spec.loader)\n\n    kind = -1\n    file = None\n    static = isinstance(spec.loader, type)\n    if spec.origin == 'frozen' or static and issubclass(\n            spec.loader, importlib.machinery.FrozenImporter):\n        kind = PY_FROZEN\n        path = None  # imp compabilty\n        suffix = mode = ''  # imp compability\n    elif spec.origin == 'built-in' or static and issubclass(\n            spec.loader, importlib.machinery.BuiltinImporter):\n        kind = C_BUILTIN\n        path = None  # imp compabilty\n        suffix = mode = ''  # imp compability\n    elif spec.has_location:\n        path = spec.origin\n        suffix = os.path.splitext(path)[1]\n        mode = 'r' if suffix in importlib.machinery.SOURCE_SUFFIXES else 'rb'\n\n        if suffix in importlib.machinery.SOURCE_SUFFIXES:\n            kind = PY_SOURCE\n        elif suffix in importlib.machinery.BYTECODE_SUFFIXES:\n            kind = PY_COMPILED\n        elif suffix in importlib.machinery.EXTENSION_SUFFIXES:\n            kind = C_EXTENSION\n\n        if kind in {PY_SOURCE, PY_COMPILED}:\n            file = open(path, mode)\n    else:\n        path = None\n        suffix = mode = ''\n\n    return file, path, (suffix, mode, kind)\n\n\ndef get_frozen_object(module, paths=None):\n    spec = importlib.util.find_spec(module, paths)\n    if not spec:\n        raise ImportError(\"Can't find %s\" % module)\n    return spec.loader.get_code(module)\n\n\ndef get_module(module, paths, info):\n    spec = importlib.util.find_spec(module, paths)\n    if not spec:\n        raise ImportError(\"Can't find %s\" % module)\n    return module_from_spec(spec)\n", "path": "setuptools/_imp.py"}]}