nebius/SWE-bench-extra huggingface dataset:
Repository: python-trio/trio

Issue:
trio.open_signal_receiver should give an error if no arguments are passed
User confusion spotted in the wild: https://gitter.im/python-trio/general?at=5ebfa9d613878c30b581b9fe


Comments:

Patch:
diff --git a/newsfragments/1526.bugfix.rst b/newsfragments/1526.bugfix.rst
new file mode 100644
index 00000000..02e1d37c
--- /dev/null
+++ b/newsfragments/1526.bugfix.rst
@@ -0,0 +1,1 @@
+Calling `open_signal_receiver` with no arguments used to succeed without listening for any signals. This was confusing, so now it raises TypeError instead.
diff --git a/trio/_signals.py b/trio/_signals.py
index aca23dda..cee3b7db 100644
--- a/trio/_signals.py
+++ b/trio/_signals.py
@@ -129,6 +129,8 @@ def open_signal_receiver(*signals):
       signals: the signals to listen for.
 
     Raises:
+      TypeError: if no signals were provided.
+
       RuntimeError: if you try to use this anywhere except Python's main
           thread. (This is a Python limitation.)
 
@@ -144,6 +146,9 @@ def open_signal_receiver(*signals):
                  reload_configuration()
 
     """
+    if not signals:
+        raise TypeError("No signals were provided")
+
     if not is_main_thread():
         raise RuntimeError(
             "Sorry, open_signal_receiver is only possible when running in "


Test patch:
diff --git a/trio/tests/test_signals.py b/trio/tests/test_signals.py
index 7ae93040..20821b40 100644
--- a/trio/tests/test_signals.py
+++ b/trio/tests/test_signals.py
@@ -41,6 +41,12 @@ async def test_open_signal_receiver_restore_handler_after_one_bad_signal():
     assert signal.getsignal(signal.SIGILL) is orig
 
 
+async def test_open_signal_receiver_empty_fail():
+    with pytest.raises(TypeError, match="No signals were provided"):
+        with open_signal_receiver():
+            pass
+
+
 async def test_open_signal_receiver_restore_handler_after_duplicate_signal():
     orig = signal.getsignal(signal.SIGILL)
     with open_signal_receiver(signal.SIGILL, signal.SIGILL):
Repository: python-trio/trio

Issue:
to_thread.run_sync() foils meta-class destructors 
Invoking `to_thread.run_sync()` seems to prevent meta-class destructors of completely unrelated classes from being called on shutdown.

```python
import trio

class deltype(type):
    def __del__(self):
        print(f"{self.__name__} class deleted")

Test = deltype("Test", (object,), {})

async def async_main():
    await trio.to_thread.run_sync(lambda: print('hi'))
    await trio.sleep(0)

trio.run(async_main)
```

expected output:
```
hi
Test class deleted
```

actual output:
```
hi
```

if the `run_sync()` is commented out, the meta-class destructor is called as expected:
```
Test class deleted
```


Comments:

Patch:
diff --git a/newsfragments/1638.fix.rst b/newsfragments/1638.fix.rst
new file mode 100644
index 00000000..6c6a9a6a
--- /dev/null
+++ b/newsfragments/1638.fix.rst
@@ -0,0 +1,1 @@
+The thread cache didn't release its reference to the previous job.
diff --git a/trio/_core/_thread_cache.py b/trio/_core/_thread_cache.py
index 8faf5543..ae5e8450 100644
--- a/trio/_core/_thread_cache.py
+++ b/trio/_core/_thread_cache.py
@@ -69,6 +69,8 @@ class WorkerThread:
                 # instead of spawning a new thread.
                 self._thread_cache._idle_workers[self] = None
                 deliver(result)
+                del fn
+                del deliver
             else:
                 # Timeout acquiring lock, so we can probably exit. But,
                 # there's a race condition: we might be assigned a job *just*


Test patch:
diff --git a/trio/_core/tests/test_thread_cache.py b/trio/_core/tests/test_thread_cache.py
index f19ac1d4..0f6e0a07 100644
--- a/trio/_core/tests/test_thread_cache.py
+++ b/trio/_core/tests/test_thread_cache.py
@@ -4,7 +4,7 @@ from queue import Queue
 import time
 import sys
 
-from .tutil import slow
+from .tutil import slow, gc_collect_harder
 from .. import _thread_cache
 from .._thread_cache import start_thread_soon, ThreadCache
 
@@ -25,6 +25,29 @@ def test_thread_cache_basics():
         outcome.unwrap()
 
 
+def test_thread_cache_deref():
+    res = [False]
+
+    class del_me:
+        def __call__(self):
+            return 42
+
+        def __del__(self):
+            res[0] = True
+
+    q = Queue()
+
+    def deliver(outcome):
+        q.put(outcome)
+
+    start_thread_soon(del_me(), deliver)
+    outcome = q.get()
+    assert outcome.unwrap() == 42
+
+    gc_collect_harder()
+    assert res[0]
+
+
 @slow
 def test_spawning_new_thread_from_deliver_reuses_starting_thread():
     # We know that no-one else is using the thread cache, so if we keep
Repository: python-trio/trio

Issue:
trio.Path.iterdir wrapping is broken
Given `pathlib.Path.iterdir` returns a generator that does IO access on each iteration, `trio.Path.iterdir` is currently broken given it currently only generates the generator asynchronously (which I suppose is pointless given there is no need for IO at generator creation)

The solution would be to modify  `trio.Path.iterdir` to return an async generator, however this means creating a special case given the current implementation is only an async wrapper on `pathlib.Path.iterdir`.

Comments:

Patch:
diff --git a/trio/_path.py b/trio/_path.py
index 4b1bee16..7f777936 100644
--- a/trio/_path.py
+++ b/trio/_path.py
@@ -128,6 +128,28 @@ class Path(metaclass=AsyncAutoWrapperType):
 
         self._wrapped = pathlib.Path(*args)
 
+    async def iterdir(self):
+        """
+        Like :meth:`pathlib.Path.iterdir`, but async.
+
+        This is an async method that returns a synchronous iterator, so you
+        use it like::
+        
+           for subpath in await mypath.iterdir():
+               ...
+               
+        Note that it actually loads the whole directory list into memory
+        immediately, during the initial call. (See `issue #501
+        <https://github.com/python-trio/trio/issues/501>`__ for discussion.)
+        
+        """
+
+        def _load_items():
+            return list(self._wrapped.iterdir())
+
+        items = await trio.run_sync_in_worker_thread(_load_items)
+        return (Path(item) for item in items)
+
     def __getattr__(self, name):
         if name in self._forward:
             value = getattr(self._wrapped, name)


Test patch:
diff --git a/trio/tests/test_path.py b/trio/tests/test_path.py
index 6b9d1c15..1289cfa2 100644
--- a/trio/tests/test_path.py
+++ b/trio/tests/test_path.py
@@ -198,3 +198,17 @@ async def test_path_nonpath():
 async def test_open_file_can_open_path(path):
     async with await trio.open_file(path, 'w') as f:
         assert f.name == fspath(path)
+
+
+async def test_iterdir(path):
+    # Populate a directory
+    await path.mkdir()
+    await (path / 'foo').mkdir()
+    await (path / 'bar.txt').write_bytes(b'')
+
+    entries = set()
+    for entry in await path.iterdir():
+        assert isinstance(entry, trio.Path)
+        entries.add(entry.name)
+
+    assert entries == {'bar.txt', 'foo'}
Repository: python-visualization/folium

Issue:
Styling Imported Images
New to Python, kinda dove into it headfirst to create an interactive map with data. Really enjoying it, and really loving what Folium can do.

I've added a legend.png to create a legend (temporarily, or perhaps permanently, unless something else can be recommended) that I'd like to style by adding a box-shadow as well as adding a radius to curve the edges if I so desire.

Perhaps it's already in the notes somewhere, but I couldn't find it!

The legend itself works as it should and doesn't interfere with interacting with each site bubble (each site is expected to have more than just a "name" at some point. Actual data/graphs/etc. will be contained for nearly each site.)

```python
# Create Map Legend
from folium.plugins import FloatImage
image_file='images/Legend.png'

FloatImage(image_file,bottom=5,left=5).add_to(map)

```

Another quick question: can the output HTML file be modified with a viewport tag to assist with scaling on a mobile environment? I haven't tried it yet, and I assume each time I compile the app after I make changes the subsequent HTML file is entirely overwritten.

Thank you!



Comments:

Patch:
diff --git a/folium/plugins/float_image.py b/folium/plugins/float_image.py
index 00f32e03..fd3fc21f 100644
--- a/folium/plugins/float_image.py
+++ b/folium/plugins/float_image.py
@@ -12,6 +12,7 @@ class FloatImage(MacroElement):
                         position:absolute;
                         bottom:{{this.bottom}}%;
                         left:{{this.left}}%;
+                        width:{{this.width}}%;
                         }
                 </style>
             {% endmacro %}
@@ -24,9 +25,10 @@ class FloatImage(MacroElement):
             {% endmacro %}
             """)
 
