Anonymous committed 65f7b7e

Fix KeyError when filter()-ing empty set.

Comments (0)

Files changed (2)


                     if selector(i):
-                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):
         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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.