[Python-Dev] httplib SSLFile broken in CVS

Raymond Hettinger python@rcn.com
Thu, 6 Mar 2003 10:33:21 -0500


I'll put in your SF report and fix it.

Raymond

----- Original Message ----- 
From: "Kevin Jacobs" <jacobs@penguin.theopalgroup.com>
To: <python-dev@python.org>; "Raymond Hettinger" <python@rcn.com>
Sent: Thursday, March 06, 2003 10:18 AM
Subject: [Python-Dev] httplib SSLFile broken in CVS


> Hi all,
> 
> SourceForge isn't letting me in, so I'm dropping a note here to report that
> Raymond Hettinger's changes to httplib.py (Rev 1.72 on Wed Feb 26 22:45:18
> 2003 UTC) have broken the read() method on the SSLFile object.  I suspect
> that he was trying to be clever by adding iterators to code that worked just
> fine (if not better) without them.  Unfortunately, clever code has to be
> tested.  The diff below repairs it, though I'd be just as happy if that part
> of Rev 1.72 was reverted.
> 
> --- httplib.py.orig     2003-03-05 19:37:28.000000000 -0500
> +++ httplib.py  2003-03-06 10:11:01.000000000 -0500
> @@ -864,13 +864,15 @@
> 
>      def read(self, size=None):
>          L = [self._buf]
> +        self._buf = ''
>          if size is None:
> -            self._buf = ''
>              for s in iter(self._read, ""):
>                  L.append(s)
> -            return "".join(L)
>          else:
> -            avail = len(self._buf)
> +            avail = len(L[0])
> +            if avail >= size:
> +                self._buf = L[0][size:]
> +                return L[0][:size]
>              for s in iter(self._read, ""):
>                  L.append(s)
>                  avail += len(s)
> @@ -878,14 +880,19 @@
>                      all = "".join(L)
>                      self._buf = all[size:]
>                      return all[:size]
> +        return "".join(L)
> 
>      def readline(self):
>          L = [self._buf]
>          self._buf = ''
> +        i = L[0].find("\n") + 1
> +        if i > 0:
> +            self._buf = L[0][i:]
> +            return L[0][:i]
>          for s in iter(self._read, ""):
>              L.append(s)
> -            if "\n" in s:
> -                i = s.find("\n") + 1
> +            i = s.find("\n") + 1
> +            if i > 0:
>                  self._buf = s[i:]
>                  L[-1] = s[:i]
>                  break
> 
> Regards,
> -Kevin
> 
> -- 
> --
> Kevin Jacobs
> The OPAL Group - Enterprise Systems Architect
> Voice: (216) 986-0710 x 19         E-mail: jacobs@theopalgroup.com
> Fax:   (216) 986-0714              WWW:    http://www.theopalgroup.com
> 
> 
> _______________________________________________
> Python-Dev mailing list
> Python-Dev@python.org
> http://mail.python.org/mailman/listinfo/python-dev