Skip to content

A feature-rich command-line audio/video downloader

[utils] `HTTPHeaderDict`: Fix `__ior__` (#16930)

doe1080cb309b3293c9
diff --git a/test/test_utils.py b/test/test_utils.py
index cd0fb0f2e9..8f86d151b2 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -2172,6 +2172,10 @@ Line 1
headers6 = HTTPHeaderDict(a=1, b=2)
self.assertEqual(pickle.loads(pickle.dumps(headers6)), headers6)
+ headers7 = HTTPHeaderDict()
+ headers7 |= {'X-dlp': 'data'}
+ self.assertEqual(headers7.sensitive(), {'X-dlp': 'data'})
+
def test_extract_basic_auth(self):
assert extract_basic_auth('http://:foo.bar') == ('http://:foo.bar', None)
assert extract_basic_auth('http://foo.bar') == ('http://foo.bar', None)
diff --git a/yt_dlp/utils/networking.py b/yt_dlp/utils/networking.py
index 32c7acdb14..33cca412dc 100644
--- a/yt_dlp/utils/networking.py
+++ b/yt_dlp/utils/networking.py
@@ -64,7 +64,7 @@ class HTTPHeaderDict(dict):
other = other.sensitive()
if isinstance(other, dict):
self.update(other)
- return
+ return self
return NotImplemented
def __or__(self, other, /) -> typing.Self: