requests.cookies.RequestsCookieJar's popitem() method doesn't seem to work even if cookies is not empty.
Expected Result
From the doc:
remove and return some (key, value) pair as a 2-tuple; but raise KeyError if D is empty.
(Also, I'm not sure what exactly is "D" here. I assume it means the cookies obj itself.)
Actual Result
It always raises KeyError even when it's not empty.
Reproduction Steps
import requests
r = requests.get('https://google.com')
print(len(r.cookies)) # = 3
r.cookies.popitem()
System Information
$ python -m requests.help
{
"chardet": {
"version": "4.0.0"
},
"charset_normalizer": {
"version": "2.0.10"
},
"cryptography": {
"version": "3.4.8"
},
"idna": {
"version": "2.10"
},
"implementation": {
"name": "CPython",
"version": "3.9.1"
},
"platform": {
"release": "10",
"system": "Windows"
},
"pyOpenSSL": {
"openssl_version": "101010cf",
"version": "20.0.1"
},
"requests": {
"version": "2.28.1"
},
"system_ssl": {
"version": "1010107f"
},
"urllib3": {
"version": "1.26.3"
},
"using_charset_normalizer": false,
"using_pyopenssl": true
}
requests.cookies.RequestsCookieJar'spopitem()method doesn't seem to work even if cookies is not empty.Expected Result
From the doc:
(Also, I'm not sure what exactly is "D" here. I assume it means the cookies obj itself.)
Actual Result
It always raises KeyError even when it's not empty.
Reproduction Steps
System Information
{ "chardet": { "version": "4.0.0" }, "charset_normalizer": { "version": "2.0.10" }, "cryptography": { "version": "3.4.8" }, "idna": { "version": "2.10" }, "implementation": { "name": "CPython", "version": "3.9.1" }, "platform": { "release": "10", "system": "Windows" }, "pyOpenSSL": { "openssl_version": "101010cf", "version": "20.0.1" }, "requests": { "version": "2.28.1" }, "system_ssl": { "version": "1010107f" }, "urllib3": { "version": "1.26.3" }, "using_charset_normalizer": false, "using_pyopenssl": true }