Comments (3)
I'd looked at this when the ticket first opened and the typing is due to ambiguity created by our top-level API defaults and the code inside merge_environment_settings.
We imply proxies
can be None and even have some code written around that assumption. I'd personally rather be explicit that we require a Mapping and only a Mapping for this API since it doesn't really work without that. The only downside is a minor performance hit in the case we were previously skipping the merge in merge_settings
. A sufficiently large proxies dictionary may see some performance impact, but I'm not sure that's going to be a noticeable case.
from requests.
How are you encountering this? On which versions? Why did you skip the issue template?
from requests.
Hello! Apologies for not using the template above. I have included it below.
Additionally, I have unearthed more context while working on reproduction steps.
It appears that although the type hint signature in typeshed defines the proxies parameter as optional:
https://github.com/python/typeshed/blob/main/stubs/requests/requests/sessions.pyi#L307
In practice requests fallbacks to an empty dictionary which prevents hitting the issue:
https://github.com/psf/requests/blob/main/src/requests/sessions.py#L577
Expected Result
No Exception to be thrown.
Actual Result
AttributeError: 'NoneType' object has no attribute 'setdefault'
Reproduction Steps
Invoke this code with an environment that has a variable that ends with _PROXY, example:
HELLO_PROXY=abc python script.py
from requests import Request, Session
request = Request(method="GET", url="<https://disney.com")>
session = Session()
prepared_request = session.prepare_request(request)
settings = session.merge_environment_settings(prepared_request.url, None, None, None, None)
response = session.send(prepared_request, **settings)
System Information
{
"chardet": {
"version": null
},
"charset_normalizer": {
"version": "3.3.2"
},
"cryptography": {
"version": ""
},
"idna": {
"version": "3.6"
},
"implementation": {
"name": "CPython",
"version": "3.9.6"
},
"platform": {
"release": "23.2.0",
"system": "Darwin"
},
"pyOpenSSL": {
"openssl_version": "",
"version": null
},
"requests": {
"version": "2.31.0"
},
"system_ssl": {
"version": "20000000"
},
"urllib3": {
"version": "1.26.18"
},
"using_charset_normalizer": true,
"using_pyopenssl": false
}
from requests.
Related Issues (20)
- Connection problems HOT 1
- Request not throwing requests.exceptions.InvalidSchema on custom HTTPAdapter HOT 3
- Requests roadmap HOT 5
- 2.32.0 sdist is missing `tests/certs` HOT 4
- Requests 2.32.0 Not supported URL scheme http+docker HOT 16
- breaking aws s3 usage with requests 2.32.0
- Not supported URL scheme http+docker KOLLA ANSIBLE HOT 1
- SSLV3_ALERT_HANDSHAKE_FAILURE after upgrade from 2.31.0 to 2.32.2 HOT 20
- SSLCertVerificationError - unable to get local issuer certificate HOT 5
- ERROR - Cannot set verify_mode to CERT_NONE when check_hostname is enabled HOT 1
- Enhance Error Messaging for Connection Failures
- Different default values for "allow_redirects" for HEAD http method HOT 4
- Multiple concurrent client certs broken with v2.32.3 HOT 4
- ssl certificate validation of requests was ignored but the ssl certificate still reported an error HOT 1
- ssl certificate validation of requests was ignored but the ssl certificate still reported an error HOT 2
- Certificate loading regression with HTTPAdapters in 2.32.3
- Deprecated `HTTPAdapter.get_connection()` method is never called, causing breakage without deprecation warnings HOT 2
- requests 2.32.3 & urllib3 1.26.18 issue with unicode put HOT 3
- requests 2.32.3 with IPv6 link local address fails with error: [Errno -2] Name or service not known
- 2.32.3 does not load system CA certificates when using an Adapter HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from requests.