nebius/SWE-bench-extra huggingface dataset:
Repository: serge-sans-paille/beniget

Issue:
Regression in Lambda functions
This new test was passing in version 0.4.1 and now shows nothing

```python
    def test_simple_lambda(self):
        code = "lambda y: True"
        node = ast.parse(code)
        c = beniget.DefUseChains()
        c.visit(node)
        self.assertEqual(c.dump_chains(node), [])
        self.assertEqual(c.dump_chains(node.body[0].value), ['y -> ()'])
```

Comments:

Patch:
diff --git a/beniget/beniget.py b/beniget/beniget.py
index 50f035b..c964c50 100644
--- a/beniget/beniget.py
+++ b/beniget/beniget.py
@@ -1025,11 +1025,19 @@ class DefUseChains(ast.NodeVisitor):
     def visit_Lambda(self, node, step=DeclarationStep):
         if step is DeclarationStep:
             dnode = self.chains.setdefault(node, Def(node))
+            for default in node.args.defaults:
+                self.visit(default).add_user(dnode)
+            self._defered.append((node,
+                                  list(self._definitions),
+                                  list(self._scopes),
+                                  list(self._scope_depths),
+                                  list(self._precomputed_locals)))
             return dnode
         elif step is DefinitionStep:
             dnode = self.chains[node]
             with self.ScopeContext(node):
-                self.visit(node.args)
+                for a in node.args.args:
+                    self.visit(a)
                 self.visit(node.body).add_user(dnode)
             return dnode
         else:


Test patch:
diff --git a/tests/test_chains.py b/tests/test_chains.py
index e9d33f8..288ccc6 100644
--- a/tests/test_chains.py
+++ b/tests/test_chains.py
@@ -332,6 +332,22 @@ while done:
     def test_simple_import_as(self):
         code = "import x as y; y()"
         self.checkChains(code, ["y -> (y -> (Call -> ()))"])
+    
+    def test_simple_lambda(self):
+        node, c = self.checkChains( "lambda y: True", [])
+        self.assertEqual(c.dump_chains(node.body[0].value), ['y -> ()'])
+    
+    def test_lambda_defaults(self):
+        node, c = self.checkChains( "x=y=1;(lambda y, x=x: (True, x, y, z)); x=y=z=2", 
+                                   ['x -> (x -> (Lambda -> ()))',
+                                    'y -> ()', 
+                                    'x -> ()', 
+                                    'y -> ()',
+                                    'z -> (z -> (Tuple -> (Lambda -> ())))']) 
+        self.assertEqual(c.dump_chains(node.body[1].value), [
+            'y -> (y -> (Tuple -> (Lambda -> ())))',
+            'x -> (x -> (Tuple -> (Lambda -> ())))',
+        ])
 
     def test_multiple_import_as(self):
         code = "import x as y, z; y"
Repository: serge-sans-paille/beniget

Issue:
AssertionError in the __debug__ sanity checks when parsing idlelib.config
It can be reproduced as follows, but I don't have a minimal reproducer at the moment.

```
% curl --silent https://raw.githubusercontent.com/python/cpython/3.12/Lib/idlelib/config.py > test.py
% python3 -m beniget test.py 
W: unbound identifier 'line' at test.py:885:8
W: unbound identifier 'crc' at test.py:886:50
[...]
  File "beniget/beniget.py", line 616, in visit_Module
    assert nb_defs == nb_heads + nb_bltns - nb_overloaded_bltns
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError
```


Comments:

Patch:
diff --git a/beniget/beniget.py b/beniget/beniget.py
index 4faa64d..fe38b13 100644
--- a/beniget/beniget.py
+++ b/beniget/beniget.py
@@ -665,6 +665,14 @@ class DefUseChains(ast.NodeVisitor):
     def extend_global(self, name, dnode_or_dnodes):
         if self._deadcode:
             return
+        # `name` *should* be in self._definitions[0] because we extend the
+        # globals. Yet the original code maybe faulty and we need to cope with
+        # it.
+        if name not in self._definitions[0]:
+            if isinstance(dnode_or_dnodes, Def):
+                self.locals[self.module].append(dnode_or_dnodes)
+            else:
+                self.locals[self.module].extend(dnode_or_dnodes)
         DefUseChains.add_to_definition(self._definitions[0], name,
                                        dnode_or_dnodes)
 


Test patch:
diff --git a/tests/test_chains.py b/tests/test_chains.py
index 1e9bdaa..d2fa72c 100644
--- a/tests/test_chains.py
+++ b/tests/test_chains.py
@@ -111,6 +111,9 @@ class TestDefUseChains(TestCase):
         self.checkChains(code, ['a -> (a -> ())',
                                 'foo -> ()'])
 
+    def test_augassign_undefined_global(self):
+        code = "def foo():\n def bar():\n  global x\n  x+=1; x"
+        self.checkChains(code, ['foo -> ()', 'x -> (x -> ())'], strict=False)
 
     def test_expanded_augassign(self):
         code = "a = 1; a = a + 2"
Repository: serge-sans-paille/beniget

Issue:
Variable lenght arguments in lambda are ignored
```python
lambda *args: args
```

The code above generates the following warning: 

```
W: unbound identifier 'args' at ./test.py:1:14
```

Comments:

Patch:
diff --git a/beniget/beniget.py b/beniget/beniget.py
index fe38b13..efe40bb 100644
--- a/beniget/beniget.py
+++ b/beniget/beniget.py
@@ -1058,6 +1058,7 @@ class DefUseChains(ast.NodeVisitor):
             dnode = self.chains.setdefault(node, Def(node))
             for default in node.args.defaults:
                 self.visit(default).add_user(dnode)
+            # a lambda never has kw_defaults
             self._defered.append((node,
                                   list(self._definitions),
                                   list(self._scopes),
@@ -1067,7 +1068,7 @@ class DefUseChains(ast.NodeVisitor):
         elif step is DefinitionStep:
             dnode = self.chains[node]
             with self.ScopeContext(node):
-                for a in node.args.args:
+                for a in _iter_arguments(node.args):
                     self.visit(a)
                 self.visit(node.body).add_user(dnode)
             return dnode


Test patch:
diff --git a/tests/test_chains.py b/tests/test_chains.py
index d2fa72c..ff309e7 100644
--- a/tests/test_chains.py
+++ b/tests/test_chains.py
@@ -357,6 +357,14 @@ while done:
             'x -> (x -> (Tuple -> (Lambda -> ())))',
         ])
 
+    def test_lambda_varargs(self):
+        node, c = self.checkChains( "lambda *args: args", [])
+        self.assertEqual(c.dump_chains(node.body[0].value), ['args -> (args -> (Lambda -> ()))'])
+    
+    def test_lambda_kwargs(self):
+        node, c = self.checkChains( "lambda **kwargs: kwargs", [])
+        self.assertEqual(c.dump_chains(node.body[0].value), ['kwargs -> (kwargs -> (Lambda -> ()))'])
+
     def test_multiple_import_as(self):
         code = "import x as y, z; y"
         self.checkChains(code, ["y -> (y -> ())", "z -> ()"])
Repository: serge-sans-paille/gast

Issue:
gast doesn't seem to parse assignment expressions correctly
It looks like `gast` doesn't correctly parse [assignment expressions](https://docs.python.org/3/whatsnew/3.8.html#assignment-expressions) (the `:=` operator):

`ast`:

```
In [1]: import ast

In [2]: expr = "(x := 1)"

In [3]: ast.dump(ast.parse(expr))
Out[3]: "Module(body=[Expr(value=NamedExpr(target=Name(id='x', ctx=Store()), value=Constant(value=1, kind=None)))], type_ignores=[])"
```

`gast`:

```
In [4]: import gast

In [5]: expr = "(x := 1)"

In [6]: gast.dump(gast.parse(expr))
Out[6]: 'Module(body=[Expr(value=None)], type_ignores=[])'
```

Comments:

Patch:
diff --git a/README.rst b/README.rst
index d26f2d7..0fead9d 100644
--- a/README.rst
+++ b/README.rst
@@ -186,6 +186,7 @@ ASDL
 
               -- BoolOp() can use left & right?
         expr = BoolOp(boolop op, expr* values)
+             | NamedExpr(expr target, expr value)
              | BinOp(expr left, operator op, expr right)
              | UnaryOp(unaryop op, expr operand)
              | Lambda(arguments args, expr body)
diff --git a/gast/gast.py b/gast/gast.py
index 11b248a..a745858 100644
--- a/gast/gast.py
+++ b/gast/gast.py
@@ -133,6 +133,9 @@ _nodes = (
     ('BoolOp', (('op', 'values',),
                 ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',),
                 (expr,))),
+    ('NamedExpr', (('target', 'value',),
+                ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',),
+                (expr,))),
     ('BinOp', (('left', 'op', 'right',),
                ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',),
                (expr,))),


Test patch:
diff --git a/tests/test_compat.py b/tests/test_compat.py
index c04c433..bca7683 100644
--- a/tests/test_compat.py
+++ b/tests/test_compat.py
@@ -112,6 +112,16 @@ class CompatTestCase(unittest.TestCase):
                         "], type_ignores=[])")
                 self.assertEqual(gast.dump(tree), norm)
 
+            def test_NamedExpr(self):
+                code = '(x := 1) '
+                tree = gast.parse(code)
+                compile(gast.gast_to_ast(tree), '<test>', 'exec')
+                norm = ("Module(body=[Expr(value=NamedExpr(target=Name(id='x',"
+                        " ctx=Store(), annotation=None, type_comment=None), "
+                        "value=Constant(value=1, kind=None)))], type_ignores="
+                        "[])")
+                self.assertEqual(gast.dump(tree), norm)
+
         else:
 
             def test_Bytes(self):
Repository: seung-lab/cloud-volume

Issue:
Writing to volume (by slicing notation) is not properly checking slice.start < slice.stop
cv[(slice(0,1),slice(0,1),slice(779,344))] = 0  appears to clear out 344:779 rather than the expected behavior of not writing anything because the effective range is empty.

Comments:

Patch:
diff --git a/cloudvolume/frontends/precomputed.py b/cloudvolume/frontends/precomputed.py
index 807561d..6717c5e 100644
--- a/cloudvolume/frontends/precomputed.py
+++ b/cloudvolume/frontends/precomputed.py
@@ -522,6 +522,7 @@ class CloudVolumePrecomputed(object):
 
     slices = self.meta.bbox(self.mip).reify_slices(slices, bounded=self.bounded)
     steps = Vec(*[ slc.step for slc in slices ])
+    slices = [ slice(slc.start, slc.stop) for slc in slices ]
     channel_slice = slices.pop()
     requested_bbox = Bbox.from_slices(slices)
 
diff --git a/cloudvolume/lib.py b/cloudvolume/lib.py
index e3d00fb..2fae1f0 100644
--- a/cloudvolume/lib.py
+++ b/cloudvolume/lib.py
@@ -403,9 +403,13 @@ class Bbox(object):
         slices, bounded=bounded, autocrop=autocrop
       )
 
+    for slc in slices:
+      if slc.step not in (None, 1):
+        raise ValueError("Non-unitary steps are unsupported. Got: " + str(slc.step))
+
     return Bbox(
       [ slc.start for slc in slices ],
-      [ slc.stop for slc in slices ]
+      [ (slc.start if slc.stop < slc.start else slc.stop) for slc in slices ]
     )
 
   @classmethod


Test patch:
diff --git a/test/test_lib.py b/test/test_lib.py
index c175b5b..0813598 100644
--- a/test/test_lib.py
+++ b/test/test_lib.py
@@ -101,6 +101,21 @@ def test_bbox_division():
   bbox /= 3.0 
   assert np.all(x == point333)
 
+def test_bbox_slicing():
+  bbx_rect = Bbox.from_slices(np.s_[1:10,1:10,1:10])
+  bbx_plane = Bbox.from_slices(np.s_[1:10,10:1,1:10])
+
+  assert bbx_rect == Bbox((1,1,1), (10,10,10))
+  assert bbx_plane == Bbox((1,10,1), (10, 10, 10))
+
+  try:
+    bbx_plane = Bbox.from_slices(np.s_[1:10,10:1:-1,1:10])
+    assert False
+  except ValueError:
+    pass
+
+  bbx_plane = Bbox.from_slices(np.s_[1:10,10:1:1,1:10])
+  assert bbx_plane == Bbox((1,10,1), (10, 10, 10))
 
 
 def test_bbox_intersection():