Skip to content

filter() doesn't accept other PyQuery objects. #232

Description

@username27

Consider the following:
jsfiddle

code:

a = $("div")
b = $('[page="2"]')
a.filter(b).css("color", "red")

As you can see, filter accepts another jquery object.

PyQuery however throws the following exception:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyquery\pyquery.py in filter(self, selector)
    580                     if len(args) == 1:
--> 581                         selector.__globals__['this'] = this
    582                     if callback(selector, i, this):

AttributeError: 'PyQuery' object has no attribute '__globals__'

During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
<ipython-input-7-36cbb5d34989> in <module>
     24 print(a.text())
     25 print(b.text())
---> 26 print(a.filter(b).text())

~\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyquery\pyquery.py in filter(self, selector)
    583                         elements.append(this)
    584             finally:
--> 585                 f_globals = selector.__globals__
    586                 if 'this' in f_globals:
    587                     del f_globals['this']

AttributeError: 'PyQuery' object has no attribute '__globals__'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions