nebius/SWE-bench-extra huggingface dataset:
Repository: ivandokov/phockup

Issue:
Regex on filenames with optional hour info
A bit of an extension of #55 

If we have a regex that accepts hour information, yet has it as optional, phockup will crash.

Assuming the following custom regex:
`(?P<day>\d{2})\.(?P<month>\d{2})\.(?P<year>\d{4})[_-]?((?P<hour>\d{2})\.(?P<minute>\d{2})\.(?P<second>\d{2}))?`
and the following filename: `IMG_27.01.2015.jpg`

In date.py
`match_dir = matches.groupdict()`
will still create keys for hour information, but their values will be None.

`match_dir = dict([a, int(x)] for a, x in match_dir.items()) `
will consequently crash when casting NoneType to Int



Comments:

Patch:
diff --git a/src/date.py b/src/date.py
index 7268dca..97d3ca6 100644
--- a/src/date.py
+++ b/src/date.py
@@ -87,7 +87,7 @@ class Date():
 
         if matches:
             try:
-                match_dir = matches.groupdict()
+                match_dir = matches.groupdict(default='0')
                 match_dir = dict([a, int(x)] for a, x in match_dir.items())  # Convert str to int
                 date = self.build(match_dir)
             except (KeyError, ValueError):


Test patch:
diff --git a/tests/test_date.py b/tests/test_date.py
index 9d02975..226cf64 100644
--- a/tests/test_date.py
+++ b/tests/test_date.py
@@ -105,3 +105,14 @@ def test_get_date_custom_regex_no_match():
     """
     date_regex = re.compile(r"(?P<day>\d{2})\.(?P<month>\d{2})\.(?P<year>\d{4})[_-]?(?P<hour>\d{2})\.(?P<minute>\d{2})\.(?P<second>\d{2})")
     assert Date("Foo.jpg").from_exif({}, False, date_regex) is None
+
+def test_get_date_custom_regex_optional_time():
+    """
+    A valid regex with a matching filename that doesn't have hour information.
+    However, the regex in question has hour information as optional.
+    """
+    date_regex = re.compile(r"(?P<day>\d{2})\.(?P<month>\d{2})\.(?P<year>\d{4})[_-]?((?P<hour>\d{2})\.(?P<minute>\d{2})\.(?P<second>\d{2}))?")
+    assert Date("IMG_27.01.2015.jpg").from_exif({}, False, date_regex) == {
+        "date": datetime(2015, 1, 27, 0, 0, 00),
+        "subseconds": ""
+    }
Repository: jabesq/netatmo-api-python

Issue:
Thermostat disconnected - error not catch
Hi guys, 

I have an issue when my thermostat is disconnected (wifi connection lost...).

I analyse the json received from netatmo, the error tag is include in body, not at root level:
```
{ 
   'status':'ok',
   'body':{ 
      'errors':[ 
         { 
            'code':6,
            'id':'xx:xx:xx:xx:xx:xx'
         }
      ],
      'home':{ 
         'id':'xx'
      }
   },
   'time_server':xxx
}
```

In the thermostat.py, the error is checked in `resp` and not in `resp["body"]` ([after post_request](https://github.com/jabesq/netatmo-api-python/blob/master/src/pyatmo/thermostat.py#L168)):
`if "errors" in resp or "body" not in resp or "home" not in resp["body"]:`

I don't know if the case of error in root level exists...

Thanks.

Comments:

Patch:
diff --git a/fixtures/home_status_error_disconnected.json b/fixtures/home_status_error_disconnected.json
new file mode 100644
index 0000000..0059e9b
--- /dev/null
+++ b/fixtures/home_status_error_disconnected.json
@@ -0,0 +1,15 @@
+{ 
+   "status":"ok",
+   "body":{ 
+      "errors":[ 
+         { 
+            "code":6,
+            "id":"12:34:56:00:fa:d0"
+         }
+      ],
+      "home":{ 
+         "id":"12:34:56:00:f1:62"
+      }
+   },
+   "time_server":1559292039
+}
\ No newline at end of file
diff --git a/src/pyatmo/thermostat.py b/src/pyatmo/thermostat.py
index 5f2ac9b..0491aca 100644
--- a/src/pyatmo/thermostat.py
+++ b/src/pyatmo/thermostat.py
@@ -165,7 +165,12 @@ class HomeStatus:
         postParams = {"access_token": self.getAuthToken, "home_id": self.home_id}
 
         resp = postRequest(_GETHOMESTATUS_REQ, postParams)
-        if "errors" in resp or "body" not in resp or "home" not in resp["body"]:
+        if (
+            "errors" in resp
+            or "body" not in resp
+            or "home" not in resp["body"]
+            or ("errors" in resp["body"] and "modules" not in resp["body"]["home"])
+        ):
             raise NoDevice("No device found, errors in response")
         self.rawData = resp["body"]["home"]
         self.rooms = {}


Test patch:
diff --git a/tests/test_pyatmo_thermostat.py b/tests/test_pyatmo_thermostat.py
index de930a2..4f85098 100644
--- a/tests/test_pyatmo_thermostat.py
+++ b/tests/test_pyatmo_thermostat.py
@@ -463,3 +463,22 @@ def test_HomeData_setroomThermpoint_error(
         )["error"]["message"]
         == expected
     )
+
+
+def test_HomeStatus_error_disconnected(auth, requests_mock):
+    with open("fixtures/home_status_error_disconnected.json") as f:
+        json_fixture = json.load(f)
+    requests_mock.post(
+        pyatmo.thermostat._GETHOMESTATUS_REQ,
+        json=json_fixture,
+        headers={"content-type": "application/json"},
+    )
+    with open("fixtures/home_data_simple.json") as f:
+        json_fixture = json.load(f)
+    requests_mock.post(
+        pyatmo.thermostat._GETHOMESDATA_REQ,
+        json=json_fixture,
+        headers={"content-type": "application/json"},
+    )
+    with pytest.raises(pyatmo.NoDevice):
+        pyatmo.HomeStatus(auth)
Repository: janehmueller/python-json-config

Issue:
Enable pickling of Config
Pickle tries to call `__getstate__` which fails since it is not handled in the custom `__getattr__` method.

Use [this solution](https://stackoverflow.com/a/50888571).

Comments:

Patch:
diff --git a/python_json_config/__version__.py b/python_json_config/__version__.py
index 1f356cc..cd7ca49 100644
--- a/python_json_config/__version__.py
+++ b/python_json_config/__version__.py
@@ -1,1 +1,1 @@
-__version__ = '1.0.0'
+__version__ = '1.0.1'
diff --git a/python_json_config/config_node.py b/python_json_config/config_node.py
index 6b63473..0b23352 100644
--- a/python_json_config/config_node.py
+++ b/python_json_config/config_node.py
@@ -47,6 +47,15 @@ class ConfigNode(object):
 
     __repr__ = __str__
 
+    """
+    These two methods are needed to enable pickling since this class overwrites __getattr__.
+    """
+    def __getstate__(self):
+        return vars(self)
+
+    def __setstate__(self, state):
+        vars(self).update(state)
+
 
 class Config(ConfigNode):
     def __init__(self, config_dict: dict):


Test patch:
diff --git a/tests/config_node_test.py b/tests/config_node_test.py
index 422901e..86521fc 100644
--- a/tests/config_node_test.py
+++ b/tests/config_node_test.py
@@ -1,3 +1,4 @@
+import pickle
 from unittest import TestCase
 
 from python_json_config.config_node import ConfigNode
@@ -61,3 +62,10 @@ class ConfigNodeTest(TestCase):
         node = ConfigNode({1: 2, 3: 4})
         node_str = 'ConfigNode(path=[], values={1: 2, 3: 4})'
         self.assertEqual(str(node), node_str)
+
+    def test_pickle(self):
+        config = ConfigNode(self.config_dict)
+        pickle_conf = pickle.loads(pickle.dumps(config))
+        self.assertEqual(pickle_conf.key1, 1)
+        self.assertEqual(pickle_conf.key2.key3, 3)
+        self.assertEqual(pickle_conf.key2.key4.key5, 5)
Repository: jaraco/zipp

Issue:
Attempting to get a parent of a dir results in the same object
In ae4be5a, I illustrate an issue I discovered where retrieving the parent of a directory results in the same object and not actually the parent.

Comments:

Patch:
diff --git a/CHANGES.rst b/CHANGES.rst
index 7cb2095..4a64ccf 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,3 +1,8 @@
+v0.5.2
+======
+
+#7: Parent of a directory now actually returns the parent.
+
 v0.5.1
 ======
 
diff --git a/zipp.py b/zipp.py
index 918e688..8cdfdc0 100644
--- a/zipp.py
+++ b/zipp.py
@@ -159,7 +159,7 @@ class Path:
 
     @property
     def parent(self):
-        parent_at = posixpath.dirname(self.at)
+        parent_at = posixpath.dirname(self.at.rstrip('/'))
         if parent_at:
             parent_at += '/'
         return self._next(parent_at)


Test patch:
diff --git a/test_zipp.py b/test_zipp.py
index da68fea..e084374 100644
--- a/test_zipp.py
+++ b/test_zipp.py
@@ -170,3 +170,14 @@ class TestEverything(unittest.TestCase):
             root = zipp.Path(zipfile_abcde)
             assert (root / 'a').parent.at == ''
             assert (root / 'a' / 'b').parent.at == 'a/'
+
+    def test_dir_parent(self):
+        for zipfile_abcde in self.zipfile_abcde():
+            root = zipp.Path(zipfile_abcde)
+            assert (root / 'b').parent.at == ''
+            assert (root / 'b/').parent.at == ''
+
+    def test_missing_dir_parent(self):
+        for zipfile_abcde in self.zipfile_abcde():
+            root = zipp.Path(zipfile_abcde)
+            assert (root / 'missing dir/').parent.at == ''
Repository: jbasko/configmanager

Issue:
Allow deep-copying of Config with config2 = Config(config1)

Comments:

Patch:
diff --git a/configmanager/managers.py b/configmanager/managers.py
index 1b03f33..9679217 100644
--- a/configmanager/managers.py
+++ b/configmanager/managers.py
@@ -46,8 +46,10 @@ class Config(BaseSection):
     cm__configparser_factory = configparser.ConfigParser
 
     def __new__(cls, config_declaration=None, item_cls=None, configparser_factory=None):
-        instance = super(Config, cls).__new__(cls)
+        if config_declaration and isinstance(config_declaration, cls):
+            return copy.deepcopy(config_declaration)
 
+        instance = super(Config, cls).__new__(cls)
         instance._cm__section = None
         instance._cm__section_alias = None
         instance._cm__configs = collections.OrderedDict()


Test patch:
diff --git a/tests/test_config.py b/tests/test_config.py
index a51c096..29f62e3 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -460,3 +460,21 @@ def test_config_item_value_can_be_unicode_str(tmpdir):
     config2.configparser.load(path)
     assert config2.name.value == u'Jānis Bērziņš'
     assert config1.to_dict(with_defaults=True) == config2.to_dict(with_defaults=True)
+
+
+def test_config_of_config_is_a_deep_copy_of_original_config():
+    config1 = Config({'uploads': {'enabled': True, 'db': {'user': 'root'}}})
+    config1.uploads.enabled.value = False
+
+    config2 = Config(config1)
+    assert config1 is not config2
+    assert config1.to_dict() == config2.to_dict()
+    assert config1.to_dict(with_defaults=True) == config2.to_dict(with_defaults=True)
+
+    config1.uploads.enabled.value = True
+    config1.uploads.db.read_dict({'user': 'admin'})
+
+    assert config2.to_dict(with_defaults=True) == {'uploads': {'enabled': False, 'db': {'user': 'root'}}}
+
+    config2.uploads.db.user.default = 'default-user'
+    assert config1.uploads.db.user.default == 'root'
Repository: jbradberry/universe

Issue:
Owned planets that have no population should lose ownership
Also, an explicit 0 population should be removed.

Comments:

Patch:
diff --git a/universe/engine.py b/universe/engine.py
index 08765e2..73fc86d 100644
--- a/universe/engine.py
+++ b/universe/engine.py
@@ -24,12 +24,14 @@ class Entity:
         for component in self.__dict__.get('_components', {}).values():
             if name in component._fields:
                 self.__dict__['_data'][name] = value
+                return
         self.__dict__[name] = value
 
     def __delattr__(self, name):
         for component in self.__dict__.get('_components', {}).values():
             if name in component._fields:
                 del self.__dict__['_data'][name]
+                return
         del self.__dict__[name]
 
     def __contains__(self, key):
diff --git a/universe/systems.py b/universe/systems.py
index 7a7043b..f06579c 100644
--- a/universe/systems.py
+++ b/universe/systems.py
@@ -119,3 +119,6 @@ class PopulationGrowthSystem:
             growth_rate = 1 + Decimal(species.growth_rate) / 100
             population *= growth_rate
             entity.population = int(population.to_integral_value())
+            if entity.population <= 0:
+                del entity.population
+                del entity.owner_id


Test patch:
diff --git a/tests/test_systems.py b/tests/test_systems.py
index 96ef1ce..4d07dc0 100644
--- a/tests/test_systems.py
+++ b/tests/test_systems.py
@@ -67,3 +67,38 @@ class PopulationTestCase(unittest.TestCase):
                 }
             }
         )
+
+    def test_lose_ownership(self):
+        state = {
+            'turn': 2500,
+            'width': 1000,
+            'entities': {
+                0: {
+                    'type': 'species',
+                    'name': 'Human',
+                    'plural_name': 'Humans',
+                    'growth_rate': 15,
+                },
+                1: {
+                    'type': 'planet',
+                    'population': 0,
+                    'x': 480,
+                    'y': 235,
+                    'gravity': 50,
+                    'temperature': 50,
+                    'radiation': 50,
+                    'ironium_conc': 50,
+                    'boranium_conc': 50,
+                    'germanium_conc': 50,
+                    'owner_id': 0,
+                    'queue': [],
+                },
+            }
+        }
+
+        S = engine.GameState(state, {})
+        results = S.generate()
+
+        self.assertEqual(len(results['entities']), 2)
+        self.assertNotIn('population', results['entities'][1])
+        self.assertNotIn('owner_id', results['entities'][1])