Commits

Olivier Lauzanne  committed 07d5b2c

Integrated map() fix by Rooney Panduwana.

  • Participants
  • Parent commits 890d8cd

Comments (0)

Files changed (2)

File pyquery/pyquery.py

 
             >>> d('p').map(lambda i, e: PyQuery(this).text().split())
             ['Hi', 'there', 'Bye']
+            
+            Added this 
+
+
         """
         items = []
         try:
                     else:
                         items.extend(result)
         finally:
-            del func.func_globals['this']
+            if 'this' in func.func_globals:
+                del func.func_globals['this']
         return self.__class__(items, **dict(parent=self))
 
     @property

File pyquery/test.py

         def ids_minus_one(i, elem):
             return int(self.klass(elem).attr('id')[-1]) - 1
         assert self.klass('div', self.html).map(ids_minus_one) == [0, 1]
+        
+        d = pq('<p>Hello <b>warming</b> world</p>')
+        self.assertEqual(d('strong').map(lambda i,el: pq(this).text()), [])
 
     def test_end(self):
         assert len(self.klass('div', self.html).find('span').end()) == 2