prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  login failed with default registry
  I am using docker-py (1.8.0) and trying to using login API.
  
  If I don't input `registry='https://index.docker.io/v1/'` .
  It will raise exception as following:
  
  ```
  docker.errors.APIError: 500 Server Error: Internal Server Error ("Unexpected status code [301] :")
  ```
  
  But I saw https://github.com/docker/docker-py/blob/81edb398ebf7ce5c7ef14aa0739de5329589aabe/docker/api/daemon.py#L52 in source code. Should work with default registry.
  
  
  </issue>
  <code>
  [start of docker/api/daemon.py]
  1 import os
  2 import warnings
  3 from datetime import datetime
  4 
  5 from ..auth import auth
  6 from ..constants import INSECURE_REGISTRY_DEPRECATION_WARNING
  7 from ..utils import utils
  8 
  9 
  10 class DaemonApiMixin(object):
  11     def events(self, since=None, until=None, filters=None, decode=None):
  12         if isinstance(since, datetime):
  13             since = utils.datetime_to_timestamp(since)
  14 
  15         if isinstance(until, datetime):
  16             until = utils.datetime_to_timestamp(until)
  17 
  18         if filters:
  19             filters = utils.convert_filters(filters)
  20 
  21         params = {
  22             'since': since,
  23             'until': until,
  24             'filters': filters
  25         }
  26 
  27         return self._stream_helper(
  28             self.get(self._url('/events'), params=params, stream=True),
  29             decode=decode
  30         )
  31 
  32     def info(self):
  33         return self._result(self._get(self._url("/info")), True)
  34 
  35     def login(self, username, password=None, email=None, registry=None,
  36               reauth=False, insecure_registry=False, dockercfg_path=None):
  37         if insecure_registry:
  38             warnings.warn(
  39                 INSECURE_REGISTRY_DEPRECATION_WARNING.format('login()'),
  40                 DeprecationWarning
  41             )
  42 
  43         # If we don't have any auth data so far, try reloading the config file
  44         # one more time in case anything showed up in there.
  45         # If dockercfg_path is passed check to see if the config file exists,
  46         # if so load that config.
  47         if dockercfg_path and os.path.exists(dockercfg_path):
  48             self._auth_configs = auth.load_config(dockercfg_path)
  49         elif not self._auth_configs:
  50             self._auth_configs = auth.load_config()
  51 
  52         registry = registry or auth.INDEX_URL
  53 
  54         authcfg = auth.resolve_authconfig(self._auth_configs, registry)
  55         # If we found an existing auth config for this registry and username
  56         # combination, we can return it immediately unless reauth is requested.
  57         if authcfg and authcfg.get('username', None) == username \
  58                 and not reauth:
  59             return authcfg
  60 
  61         req_data = {
  62             'username': username,
  63             'password': password,
  64             'email': email,
  65             'serveraddress': registry,
  66         }
  67 
  68         response = self._post_json(self._url('/auth'), data=req_data)
  69         if response.status_code == 200:
  70             self._auth_configs[registry] = req_data
  71         return self._result(response, json=True)
  72 
  73     def ping(self):
  74         return self._result(self._get(self._url('/_ping')))
  75 
  76     def version(self, api_version=True):
  77         url = self._url("/version", versioned_api=api_version)
  78         return self._result(self._get(url), json=True)
  79
  [end of docker/api/daemon.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/docker/api/daemon.py b/docker/api/daemon.py
  --- a/docker/api/daemon.py
  +++ b/docker/api/daemon.py
  @@ -49,8 +49,6 @@
           elif not self._auth_configs:
               self._auth_configs = auth.load_config()
   
  -        registry = registry or auth.INDEX_URL
  -
           authcfg = auth.resolve_authconfig(self._auth_configs, registry)
           # If we found an existing auth config for this registry and username
           # combination, we can return it immediately unless reauth is requested.
  @@ -67,7 +65,7 @@
   
           response = self._post_json(self._url('/auth'), data=req_data)
           if response.status_code == 200:
  -            self._auth_configs[registry] = req_data
  +            self._auth_configs[registry or auth.INDEX_NAME] = req_data
           return self._result(response, json=True)
   
       def ping(self):
  
verification_info: {"golden_diff": "diff --git a/docker/api/daemon.py b/docker/api/daemon.py\n--- a/docker/api/daemon.py\n+++ b/docker/api/daemon.py\n@@ -49,8 +49,6 @@\n         elif not self._auth_configs:\n             self._auth_configs = auth.load_config()\n \n-        registry = registry or auth.INDEX_URL\n-\n         authcfg = auth.resolve_authconfig(self._auth_configs, registry)\n         # If we found an existing auth config for this registry and username\n         # combination, we can return it immediately unless reauth is requested.\n@@ -67,7 +65,7 @@\n \n         response = self._post_json(self._url('/auth'), data=req_data)\n         if response.status_code == 200:\n-            self._auth_configs[registry] = req_data\n+            self._auth_configs[registry or auth.INDEX_NAME] = req_data\n         return self._result(response, json=True)\n \n     def ping(self):\n", "issue": "login failed with default registry\nI am using docker-py (1.8.0) and trying to using login API.\n\nIf I don't input `registry='https://index.docker.io/v1/'` .\nIt will raise exception as following:\n\n```\ndocker.errors.APIError: 500 Server Error: Internal Server Error (\"Unexpected status code [301] :\")\n```\n\nBut I saw https://github.com/docker/docker-py/blob/81edb398ebf7ce5c7ef14aa0739de5329589aabe/docker/api/daemon.py#L52 in source code. Should work with default registry.\n\n", "before_files": [{"content": "import os\nimport warnings\nfrom datetime import datetime\n\nfrom ..auth import auth\nfrom ..constants import INSECURE_REGISTRY_DEPRECATION_WARNING\nfrom ..utils import utils\n\n\nclass DaemonApiMixin(object):\n    def events(self, since=None, until=None, filters=None, decode=None):\n        if isinstance(since, datetime):\n            since = utils.datetime_to_timestamp(since)\n\n        if isinstance(until, datetime):\n            until = utils.datetime_to_timestamp(until)\n\n        if filters:\n            filters = utils.convert_filters(filters)\n\n        params = {\n            'since': since,\n            'until': until,\n            'filters': filters\n        }\n\n        return self._stream_helper(\n            self.get(self._url('/events'), params=params, stream=True),\n            decode=decode\n        )\n\n    def info(self):\n        return self._result(self._get(self._url(\"/info\")), True)\n\n    def login(self, username, password=None, email=None, registry=None,\n              reauth=False, insecure_registry=False, dockercfg_path=None):\n        if insecure_registry:\n            warnings.warn(\n                INSECURE_REGISTRY_DEPRECATION_WARNING.format('login()'),\n                DeprecationWarning\n            )\n\n        # If we don't have any auth data so far, try reloading the config file\n        # one more time in case anything showed up in there.\n        # If dockercfg_path is passed check to see if the config file exists,\n        # if so load that config.\n        if dockercfg_path and os.path.exists(dockercfg_path):\n            self._auth_configs = auth.load_config(dockercfg_path)\n        elif not self._auth_configs:\n            self._auth_configs = auth.load_config()\n\n        registry = registry or auth.INDEX_URL\n\n        authcfg = auth.resolve_authconfig(self._auth_configs, registry)\n        # If we found an existing auth config for this registry and username\n        # combination, we can return it immediately unless reauth is requested.\n        if authcfg and authcfg.get('username', None) == username \\\n                and not reauth:\n            return authcfg\n\n        req_data = {\n            'username': username,\n            'password': password,\n            'email': email,\n            'serveraddress': registry,\n        }\n\n        response = self._post_json(self._url('/auth'), data=req_data)\n        if response.status_code == 200:\n            self._auth_configs[registry] = req_data\n        return self._result(response, json=True)\n\n    def ping(self):\n        return self._result(self._get(self._url('/_ping')))\n\n    def version(self, api_version=True):\n        url = self._url(\"/version\", versioned_api=api_version)\n        return self._result(self._get(url), json=True)\n", "path": "docker/api/daemon.py"}]}