-    def __init__(self, image, bottom=75, left=75):
+    def __init__(self, image, bottom=75, left=75, width=100):
         super(FloatImage, self).__init__()
         self._name = 'FloatImage'
         self.image = image
         self.bottom = bottom
         self.left = left
+        self.width = width


Test patch:
diff --git a/tests/plugins/test_float_image.py b/tests/plugins/test_float_image.py
index 8fdf02f4..cf98028e 100644
--- a/tests/plugins/test_float_image.py
+++ b/tests/plugins/test_float_image.py
@@ -13,7 +13,7 @@ from jinja2 import Template
 def test_float_image():
     m = folium.Map([45., 3.], zoom_start=4)
     url = 'https://raw.githubusercontent.com/SECOORA/static_assets/master/maps/img/rose.png'
-    szt = plugins.FloatImage(url, bottom=60, left=70)
+    szt = plugins.FloatImage(url, bottom=60, left=70, width=20)
     m.add_child(szt)
     m._repr_html_()
 
@@ -35,6 +35,7 @@ def test_float_image():
                 position:absolute;
                 bottom:60%;
                 left:70%;
+                width:20%;
                 }
         </style>
     """)
Repository: python-visualization/folium

Issue:
Leaflet.boatmarker is broken in v0.3.0
The reason is probably the move to `leaflet 1.0`.

Comments:

Patch:
diff --git a/folium/plugins/boat_marker.py b/folium/plugins/boat_marker.py
index d6e8856a..faed487e 100644
--- a/folium/plugins/boat_marker.py
+++ b/folium/plugins/boat_marker.py
@@ -65,5 +65,5 @@ class BoatMarker(Marker):
                                             'if it is not in a Figure.')
 
         figure.header.add_child(
-            JavascriptLink('https://thomasbrueggemann.github.io/leaflet.boatmarker/js/leaflet.boatmarker.min.js'),  # noqa
+            JavascriptLink('https://unpkg.com/leaflet.boatmarker/leaflet.boatmarker.min.js'),  # noqa
             name='markerclusterjs')


Test patch:
diff --git a/tests/plugins/test_boat_marker.py b/tests/plugins/test_boat_marker.py
index b6842784..97a5ad5b 100644
--- a/tests/plugins/test_boat_marker.py
+++ b/tests/plugins/test_boat_marker.py
@@ -34,7 +34,7 @@ def test_boat_marker():
     out = m._parent.render()
 
     # We verify that the script import is present.
-    script = '<script src="https://thomasbrueggemann.github.io/leaflet.boatmarker/js/leaflet.boatmarker.min.js"></script>'  # noqa
+    script = '<script src="https://unpkg.com/leaflet.boatmarker/leaflet.boatmarker.min.js"></script>'  # noqa
     assert script in out
 
     # We verify that the script part is correct.
Repository: python273/telegraph

Issue:
IndexErrortelegraph.utils in handle_endtag error pop from empty list
os:linux
version: "==1.3.2"
https://sentry.io/share/issue/f0d73c02680a4f0ea637437b236e9ec9/

Comments:

Patch:
diff --git a/telegraph/utils.py b/telegraph/utils.py
index c4b9f8b..41b6df9 100644
--- a/telegraph/utils.py
+++ b/telegraph/utils.py
@@ -83,6 +83,11 @@ class HtmlToNodesParser(HTMLParser):
         if tag in VOID_ELEMENTS:
             return
 
+        if not len(self.parent_nodes):
+            raise InvalidHTML('"{}" missing start tag'.format(
+                tag
+            ))
+
         self.current_nodes = self.parent_nodes.pop()
 
         last_node = self.current_nodes[-1]


Test patch:
diff --git a/tests/test_html_converter.py b/tests/test_html_converter.py
index 42af23a..86fecb1 100644
--- a/tests/test_html_converter.py
+++ b/tests/test_html_converter.py
@@ -19,7 +19,7 @@ NODES_TEST_LIST = [
         'attrs': {'href': 'https://telegra.ph/'},
         'children': ['Test link</a>']
         }]
-    },
+     },
     {'tag': 'figure', 'children': [
         {'tag': 'img', 'attrs': {'src': '/file/6c2ecfdfd6881d37913fa.png'}},
         {'tag': 'figcaption'}
@@ -45,6 +45,8 @@ HTML_MULTI_LINES_NODES_LIST = [
     ]},
 ]
 
+HTML_NO_STARTTAG = "</a><h1></h1>"
+
 
 class TestHTMLConverter(TestCase):
     def test_html_to_nodes(self):
@@ -130,3 +132,7 @@ class TestHTMLConverter(TestCase):
         ]
 
         self.assertEqual(clear_whitespace_nodes(nodes)[0], expected)
+
+    def test_no_starttag_node(self):
+        with self.assertRaises(InvalidHTML):
+             html_to_nodes(HTML_NO_STARTTAG)