Commits

rooney  committed 65f7b7e

Fix KeyError when filter()-ing empty set.

  • Participants
  • Parent commits 9af970e

Comments (0)

Files changed (2)

File pyquery/pyquery.py

                     if selector(i):
                         elements.append(this)
             finally:
-                del selector.func_globals['this']
+                if 'this' in selector.func_globals:
+                    del selector.func_globals['this']
             return self.__class__(elements, **dict(parent=self))
 
     def not_(self, selector):

File pyquery/test.py

         assert len(self.klass('div', self.html).filter('.node3')) == 1
         assert len(self.klass('div', self.html).filter('#node2')) == 1
         assert len(self.klass('div', self.html).filter(lambda i: i == 0)) == 1
+        
+        d = pq('<p>Hello <b>warming</b> world</p>')
+        self.assertEqual(d('strong').filter(lambda el: True), [])
 
     def test_not(self):
         assert len(self.klass('div', self.html).not_('.node3')) == 1