Package: python-mechanize
Version: 0.1.6b-1
Severity: normal
Tags: patch
Forwarded: [EMAIL PROTECTED]

Hello,

Luis Bruno reported a bug on Twill Debian package: ``showforms'' command
doesn't  work in Twill  Debian package  ATM.  This  bug happens  only in
Debian package because I (as the Twill Debian package maintainer) remove
the installation of customized  version of mechanize and clientform from
Twill module in favor of  depending on official mechanize and clientform
modules.

Titus patched ClientForm in Twill module:

--- ClientForm.py	2007-03-06 23:00:05.000000000 +0000
+++ python-clientform-0.2.6/ClientForm.py	2007-01-07 18:30:19.000000000 +0000
@@ -1085,9 +1085,6 @@
     if backwards_compat:
         deprecation("operating in backwards-compatibility mode")
     fp = form_parser_class(entitydefs, encoding)
-    
-    file.seek(0)
-    
     while 1:
         data = file.read(CHUNK)
         try:
Actually,  ``file.seek(0)'' has  been  added by  Titus in  ClientForm.py
because ``file'' position (parameter  of ``_ParseFileEx'' class) may not
be  at the  beginning. 

However, IMHO the ``seek''  shouldn't be performed in ClientForm because
the  file position  is only  modified  by ``RobustFactory.set_response''
(but not by DefaultFactory.set_response) when reading the response.

I have attached a patch that  fixes this problem for me and forwarded it
to [EMAIL PROTECTED] and [EMAIL PROTECTED] but
I didn't get an answer yet.

Regards,
Arnaud Fontaine

--- mechanize-0.1.7b/mechanize/_html.py.old	2007-12-16 15:17:37.000000000 +0000
+++ mechanize-0.1.7b/mechanize/_html.py	2007-12-16 15:17:47.000000000 +0000
@@ -599,6 +599,7 @@
         Factory.set_response(self, response)
         if response is not None:
             data = response.read()
+            response.seek(0)
             soup = self._soup_class(self.encoding, data)
             self._forms_factory.set_response(
                 copy.copy(response), self.encoding)

Attachment: pgpIrJsBFZMFu.pgp
Description: PGP signature

Reply via email to