Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_fieldstorage_not_multipart fails #446

Open
mtelka opened this issue Jan 16, 2023 · 0 comments
Open

test_fieldstorage_not_multipart fails #446

mtelka opened this issue Jan 16, 2023 · 0 comments

Comments

@mtelka
Copy link

mtelka commented Jan 16, 2023

The test_fieldstorage_not_multipart fails with the following error:

_______ Test_cgi_FieldStorage_Py3_tests.test_fieldstorage_not_multipart ________

self = <test_compat.Test_cgi_FieldStorage_Py3_tests object at 0x7fffa6945950>

    def test_fieldstorage_not_multipart(self):
        from webob.compat import cgi_FieldStorage

        POSTDATA = b'{"name": "Bert"}'

        env = {
            'REQUEST_METHOD': 'POST',
            'CONTENT_TYPE': 'text/plain',
            'CONTENT_LENGTH': str(len(POSTDATA))
        }
        fp = BytesIO(POSTDATA)
>       fs = cgi_FieldStorage(fp, environ=env)

tests/test_compat.py:67:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.7/cgi.py:499: in __init__
    self.read_single()
/usr/lib/python3.7/cgi.py:692: in read_single
    self.read_binary()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = FieldStorage(None, None)

    def read_binary(self):
        """Internal: read binary data."""
        self.file = self.make_file()
        todo = self.length
        if todo >= 0:
            while todo > 0:
                data = self.fp.read(min(todo, self.bufsize)) # bytes
                if not isinstance(data, bytes):
                    raise ValueError("%s should return bytes, got %s"
                                     % (self.fp, type(data).__name__))
                self.bytes_read += len(data)
                if not data:
                    self.done = -1
                    break
                if self._binary_file:
                    self.file.write(data)
                else:
>                   self.file.write(data.decode())
E                   TypeError: a bytes-like object is required, not 'str'

/usr/lib/python3.7/cgi.py:717: TypeError

Tested with WebOb-1.8.7. The test fails with both Python 3.7.16 and Python 3.9.16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant