[twill] html entities and latin-1 problem

Titus Brown titus at caltech.edu
Wed Mar 15 00:19:52 PST 2006


On Fri, Mar 10, 2006 at 08:39:37AM -0600, Terry Peppers wrote:
-> Michelle -
-> 
-> A couple of weeks back I had encountered the same exact problem with the
-> 'latin-1' v. 'utf-8' encoding issue. I posted the issue to the list and I
-> caught Titus @ a bad time since he was @ PyCon. So after some digging (I
-> didn't even see the post from Gabor about how to correct this), I came to
-> the same conclusion as Gabor. At first I had tried to 'monkeypatch' a fix
-> into my twill script like this:
-> 
-> <start_sample>
-> import twill.other_packages.mechanize._html
-> 
-> def form_parser_args(
->      select_default=False,
->      form_parser_class=None,
->      request_class=None,
->      backwards_compat=False,
->      encoding="utf-8"
->      ):
->      return get_args(locals())
-> 
-> twill.other_packages.mechanize._html.form_parser_args=form_parser_args
-> <end_sample>
-> 
-> Unfortunately that didn't work and I was left to editing 'mechanize's'
-> _html.py file which did fix my problem. I guess my remaining questions are:
-> 
-> 1. Anyone have an idea as to why my 'monkeypatch' doesn't work?
-> 2. Is it correct to say that this is more of a 'mechanize' issue than a
-> 'twill' issue? And if so, what can we do to correct the problem?

Hi, Terry,

sorry for taking so long to get back to you -- it's been a strange few
weeks since PyCon!

Your monkeypatch probably didn't work because
RobustFormsFactory.__init__() was called before you did the monkeypatch.
I'd have to know when in the call history you inserted that patch in
order to be sure, however.

And yes, it is more of a mechanize issue than a twill issue.  John Lee
may have fixed this up in a more recent mechanize check-in, but at the
moment I'm going to leave it as-is (as utf-8).  Until I can build some
good test cases & get a good mental idea of what should be going on, I
don't want to break John's code ;).

cheers,
--titus



More information about the twill mailing list