[ZCM] [ZC] 1548/ 5 Comment "Client.py broken because of deprecated httplib usage"

Collector: Zope Bugs, Features, and Patches ... zope-coders-admin at zope.org
Wed Mar 30 15:31:12 EST 2005


Issue #1548 Update (Comment) "Client.py broken because of deprecated httplib usage"
 Status Pending, Zope/bug medium
To followup, visit:
  http://www.zope.org/Collectors/Zope/1548

==============================================================
= Comment - Entry #5 by iclelland on Mar 30, 2005 3:31 pm

Thanks, Peter, we've been doing making that change to Client.py every time the Debian Zope packages get updated, for a while now.

fg - We're running this command every Sunday to pack the Zope database:

 /usr/bin/python /usr/lib/zope2.7/lib/python/ZPublisher/Client.py -u user:password http://localhost:9673/Control_Panel/manage_pack days:float=1

Without patching Client.py, we immediately get this exception:

 Traceback (most recent call last):
  File "/usr/lib/zope2.7/lib/python/ZPublisher/Client.py", line 566, in ?
    main()
  File "/usr/lib/zope2.7/lib/python/ZPublisher/Client.py", line 559, in main
    headers, body = apply(f,(),kw)
  File "/usr/lib/zope2.7/lib/python/ZPublisher/Client.py", line 154, in __call__
    raise NotAvailable, RemoteException(
 bci.NotAvailable: string index out of range (File: http://localhost:9673/Control_Panel/manage_pack Line: days:float=1)
 None None for None

The actual exception is being raised by the call to httplib.HTTP() on line 144, and is being handled on line 154 as a generic 'remote exception'. (The construction of the RemoteException object appears to be out of date, given it's constructor, but that's a different issue).

The simplest way for me to replicate this error (outside of Client.py) is this:

 cricket:/home/ian$ python
 Python 2.3.5 (#2, Feb  9 2005, 00:38:15) 
 [GCC 3.3.5 (Debian 1:3.3.5-8)] on linux2
 Type "help", "copyright", "credits" or "license" for more information.
 >>> from httplib import HTTP
 >>> h = HTTP()
 Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.3/httplib.py", line 1012, in __init__
    self._setup(self._connection_class(host, port, strict))
  File "/usr/lib/python2.3/httplib.py", line 507, in __init__
    self._set_hostport(host, port)
  File "/usr/lib/python2.3/httplib.py", line 523, in _set_hostport
    if host[0] == '[' and host[-1] == ']':
 IndexError: string index out of range

As Bryan mentioned, the HTTP class has been deprecated (some time ago). It still works, (as a wrapper around HTTPConnection,) but only if you pass a hostname to the constructor, or if you explicitly ignore the exception and then call h.connect(hostname) afterwards.

I hope this helps; if you need any more info, let me know.

________________________________________
= Comment - Entry #4 by efge on Mar 27, 2005 10:34 am

Could you provide the exception, traceback or the concrete problem you have with the current code ? As I say, it seems to work for me.

________________________________________
= Comment - Entry #3 by peterbe on Mar 15, 2005 1:07 pm

Solution: In Client.py change the line::

 h=HTTP()

to this which works in Python2.3::

 h=HTTP(self.host)

I don't know how to provide a patch. But the problem is still in Zope2.7.4 (haven't tested any higher version numbers) and it must be fixed soon.

I think this also affects bin/load_site.py

________________________________________
= Comment - Entry #2 by efge on Nov 10, 2004 12:12 pm

HTTP() works fine in my python 2.3.4.

The RemoteException call looks wrong, agreed.

________________________________________
= Request - Entry #1 by Anonymous User on Oct 21, 2004 2:36 pm

Client.py line 144:

  h=HTTP()

This is deprecated as of Python 2.2 and causes an exception in Python 2.3.4. The HTTP class has been deprecated in favour of HTTPConnection. Also, on line 154, RemoteException is being passed the wrong number of parameters.
==============================================================



More information about the Zope-Collector-Monitor mailing list