GithubHelp home page GithubHelp logo

Comments (4)

cdent avatar cdent commented on June 24, 2024

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.

cdent avatar cdent commented on June 24, 2024

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.

pupssman avatar pupssman commented on June 24, 2024

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.

pupssman avatar pupssman commented on June 24, 2024

Will go on with PR soon!

from wsgi-intercept.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.