Requests: 'NoneType' object has no attribute 'readline'

Created on 10 Jan 2017  Â·  31Comments  Â·  Source: psf/requests

Tried a quick check of open issues, but wasn't sure what to search for on this.

Here's the code to reproduce:

import shutil
import requests
import os

session = requests.Session()

# it has something to do with content on the 302 from this url
u = 'http://www.amazon.com/gp/redirect.html/ref=gw_m_b_ir?_encoding=UTF8&location=http%3A%2F%2Fphx.corporate-ir.net%2Fphoenix.zhtml%3Fc%3D97664%26p%3Dirol-irhome&source=standards&token=F9CAD8A11D4336B5E0B3C3B089FA066D0A467C1C'
r0 = session.get(u, stream=True, allow_redirects=False)
redirects = session.resolve_redirects(r0, r0.request, stream=True)

for redirect in redirects:
    with open(os.devnull, 'wb') as devnull:
        shutil.copyfileobj(redirect.raw, devnull)

Gives me the traceback:

(tmp-91018d725433cf2c) gsbrown$ python bug.py
Traceback (most recent call last):
  File "bug.py", line 11, in <module>
    for redirect in redirects:
  File "/Users/gsbrown/.virtualenvs/tmp-91018d725433cf2c/lib/python2.7/site-packages/requests/sessions.py", line 106, in resolve_redirects
    resp.content  # Consume socket so it can be released
  File "/Users/gsbrown/.virtualenvs/tmp-91018d725433cf2c/lib/python2.7/site-packages/requests/models.py", line 781, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
  File "/Users/gsbrown/.virtualenvs/tmp-91018d725433cf2c/lib/python2.7/site-packages/requests/models.py", line 703, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "/Users/gsbrown/.virtualenvs/tmp-91018d725433cf2c/lib/python2.7/site-packages/requests/packages/urllib3/response.py", line 428, in stream
    for line in self.read_chunked(amt, decode_content=decode_content):
  File "/Users/gsbrown/.virtualenvs/tmp-91018d725433cf2c/lib/python2.7/site-packages/requests/packages/urllib3/response.py", line 590, in read_chunked
    self._update_chunk_length()
  File "/Users/gsbrown/.virtualenvs/tmp-91018d725433cf2c/lib/python2.7/site-packages/requests/packages/urllib3/response.py", line 532, in _update_chunk_length
    line = self._fp.fp.readline()
AttributeError: 'NoneType' object has no attribute 'readline'

The redirect url is significant. It doesn't happen with the httpbin ones.

All 31 comments

FYI:

$ pip list
pip (1.5.4)
requests (2.12.4)
setuptools (2.2)
wsgiref (0.1.2)

Just a quick note... I can't really help with your issue directly, as it goes beyond my knowledge.

Just thought I'd mention that pip is up to version 9.0.1... pip 1.5.4 is nearly 3 years old. I'd strongly suggest look at why you're using such an old version of pip

Ha. I just like old stuff. :) Can you reproduce the bug?

I can when using python 2.7.12

I can't replicate with python 3.5 though.

Are you going to tell me to upgrade to Python 3.5? ;)

Hey @gilessbrown, thanks for opening this issue! This behaviour was exposed by a change made in (327512f) which removed exception handling for this case. It currently only exists in the 2.12.x releases, so using Requests 2.11.1 should work for you.

While you're seeing this behaviour in Requests, it actually seems to be how we're handling chunked responses without a body in urllib3. shazow/urllib3#990 introduced an attempt to catch this problem but the check is just slightly off. While it verifies the existence to fp, it doesn't check that fp isn't None.

I think the simple fix here is to change the check in urllib3 to return getattr(self._fp, 'fp', None) is not None which should give us what we actually want. It verifies that fp both exists, and is not the default None value.

If @Lukasa or @sigmavirus24 are in agreement, we can address this over in urllib3.

Also, I'm able to produce this in both Python 2.7 and 3.5.

Aha - My 3.5 runtime was using requests 2.11.x, which is why it worked

Thanks for the tip on Request 2.11.1 and for investigating the issue. I think I’ll follow your suggestion.

While you're seeing this behaviour in Requests, it actually seems to be how we're handling chunked responses without a body in urllib3.

Hang on. Chunked responses without a body are not a thing. The only time they're allowed is in response to a HEAD request, where the body must not be sent. Otherwise, if Transfer-Encoding: chunked is set then there must be a chunk body.

I'd say the server is at fault here.

I'd say the server is at fault here.

I can't reproduce this with 2.12.4 on Python 2.7.12 ...

What I am seeing, however, is that the URL provided redirects to

https://www.amazon.com/gp/redirect.html/ref=gw_m_b_ir?_encoding=UTF8&location=http%3A%2F%2Fphx.corporate-ir.net%2Fphoenix.zhtml%3Fc%3D97664%26p%3Dirol-irhome&source=standards&token=F9CAD8A11D4336B5E0B3C3B089FA066D0A467C1C

Which results in another 302 with Transfer-Encoding: chunked. If I access the content on that response, I get '\n'.

>>> r.headers
{'x-amz-id-1': 'V7C8AQ04FPXYP69MGHPS', 'Content-Encoding': 'gzip', 'Transfer-Encoding': 'chunked', 'Strict-Transport-Security': 'max-age=47474747; includeSubDomains; preload', 'Vary': 'Accept-Encoding,User-Agent', 'Server': 'Server', 'Connection': 'keep-alive', 'Location': 'http://phx.corporate-ir.net/phoenix.zhtml?c=97664&p=irol-irhome', 'Date': 'Wed, 11 Jan 2017 12:48:59 GMT', 'p3p': 'policyref="https://www.amazon.com/w3c/p3p.xml",CP="CAO DSP LAW CUR ADM IVAo IVDo CONo OTPo OUR DELi PUBi OTRi BUS PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA HEA PRE LOC GOV OTC "', 'Content-Type': 'text/html; charset=ISO-8859-1', 'x-frame-options': 'SAMEORIGIN'}
>>> r.content
'\n'

After that, I get a 200. So in a virtualenv with 2.12.4 on Python 2.7.12 (and on Fedora 25) I get no issues. I'm curious what's different in what y'all are using that you're seeing this.

I'd say the server is at fault here.

I completely agree the server isn't compliant here, but we also just said we'd like to be tolerant of things like this in #3794, which is even more out of spec. The server is definitely returning garbage though, so maybe we choose not to address this.

@sigmavirus24 I'm currently able to reproduce this on Python 2.7.12 and 3.5.2 on Mac OS 10.12.2, Ubuntu 12.04, and Travis.

The repro won't fail if you start it at the second hop (the https url), so it seems to require this specific set of responses. It's definitely related to the transfer-encoding because chaining a similar set of responses ((http)302->(https)302->(separate server)200) from httpbin won't trigger the failure.

This "bug" was introduced in Requests 2.7.0 (urllib3 1.10.4) but masked by two separate try/except AssertionError blocks. The first was removed in 2.8.0 in c6c8d64 but this didn't expose the issue because the content exception block was still catching it. 327512f removed the second safeguard which is why 2.12.x is now showing this. I backported 327512f and was able to confirm this only started happening after the chunk transfer work in urllib3 1.10.4. Something causes the underlying socket closed before we can read it for the redirect, but I wasn't able to immediately find what.

At this point this is probably too much digging for a pretty uncommon edge case, but I'll let you two decide.

I understand that streaming from the intermediate redirects is a little exotic. For the record I want to note that the server behaviour is not especially exotic. With tweaked sample to pass the url ...

(requestsbug$ python bug.py http://localad.homedepot.com/
Traceback (most recent call last):
  File "bug.py", line 8, in <module>
    bug.main()
  File "/Users/gsbrown/bug.py", line 28, in main
    stream_redirects(url)
  File "/Users/gsbrown/bug.py", line 21, in stream_redirects
    for redirect in redirects:
  File "/Users/gsbrown/.virtualenvs/requestsbug/lib/python2.7/site-packages/requests/sessions.py", line 106, in resolve_redirects
    resp.content  # Consume socket so it can be released
  File "/Users/gsbrown/.virtualenvs/requestsbug/lib/python2.7/site-packages/requests/models.py", line 781, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
  File "/Users/gsbrown/.virtualenvs/requestsbug/lib/python2.7/site-packages/requests/models.py", line 703, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "/Users/gsbrown/.virtualenvs/requestsbug/lib/python2.7/site-packages/requests/packages/urllib3/response.py", line 428, in stream
    for line in self.read_chunked(amt, decode_content=decode_content):
  File "/Users/gsbrown/.virtualenvs/requestsbug/lib/python2.7/site-packages/requests/packages/urllib3/response.py", line 590, in read_chunked
    self._update_chunk_length()
  File "/Users/gsbrown/.virtualenvs/requestsbug/lib/python2.7/site-packages/requests/packages/urllib3/response.py", line 532, in _update_chunk_length
    line = self._fp.fp.readline()
AttributeError: 'NoneType' object has no attribute 'readline'

Extra info about the previous run:
```
(requestsbug)$ pip list --format=columns
Package Version


pip 9.0.1
requests 2.12.4
setuptools 2.2
(requestsbug)$ python --version
Python 2.7.10```

And the downgrade does not generate the traceback:

(requestsbug)$ pip install requests==2.11.1
Collecting requests==2.11.1
  Using cached requests-2.11.1-py2.py3-none-any.whl
Installing collected packages: requests
  Found existing installation: requests 2.12.4
    Uninstalling requests-2.12.4:
      Successfully uninstalled requests-2.12.4
Successfully installed requests-2.11.1
(requestsbug)$ python bug.py http://localad.homedepot.com/
(requestsbug)$

There's nothing unexpected about streaming the intermediate response. We're fine with you doing that. What's wrong is the form of that intermediate response. Allow me to reproduce it for you here (using the original example):

HTTP/1.1 302 MovedTemporarily
Server: Server
Date: Wed, 11 Jan 2017 17:06:17 GMT
Content-Type: text/html; charset=ISO-8859-1
Transfer-Encoding: chunked
Connection: keep-alive
Strict-Transport-Security: max-age=47474747; includeSubDomains; preload
x-amz-id-1: PF9SK6WE9FGKS0FV29ED
p3p: policyref="https://www.amazon.com/w3c/p3p.xml",CP="CAO DSP LAW CUR ADM IVAo IVDo CONo OTPo OUR DELi PUBi OTRi BUS PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA HEA PRE LOC GOV OTC "
x-frame-options: SAMEORIGIN
Location: http://phx.corporate-ir.net/phoenix.zhtml?c=97664&p=irol-irhome
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip

\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\xe2\x02\x00\x00\x00\xff\xff\x03\x00\x93\x06\xd72\x01\x00\x00\x00

(I have had to hex encode the body to print it out, because it's not valid ASCII)

Note that this response says Transfer-Encoding: chunked, and then provides a non-chunk-encoded body. That body does not obey chunked transfer encoding. This is an error condition. The traceback is not wrong. There is no way to safely read this body. That means your attempt to redirect that body into a file must fail.

I cannot stress this enough: there is no way Requests can "tolerate" this if you ask us for the body because we cannot read the body. It is an invalid HTTP/1.1 response, and we cannot tell when the body is supposed to end. The problem here is not the traceback. If anything, the fact that it "works" in the older case is the actual bug, because we are pretending to the user that everything is fine when in fact it is very much not fine.

If you are going to handle redirects yourself, then you must be prepared to do what Requests does when it receives a bad body on a redirect response, which is swallow them. It is not our job to swallow them for you when you indicated you want the actual response. We are giving you the response: it is the server's fault that the response is invalid. Please take it up with them.

I should note that I would be prepared to accept a PR on urllib3 to provide a better exception in this case, because really we should be emitting a urllib3-specific exception here.

Hrm. Further investigation suggests that the chunked transfer encoding here is actually fine. I managed to pull out some specific chunked encoding from curl that works just fine, as does the httplib code. So, new question: why is the urllib3 code getting this wrong?

Ack, I suspect I know why. We're consuming the content twice. If you eat the data via response.raw, resolve_redirects goes to consume it again and gets all wibbly and confused because it doesn't know that you already did. This can be seen by modifying the originally posted code to (note the additional line at the bottom):

import requests
import os

session = requests.Session()

# it has something to do with content on the 302 from this url
u = 'http://www.amazon.com/gp/redirect.html/ref=gw_m_b_ir?_encoding=UTF8&location=http%3A%2F%2Fphx.corporate-ir.net%2Fphoenix.zhtml%3Fc%3D97664%26p%3Dirol-irhome&source=standards&token=F9CAD8A11D4336B5E0B3C3B089FA066D0A467C1C'
r0 = session.get(u, stream=True, allow_redirects=False)
redirects = session.resolve_redirects(r0, r0.request, stream=True)

for redirect in redirects:
    with open(os.devnull, 'wb') as devnull:
        shutil.copyfileobj(redirect.raw, devnull)
    redirect._content = b''

So, iter_content flags this by setting response._content_consumed = True when it has finished iterating.

I suspect the real culprit here is urllib3's custom chunking code, which does not check whether it believes the response is complete or not (in this case, it is, and so it should be short-circuit returning). I think that's a bug on urllib3.

See shazow/urllib3#1088. In the meantime, I recommend a workaround when using response.raw when iterating redirects that you set _content_consumed to True if you have, in fact, consumed the content. Closing in favour of the urllib3 bug.

Hi @Lukasa, your analysis of it being caused by the double consumption of raw (first by the copyfileobj, and then by the response.content in resolve_redirects) matches what I saw in the debugger so I'm pretty confident your work-around of setting ._content will work for me. Thanks for your deep dive into this.

Could someone change this subject to "'NoneType' object has no attribute 'readline'" ?

I ran into the same issue, and the SEO on this pushed it down a bit on search results.

From my tests so far, I believe the ._content_consumed flag needs to be set to true if anything is read off the socket during a redirect resolve (ie a header not just "content"). My workaround is to place a "#TODO" pointing to this issue in my code, and consuming all the content + setting the flag at that point.

@jvanasco Reading the headers should not require _content_consumed to be True. If it did, the _content_consumed flag would be entirely redundant, because we never create a Response object without having already read the headers.

hm. I'm not sure what happened. I tracked my error down to a custom redirect resolver. while the block does consume content, I was getting an error on cases that exited out before then. the only thing accessed on those was the headers/status.

i added these 2 lines to the top of the block, and all the edges passed:

    ...
    touched = resp.content
    resp._content_consumed = True
    ...

i'm far too busy to look deeper into this, but I'll make a note and try to investigate on my free time.

oh! thanks for the input and making the title more SEO friendly!

Howdy, I'm not clear – was this resolved? I'm on requests==2.18.4 with python 3.5.1 and still seeing this issue.

Specifically,

 File "/Users/foo/Code/dev/myapp/brain/network.py", line 56, in expand_url
    return get(url)
  File "/Users/foo/Code/dev/myapp/brain/network.py", line 27, in get
    return requests.get(url, headers=get_headers(), timeout=20, allow_redirects=True)
  File "/Users/foo/Code/dev/venv/lib/python3.5/site-packages/requests/api.py", line 72, in get
    return request('get', url, params=params, **kwargs)
  File "/Users/foo/Code/dev/venv/lib/python3.5/site-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/Users/foo/Code/dev/venv/lib/python3.5/site-packages/requests/sessions.py", line 508, in request
    resp = self.send(prep, **send_kwargs)
  File "/Users/foo/Code/dev/venv/lib/python3.5/site-packages/requests/sessions.py", line 640, in send
    history = [resp for resp in gen] if allow_redirects else []
  File "/Users/foo/Code/dev/venv/lib/python3.5/site-packages/requests/sessions.py", line 640, in <listcomp>
    history = [resp for resp in gen] if allow_redirects else []
  File "/Users/foo/Code/dev/venv/lib/python3.5/site-packages/requests/sessions.py", line 218, in resolve_redirects
    **adapter_kwargs
  File "/Users/foo/Code/dev/venv/lib/python3.5/site-packages/requests/sessions.py", line 658, in send
    r.content
  File "/Users/foo/Code/dev/venv/lib/python3.5/site-packages/requests/models.py", line 823, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
  File "/Users/foo/Code/dev/venv/lib/python3.5/site-packages/requests/models.py", line 745, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "/Users/foo/Code/dev/venv/lib/python3.5/site-packages/urllib3/response.py", line 432, in stream
    for line in self.read_chunked(amt, decode_content=decode_content):
  File "/Users/foo/Code/dev/venv/lib/python3.5/site-packages/urllib3/response.py", line 598, in read_chunked
    self._update_chunk_length()
  File "/Users/foo/Code/dev/venv/lib/python3.5/site-packages/urllib3/response.py", line 540, in _update_chunk_length
    line = self._fp.fp.readline()
AttributeError: 'NoneType' object has no attribute 'readline'

Thank you for any insight.

Hey @zefoo, this is an issue in urllib3 which is a layer beneath Requests. The issue is being tracked in shazow/urllib3#1088, but I don't know if any progress has been made. I would recommend upgrading to the latest version of urllib3 and if the issue persists, follow up there. Thanks!

Using requests with any common user-agent I hit the same bug at: http://forbes.com:

import requests

session = requests.Session()
resp = session.get('http://forbes.com', headers={'User-Agent': 'Mozilla/5.0'})

The stacktrace:

AttributeError                            Traceback (most recent call last)                                                                                                                            
<ipython-input-8-a73f5204685b> in <module>()                                                                                                                                                           
----> 1 resp = session.get('http://forbes.com', headers={'User-Agent': 'Mozilla/5.0'})                                                                                                                 

~/.virtualenvs/test/lib/python3.6/site-packages/requests/sessions.py in get(self, url, **kwargs)                                                                                                
    519                                                                                                                                                                                                
    520         kwargs.setdefault('allow_redirects', True)                                                                                                                                             
--> 521         return self.request('GET', url, **kwargs)                                                                                                                                              
    522                                                                                                                                                                                                
    523     def options(self, url, **kwargs):                                                                                                                                                          

~/.virtualenvs/test/lib/python3.6/site-packages/requests/sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream
, verify, cert, json)                                                                                                                                                                                  
    506         }                                                                                                                                                                                      
    507         send_kwargs.update(settings)                                                                                                                                                           
