Comments (4)
Thanks for the report. I'll need to investigate the history of why wsgi.errors is set to that. sys.stderr
may very well be the right thing, but I'll need to do some remembering first. If it proves to be the right thing a pull request would be great.
If you have a minimal test case that demonstrates the problem that you can share that would be great.
from wsgi-intercept.
The use of BytesIO
pre-dates my maintenance of wsgi-intercept
and its migration to become simpler and support Python 3. So I can't find any history as to why it is that, other than "it's a good way to swallow stuff".
Setting it to sys.stderr
looks like the right thing to do, especially given pep 3333's implication that that it is the norm.
So if you have the time to make a pull request that would be great and I'll get it merged and released asap.
from wsgi-intercept.
Here is the MVE:
import flask
import requests
from wsgi_intercept.interceptor import RequestsInterceptor
app = flask.Flask(__name__)
@app.route('/')
def foo():
# cause a KeyError
return flask.jsonify({}['foo'])
def test_foo():
with RequestsInterceptor(lambda: app, host='foo.com', port=80) as url:
r = requests.get(url)
assert r.status_code == 200
Running it causes the error:
(py27) pupssman@pupssman-ub:~/git/wsgi_interseptor_51_mve $ py.test test.py
===================================================================================================================================================== test session starts =====================================================================================================================================================
platform linux2 -- Python 2.7.12, pytest-2.9.0, py-1.4.34, pluggy-0.3.1
rootdir: /home/pupssman/git/wsgi_interseptor_51_mve, inifile:
collected 1 items
test.py F
========================================================================================================================================================== FAILURES ===========================================================================================================================================================
__________________________________________________________________________________________________________________________________________________________ test_foo ___________________________________________________________________________________________________________________________________________________________
def test_foo():
with RequestsInterceptor(lambda: app, host='foo.com', port=80) as url:
r = requests.get(url)
> assert r.status_code == 200
E assert 500 == 200
E + where 500 = <Response [500]>.status_code
test.py:20: AssertionError
---------------------------------------------------------------------------------------------------------------------------------------------------- Captured stderr call -----------------------------------------------------------------------------------------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 882, in emit
stream.write(fs % msg)
TypeError: 'unicode' does not have the buffer interface
Logged from file app.py, line 1560
================================================================================================================================================== 1 failed in 0.12 seconds ===================================================================================================================================================
(py27) pupssman@pupssman-ub:~/git/wsgi_interseptor_51_mve $
from wsgi-intercept.
Will go on with PR soon!
from wsgi-intercept.
Related Issues (20)
- Feature request: Add optional before_intercept and after_intercept callbacks HOT 8
- kwarg error when $http_proxy is set in environ HOT 7
- Including LICENSE file in the code repository and Adding it in the Manifest file HOT 4
- unexpected keyword argument 'source_address' HOT 3
- Please allow to disable internet tests HOT 3
- wsgi_intercept.make_environ turns headers into unicode HOT 3
- When using the url arg to an Interceptor, if there is no port in the url an error happens
- wsgi-intercept should build in some character encoding checks
- Write ignores response body when first item in iterable is an empty string HOT 1
- urllib3 intercept cause TypeError with https URL HOT 8
- Interceptor.uninstall_interceptor turns off intercept for all intercepts using the same module
- Pypi sdist tarball doesn't have README.rst HOT 3
- Missing 2 required positional arguments: 'environ' and 'start_response' with Django 2.2 HOT 4
- With httplib2 0.14.0 many tests fail HOT 9
- HTTPS connections with Requests library don't support verify=False to outside domains HOT 7
- Support aiohttp HOT 2
- Simple example fails with Python 2 HOT 5
- PEP517 HOT 4
- Incompatibility with pytest 7.2.0 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 wsgi-intercept.