nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: minio/minio-py
Pull request #185 (2015-07-09 19:01:17)

Adding milkyway to list of ignored regions


Patch:
diff --git a/minio/helpers.py b/minio/helpers.py
index 17013dd..c527e08 100644
--- a/minio/helpers.py
+++ b/minio/helpers.py
@@ -78,12 +78,16 @@ def is_positive_int(name, input_int, include_zero=False):
 
 
 def get_sha256(content):
+    if len(content) == 0:
+        content = b''
     hasher = hashlib.sha256()
     hasher.update(content)
     return hasher.digest()
 
 
 def get_md5(content):
+    if len(content) == 0:
+        content = b''
     hasher = hashlib.md5()
     hasher.update(content)
     return hasher.digest()
diff --git a/minio/minio.py b/minio/minio.py
index f198630..aa0b579 100644
--- a/minio/minio.py
+++ b/minio/minio.py
@@ -131,7 +131,7 @@ class Minio:
         region = get_region(self._location)
 
         content = ''
-        if region != 'us-east-1':
+        if not (region == 'us-east-1' or region == 'milkyway'):
             content = bucket_constraint(region)
             headers['Content-Length'] = str(len(content))
 


Test patch:
diff --git a/tests/make_bucket_test.py b/tests/make_bucket_test.py
index 792288f..e3e6606 100644
--- a/tests/make_bucket_test.py
+++ b/tests/make_bucket_test.py
@@ -40,7 +40,7 @@ class MakeBucket(TestCase):
         mock_server = MockConnection()
         mock_connection.return_value = mock_server
         mock_server.mock_add_request(MockResponse('PUT', 'http://localhost:9000/hello',
-                                                  {'Content-Length': '152', 'Content-MD5': 'SBBIY3Vm9HFpFlECujfyyw=='},
+                                                  {'Content-MD5': '1B2M2Y8AsgTpgAmY7PhCfg=='},
                                                   200))
         minio.Minio('http://localhost:9000')
 
@@ -51,7 +51,7 @@ class MakeBucket(TestCase):
         mock_server = MockConnection()
         mock_connection.return_value = mock_server
         mock_server.mock_add_request(MockResponse('PUT', 'http://localhost:9000/hello',
-                                                  {'Content-Length': '152', 'Content-MD5': 'SBBIY3Vm9HFpFlECujfyyw=='},
+                                                  {'Content-MD5': '1B2M2Y8AsgTpgAmY7PhCfg=='},
                                                   409, content=error_xml))
         client = minio.Minio('http://localhost:9000')
         client.make_bucket('hello')
Repository: minio/minio-py
Pull request #1053 (2021-01-05 04:39:18)

Allow empty prefix in Filter


Patch:
diff --git a/minio/commonconfig.py b/minio/commonconfig.py
index 735dd42..9d43851 100644
--- a/minio/commonconfig.py
+++ b/minio/commonconfig.py
@@ -179,8 +179,6 @@ class Filter:
         )
         if not valid:
             raise ValueError("only one of and, prefix or tag must be provided")
-        if prefix is not None and not prefix:
-            raise ValueError("prefix must not be empty")
         self._and_operator = and_operator
         self._prefix = prefix
         self._tag = tag
diff --git a/minio/xml.py b/minio/xml.py
index 438dbb6..f995d2a 100644
--- a/minio/xml.py
+++ b/minio/xml.py
@@ -77,7 +77,7 @@ def findtext(element, name, strict=False):
         if strict:
             raise ValueError("XML element <{0}> not found".format(name))
         return None
-    return element.text
+    return element.text or ""
 
 
 def unmarshal(cls, xmlstring):


Test patch:
diff --git a/tests/unit/lifecycleconfig_test.py b/tests/unit/lifecycleconfig_test.py
index d9ecde8..577ad01 100644
--- a/tests/unit/lifecycleconfig_test.py
+++ b/tests/unit/lifecycleconfig_test.py
@@ -41,6 +41,18 @@ class LifecycleConfigTest(TestCase):
         )
         xml.marshal(config)
 
+        config = LifecycleConfig(
+            [
+                Rule(
+                    ENABLED,
+                    rule_filter=Filter(prefix=""),
+                    rule_id="rule",
+                    expiration=Expiration(days=365),
+                ),
+            ],
+        )
+        xml.marshal(config)
+
         config = xml.unmarshal(
             LifecycleConfig,
             """<LifeCycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
@@ -68,3 +80,20 @@ class LifecycleConfigTest(TestCase):
 </LifeCycleConfiguration>""",
         )
         xml.marshal(config)
+
+        config = xml.unmarshal(
+            LifecycleConfig,
+            """<LifeCycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
+  <Rule>
+    <ID>DeleteAfterBecomingNonCurrent</ID>
+    <Filter>
+       <Prefix></Prefix>
+    </Filter>
+    <Status>Enabled</Status>
+    <NoncurrentVersionExpiration>
+      <NoncurrentDays>100</NoncurrentDays>
+    </NoncurrentVersionExpiration>
+  </Rule>
+</LifeCycleConfiguration>""",
+        )
+        xml.marshal(config)