1. Olivier Lauzanne
  2. pyquery
  3. Issues
Issue #39 wontfix

make_links_absolute() crush with 'global name 'this' is not defined' message

created an issue

OS: Windows 7 Python version: 2.7 pyquery version: 1.1.1 Script is multithread html-parser. Getting exception on make_links_absolute() execution.

Traceback: 17:47:56 <Votpusk.ru> in module 'site' at line 172 INFO: Processing URL: http://www.votpusk.ru/hotels/story.asp?H=TH018&P=8 17:47:56 <Tury.ru> in module 'site' at line 172 INFO: Processing URL: http://www.tury.ru/hotel/id/106977 Exception in thread Votpusk.ru: Traceback (most recent call last): File "C:\usr\Python27\lib\threading.py", line 530, in bootstrap_inner self.run() File "C:\usr\Python27\lib\threading.py", line 483, in run self.target(self.args, **self.kwargs) File "D:!Projects\nuitour\4Sergey\2012-01-18\model\site.py", line 203, in run page.make_links_absolute(url) File "C:\usr\Python27\lib\site-packages\pyquery-1.1.1-py2.7.egg\pyquery\pyquery.py", line 1207, in make_links_absolute self('a').each(lambda: self(this).attr('href', urljoin(base_url, self(this).attr('href')))) File "C:\usr\Python27\lib\site-packages\pyquery-1.1.1-py2.7.egg\pyquery\pyquery.py", line 522, in each if callback(func, i, element) == False: File "C:\usr\Python27\lib\site-packages\pyquery-1.1.1-py2.7.egg\pyquery\pyquery.py", line 69, in callback return func(args[:func_code(func).co_argcount]) File "C:\usr\Python27\lib\site-packages\pyquery-1.1.1-py2.7.egg\pyquery\pyquery.py", line 1207, in <lambda> self('a').each(lambda: self(this).attr('href', urljoin(base_url, self(this).attr('href')))) NameError: global name 'this' is not defined

'Site' module code: ... try: page = PyQuery(url = url, opener = self.opener) except ... ... page.make_links_absolute(url) ...

For example, variable 'url' has value 'http://www.votpusk.ru/hotels/story.asp?H=TH018&P=8'. Can't repeat on other OSs.

Comments (1)

  1. Log in to comment