[twill] BeautifulSoup conflicts

twill.overbored at spamgourmet.com twill.overbored at spamgourmet.com
Tue Aug 8 09:26:04 PDT 2006


I found that one way to workaround this is to simply rename
BeautifulSoup.py to TwillBeautifulSoup.py and replace all "import
BeautifulSoup" with "import TwillBeautifulSoup as BeautifulSoup" in
the .py files. I tried this with both 0.8.5 and 0.9a. I hope this
simple change is introduced in the actual program to prevent such
conflicts with BeautifulSoup. Thanks.

On 8/8/06, I wrote:
> Never mind. The problem is still there.
>
> Upon closer inspection, Python is using the wrong BeautifulSoup! If
> you look at the exception's line numbers, some are far beyond the
> total line count in the BeautifulSoup included with twill. Instead,
> this stack trace matches up with the BeautifulSoup 3.x I have
> installed elsewhere. The thing that threw me off was the fact that
> Python was printing the wrong path in the exceptions! (It's showing
> the one that came with twill.)
>
> There's almost certainly a way to have the two coexist (maybe I can
> specify a BeautifulSoup version number from within mechanize and
> ClientForm).
>
> On 8/5/06, I wrote:
> > I just tried with twill 0.8.5 (BeautifulSoup still at 3.0.3) and this
> > is no longer a problem. Did someone fix it? (Thanks!)
> >
> > On 7/3/06, I wrote:
> > > The program (/tmp/zxcv):
> > >
> > > import BeautifulSoup
> > > import twill.commands
> > > twill.commands.go('http://youtube.com/')
> > > twill.commands.follow( 'Log In' )
> > >
> > > The output and exception:
> > >
> > > ==> at http://youtube.com/
> > > Traceback (most recent call last):
> > >   File "/tmp/zxcv", line 6, in ?
> > >     twill.commands.follow( 'Log In' )
> > >   File "/usr/lib/python2.4/site-packages/twill-0.8.4-py2.4.egg/twill/commands.py",
> > > line 180, in follow
> > >     link = browser.find_link(regexp)
> > >   File "/usr/lib/python2.4/site-packages/twill-0.8.4-py2.4.egg/twill/browser.py",
> > > line 181, in find_link
> > >     l = self._browser.find_link(url_regex=pattern)
> > >   File "/usr/lib/python2.4/site-packages/twill-0.8.4-py2.4.egg/twill/other_packages/mechanize/_mechanize.py",
> > > line 431, in find_link
> > >     return _find_links(self._factory.links(), True, **kwds)
> > >   File "/usr/lib/python2.4/site-packages/twill-0.8.4-py2.4.egg/twill/utils.py",
> > > line 382, in links
> > >     self._links = list(self._links)
> > >   File "/usr/lib/python2.4/site-packages/twill-0.8.4-py2.4.egg/twill/other_packages/mechanize/_html.py",
> > > line 345, in links
> > >     bs = self.link_parser_class(encoding, data)
> > >   File "/usr/lib/python2.4/site-packages/twill-0.8.4-py2.4.egg/twill/other_packages/mechanize/_html.py",
> > > line 303, in __init__
> > >     BeautifulSoup.BeautifulSoup.__init__(
> > >   File "/usr/lib/python2.4/site-packages/twill-0.8.4-py2.4.egg/twill/other_packages/BeautifulSoup.py",
> > > line 1326, in __init__
> > >
> > >   File "/usr/lib/python2.4/site-packages/twill-0.8.4-py2.4.egg/twill/other_packages/BeautifulSoup.py",
> > > line 973, in __init__
> > >
> > >   File "/usr/lib/python2.4/site-packages/twill-0.8.4-py2.4.egg/twill/other_packages/BeautifulSoup.py",
> > > line 987, in _feed
> > >
> > >   File "/usr/lib/python2.4/site-packages/twill-0.8.4-py2.4.egg/twill/other_packages/BeautifulSoup.py",
> > > line 1580, in __init__
> > >
> > >   File "/usr/lib/python2.4/site-packages/twill-0.8.4-py2.4.egg/twill/other_packages/BeautifulSoup.py",
> > > line 1614, in _convertFrom
> > >
> > >   File "/usr/lib/python2.4/site-packages/twill-0.8.4-py2.4.egg/twill/other_packages/BeautifulSoup.py",
> > > line 1731, in find_codec
> > >
> > >   File "/usr/lib/python2.4/site-packages/twill-0.8.4-py2.4.egg/twill/other_packages/BeautifulSoup.py",
> > > line 1740, in _codec
> > >
> > > TypeError: lookup() argument 1 must be string, not bool
> > >
> > > On 7/2/06, William K. Volkman - wkvsf at users.sourceforge.net
> > > <+twill+overbored+89479d6bab.wkvsf#users.sourceforge.net at spamgourmet.com>
> > > wrote:
> > > > Hello,
> > > > On Sun, 2006-07-02 at 21:20, twill.overbored at spamgourmet.com wrote:
> > > > > On 7/2/06, William K. Volkman - wkvsf at users.sourceforge.net
> > > > > <>
> > > > > wrote:
> > > > > > On Sun, 2006-07-02 at 18:11, twill.overbored at spamgourmet.com wrote:
> > > > > > > I'm trying to use both twill and BeautifulSoup. I downloaded the
> > > > > > > latest BeautifulSoup (3.0.3) and have the following simple program:
> > > > > > >
> > > > > > > from BeautifulSoup import BeautifulSoup
> > > > > >
> > > > > > I suspect you're stepping on twill's desire to use BeautifulSoup,
> > > > > > the quick and dirty solution solution would be:
> > > > > >
> > > > > > from BeautifulSoup import BeautifulSoup as MySoup
> > > > >
> > > > > I had already tried this, but it still doesn't work; there's something
> > > > > more intricate going on.
> > > >
> > > > OK.
> > > >
> > > > > The problem is that I'm trying to use code which seems to only work
> > > > > with bsoup 3.x.
> > > > >
> > > > > >
> > > > > > > from twill.commands import *
> > > > > > > from twill.errors import *
> > > > > > > from twill import *
> > > > > > > from sys import *
> > > > > > > go('http://youtube.com/')
> > > > > > > follow( 'Log In' )
> > > > > > >
> > > > > > > This raises a hard-to-decipher exception. Once I remove the
> > > > > > > BeautifulSoup improt, everything's fine. Should this be filed as a
> > > > > > > twill bug? Any workarounds in the meantime? Thanks in advance.
> > > >
> > > > Well perhaps you could share the trace back from the hard-to-decipher
> > > > exception?  (making it a little less hard to decipher :-D)
> > > >
> > > > Cheers,
> > > > William.
> > > >
> > > >
> > > >
> > >
> >
>



More information about the twill mailing list