[ZCM] [ZC] 2354/ 1 Request "Out of date with a PSL httplib change"

"Collector: Zope Bugs, Features, and Patches ..." <[email protected]> Mon, 03 Sep 2007 20:53:44 -0400
Newsgroups gmane.comp.web.zope.devel.collector-monitor
Message-ID <[email protected]>
Issue #2354 Update (Request) "Out of date with a PSL httplib change"
 Status Pending, Zope/bug medium
To followup, visit:
  http://www.zope.org/Collectors/Zope/2354

==============================================================
= Request - Entry #1 by ploneforge on Sep 3, 2007 8:53 pm


Uploaded:  "client.txt"
 - http://www.zope.org/Collectors/Zope/2354/client.txt/view
The code in HTTP(httplib.HTTP):getreply is out of date with changes (a long time ago) to the Python standard library httplib at line 33: self.sock should be self._conn.sock.

Also there is a really ugly assumption in Resource:put that filesnames are 7-bit ASCII which is not true on modern filesystems: they could be latin1 or utf-8 for example. The assumption is that if the thing given to the first argument of put doesn't match isbin=re.compile(r'[\000-\006\177-\277]') then then it might be a filename, and it calls os.stat on what could be a very large string full of control characters to see if it's a filename to be opened, which may provoke OSErrors on some OSs.

I think this method should be deprecated, and 2 new methods putFile and putBytes should replace it without the binary assumption code, even if it means changing all of the code that calls this method (probably not many occurences).

==============================================================