--> 508         resp = self.send(prep, **send_kwargs)                                                                                                                                                  
    509                                                                                                                                                                                                
    510         return resp                                                                                                                                                                            

~/.virtualenvs/test/lib/python3.6/site-packages/requests/sessions.py in send(self, request, **kwargs)                                                                                           
    638                                                                                                                                                                                                
    639         # Resolve redirects if allowed.                                                                                                                                                        
--> 640         history = [resp for resp in gen] if allow_redirects else []                                                                                                                            
    641                                                                                                                                                                                                
    642         # Shuffle things around if there's history.                                                                                                                                            

~/.virtualenvs/test/lib/python3.6/site-packages/requests/sessions.py in <listcomp>(.0)                                                                                                          
    638                                                                                                                                                                                                
    639         # Resolve redirects if allowed.                                                                                                                                                        
--> 640         history = [resp for resp in gen] if allow_redirects else []                                                                                                                            
    641                                                                                                                                                                                                
    642         # Shuffle things around if there's history.                                                                                                                                            

~/.virtualenvs/test/lib/python3.6/site-packages/requests/sessions.py in resolve_redirects(self, resp, req, stream, timeout, verify, cert, proxies, yield_requests, **adapter_kwargs)
    216                     proxies=proxies,
    217                     allow_redirects=False,
--> 218                     **adapter_kwargs
    219                 )
    220 

~/.virtualenvs/test/lib/python3.6/site-packages/requests/sessions.py in send(self, request, **kwargs)
    656 
    657         if not stream:
--> 658             r.content
    659 
    660         return r

~/.virtualenvs/test/lib/python3.6/site-packages/requests/models.py in content(self)
    821                 self._content = None
    822             else:
--> 823                 self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
    824 
    825         self._content_consumed = True

~/.virtualenvs/test/lib/python3.6/site-packages/requests/models.py in generate()
    743             if hasattr(self.raw, 'stream'):
    744                 try:
--> 745                     for chunk in self.raw.stream(chunk_size, decode_content=True):
    746                         yield chunk
    747                 except ProtocolError as e:

~/.virtualenvs/test/lib/python3.6/site-packages/urllib3/response.py in stream(self, amt, decode_content)
    430         """
    431         if self.chunked and self.supports_chunked_reads():
--> 432             for line in self.read_chunked(amt, decode_content=decode_content):
    433                 yield line
    434         else:

~/.virtualenvs/test/lib/python3.6/site-packages/urllib3/response.py in read_chunked(self, amt, decode_content)
    596         with self._error_catcher():
    597             while True:
--> 598                 self._update_chunk_length()
    599                 if self.chunk_left == 0:
    600                     break

~/.virtualenvs/test/lib/python3.6/site-packages/urllib3/response.py in _update_chunk_length(self)
    538         if self.chunk_left is not None:
    539             return
--> 540         line = self._fp.fp.readline()
    541         line = line.split(b';', 1)[0]
    542         try:

AttributeError: 'NoneType' object has no attribute 'readline'

This is the wget output:

--2018-05-31 20:39:04--  http://forbes.com/
Resolving forbes.com... 151.101.2.49
Connecting to forbes.com|151.101.2.49|:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 301 Moved Permanently
  Server: Varnish
  Retry-After: 0
  Content-Length: 0
  Location: https://forbes.com/
  Accept-Ranges: bytes
  Date: Fri, 01 Jun 2018 03:39:04 GMT
  Via: 1.1 varnish
  Connection: close
  X-Served-By: cache-pao17432-PAO
  X-Cache: HIT
  X-Cache-Hits: 0
  X-Timer: S1527824344.292472,VS0,VE0
  Access-Control-Allow-Credentials: true
Location: https://forbes.com/ [following]
--2018-05-31 20:39:04--  https://forbes.com/
Connecting to forbes.com|151.101.2.49|:443... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 302 Found
  Server: Varnish
  Accept-Ranges: bytes
  location: https://www.forbes.com/forbes/welcome/?toURL=https://forbes.com/&refURL=&referrer=
  X-Frame-Options: SAMEORIGIN
  X-Cicero-Cache: MISS
  Content-Security-Policy: upgrade-insecure-requests
  Strict-Transport-Security: max-age=0; includeSubDomains
  Accept-Ranges: bytes
  Date: Fri, 01 Jun 2018 03:39:04 GMT
  Via: 1.1 varnish
  X-Served-By: cache-pao17451-PAO
  X-Cache: MISS
  X-Cache-Hits: 0
  X-Timer: S1527824344.332493,VS0,VE269
  Vary: X-ABtesting
  Access-Control-Allow-Credentials: true
  Connection: close
Location: https://www.forbes.com/forbes/welcome/?toURL=https://forbes.com/&refURL=&referrer= [following]
--2018-05-31 20:39:04--  https://www.forbes.com/forbes/welcome/?toURL=https://forbes.com/&refURL=&referrer=
Resolving www.forbes.com... 151.101.190.49
Connecting to www.forbes.com|151.101.190.49|:443... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 200 OK
  Content-Type: text/html;charset=utf-8
  Content-Language: en-US
  Server:
  Backend: templates
  X-YourTtl: 300.000
  X-Frame-Options: SAMEORIGIN
  X-Cicero-Cache: HIT 4
  Content-Security-Policy: upgrade-insecure-requests
  Strict-Transport-Security: max-age=10886400; includeSubDomains; preload
  Accept-Ranges: bytes
  Date: Fri, 01 Jun 2018 03:39:04 GMT
  Via: 1.1 varnish
  X-Served-By: cache-pao17438-PAO
  X-Cache: MISS
  X-Cache-Hits: 0
  X-Timer: S1527824345.632429,VS0,VE68
  Vary: Accept-Encoding, X-ABtesting
  Access-Control-Allow-Credentials: true
  Set-Cookie: client_id=442dfb7dc29c1468da4ee0432b04ab7cb1b; Path=/; Domain=.forbes.com; Expires=Sun, 31 May 2020 03:39:04 GMT
  Connection: close
Length: unspecified [text/html]

This is for:

requests==2.18.4
urllib3==1.22

However, I've even tried with urlib3-dev which has the fix for urllib3/urllib3#1088 merged and the issue still persists.

Hi @mjuarezm, if you can verify that you're using the dev version of urllib3, both with the warning we emit "RequestsDependencyWarning: urllib3 (dev) or chardet (3.0.4) doesn't match a supported version!" and with the contents of requests.packages.urllib3.__version__ being "dev", you'll want to open a new ticket since this is 18 months old. I'm unable to reproduce the issue with what you've provided with the current master branch of urllib3, so we'll need more information about your system.

@nateprewitt I'm sorry, I was installing requests from master branch using pip and didn't realize that it was automatically uninstalling urllib3-dev and installing urllib3. I made sure to use urllib3-dev and I get a status code 200 as expected. Thanks!

This is a python2 python3 version incompatible error. out.readline is only py2 PEP usage.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xsren picture xsren  Â·  3Comments

8key picture 8key  Â·  3Comments

remram44 picture remram44  Â·  4Comments

avinassh picture avinassh  Â·  4Comments

brainwane picture brainwane  Â·  3Comments