Commits

Devin Jeanpierre  committed 50a46ea

Didn't even understand my idea. Dumb bug fix'd. Tee hee.

Coding while tired is so a bad idea.

  • Participants
  • Parent commits 34f79c8

Comments (0)

Files changed (2)

File langext/__init__.py

     # (specifically, could do binary search at each level, so log squared of n)
     # ... I think.
     isscope = isinstance(syntax, # TODO: module (probably modulename, not ast.Module)
-                  (ast.FunctionDef, ast.ClassDef, ast.Lambda))
+                  (ast.FunctionDef, ast.ClassDef, ast.Lambda,
+                   ast.ListComp, ast.SetComp, ast.DictComp, ast.GeneratorExp))
     ismodule = isinstance(syntax, ast.Module)
     if isscope:
         path_to_code = [syntax]
     - Class scope is considered to provide variables to closures by the patch
       scoper.
     
-    - genexps and comprehensions are not implemented at all. Not sure why,
-      I (author) expected leaving out handling of them to just lead to their
-      scope bleeding over. Apparently they can't be found at all. I will
-      investigate later.
-    
     - if two scopes are on the same line, anything scoped to the second
       will actually be given the scope of the first. Think, for example,
       [(lambda: ...), (lambda: ...)]

File langext/test/test_patch.py

         
         self.assertEqual(y(self.Thing()), 1)
     
-    @unittest.skip("expected something else... it actually explodes")
-    def testLCBug(self):
-        y = lambda t: t.foo()
+    def testListCompScope(self):
         [monkeypatch(self.Thing.foo)(self.foo) for _ in range(1)]
         
-        self.assertEqual(y(self.Thing()), 2) # BUG: should be 1
+        self.assertEqual(self.Thing().foo(), 1)
     
-    @unittest.skip("expected something else... it actually explodes")
-    def testGenexpBug(self):
-        y = lambda t: t.foo()
+    def testSetCompScope(self):
+        {monkeypatch(self.Thing.foo)(self.foo) for _ in range(1)}
+        
+        self.assertEqual(self.Thing().foo(), 1)
+    
+    def testDictCompScope(self):
+        {monkeypatch(self.Thing.foo)(self.foo):0 for _ in range(1)}
+        
+        self.assertEqual(self.Thing().foo(), 1)
+    
+    def testGenExpScope(self):
         list(monkeypatch(self.Thing.foo)(self.foo) for _ in range(1))
         
-        self.assertEqual(y(self.Thing()), 2) # BUG: should be 1
+        self.assertEqual(self.Thing().foo(), 1)
     
     def testClassScopeBug(self):
         class Class: