nebius/SWE-bench-extra huggingface dataset:
Repository: piotrmaslanka/satella

Issue:
Bad rethrow_as
```python
    @rethrow_as((UnicodeDecodeError, ConfigurationMalformed),
                (json.JSONDecodeError, ConfigurationMalformed))
    @rethrow_as(ValueError, ConfigurationMalformed)
    @rethrow_as(binascii.Error, ConfigurationMalformed)
    @rethrow_as(TypeError, ConfigurationError)
    def provide(self):
        return json.loads(self.root, encoding=self.encoding)
```

breaks it by treating two first pairs in a wrong way

Comments:

Patch:
diff --git a/satella/coding/recast_exceptions.py b/satella/coding/recast_exceptions.py
index bf164db4..32e4e1c8 100644
--- a/satella/coding/recast_exceptions.py
+++ b/satella/coding/recast_exceptions.py
@@ -45,7 +45,8 @@ class rethrow_as(object):
         """
 
         # You can also provide just two exceptions
-        if len(pairs) == 2 and all(issubclass(p, BaseException) for p in pairs):
+        if len(pairs) == 2 and not isinstance(pairs[1], (tuple, list)) \
+                and all(issubclass(p, BaseException) for p in pairs):
             self.mapping = {pairs[0]: pairs[1]}
         else:
             self.mapping = dict(pairs)


Test patch:
diff --git a/tests/test_coding/test_rethrow.py b/tests/test_coding/test_rethrow.py
index ce17f722..80dd8ec6 100644
--- a/tests/test_coding/test_rethrow.py
+++ b/tests/test_coding/test_rethrow.py
@@ -39,4 +39,17 @@ class TestStuff(unittest.TestCase):
         def lol():
             raise ValueError()
 
-        self.assertRaises(NameError, lol)
\ No newline at end of file
+        self.assertRaises(NameError, lol)
+
+    def test_issue_10(self):
+
+        class WTFException1(Exception): pass
+        class WTFException2(Exception): pass
+
+        @rethrow_as((NameError, WTFException1),
+                    (TypeError, WTFException2))
+        def provide(exc):
+            raise exc()
+
+        self.assertRaises(WTFException1, lambda: provide(NameError))
+        self.assertRaises(WTFException2, lambda: provide(TypeError))
Repository: planetarypy/pvl

Issue:
Provide some additional functions for pvl.collection.Quantity objects.
**Is your feature request related to a problem? Please describe.**
Sometimes a caller will expect a particular key in the returned object, and will expect a numeric value but won't know if the value is a bare numeric value (of type float or int) or a Quantity object, but in any case won't care about the unit, and is only after the numeric value.  In this case, they need to perform an `isinstance()` test to know whether they can use the value as-is, or if they need to call the `.value` attribute.

**Describe the solution you'd like**
Implement `__float__()` and `__int__()` functions in the `pvl.collection.Quantity` class, so that a caller can just call `float(value)` or `int(value)` to get the contents of `Quantity.value`, as needed, or a harmless conversion of a float to a float (if the value isn't a Quantity object), for example.

**Describe alternatives you've considered**
The alternate solution is to do nothing and continue to force type testing behavior on users, but this results in more complex downstream code.  This simple change would streamline certain use cases.


Comments:

Patch:
diff --git a/HISTORY.rst b/HISTORY.rst
index 0303c97..51e2522 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -30,6 +30,13 @@ and the release date, in year-month-day format (see examples below).
 Unreleased
 ----------
 
+Added
++++++
+* pvl.collections.Quantity objects now have __int__() and __float__() functions that
+  will return the int and float versions of their .value parameter to facilitate numeric
+  operations with Quantity objects (Issue 91).
+
+
 1.2.1 (2021-05-31)
 ------------------
 
diff --git a/pvl/collections.py b/pvl/collections.py
index 5679915..5eebdbd 100644
--- a/pvl/collections.py
+++ b/pvl/collections.py
@@ -692,7 +692,11 @@ class Quantity(namedtuple("Quantity", ["value", "units"])):
     for how to use 3rd party Quantity objects with pvl.
     """
 
-    pass
+    def __int__(self):
+        return int(self.value)
+
+    def __float__(self):
+        return float(self.value)
 
 
 class Units(Quantity):


Test patch:
diff --git a/tests/test_collections.py b/tests/test_collections.py
index 61b5126..b7cb3e7 100644
--- a/tests/test_collections.py
+++ b/tests/test_collections.py
@@ -880,4 +880,28 @@ class TestMultiDict(unittest.TestCase):
             )
 
         except ImportError:
-            pass
\ No newline at end of file
+            pass
+
+
+class TestQuantity(unittest.TestCase):
+
+    def setUp(self):
+        self.d = pvl.loads("a = 2 <m> b = 1.21 <gW> c = nine <planets>")
+
+    def test_int(self):
+        a = int(self.d["a"])
+        self.assertEqual(2, a)
+
+        b = int(self.d["b"])
+        self.assertEqual(1, b)
+
+        self.assertRaises(ValueError, int, self.d["c"])
+
+    def test_float(self):
+        a = float(self.d["a"])
+        self.assertEqual(2.0, a)
+
+        b = float(self.d["b"])
+        self.assertEqual(1.21, b)
+
+        self.assertRaises(ValueError, float, self.d["c"])