Error when passing CookieJar to Session via PreparedRequest

I'm using requests 2.11.1. The following code throws an exception:

```
from requests import Request, Session
from http.cookiejar import CookieJar

cj = CookieJar()
req = Request('GET', 'http://google.com', cookies=cj).prepare()
resp = Session().send(req)
```

The exception is:

```
Traceback (most recent call last):
  File "test.py", line 6, in <module>
    resp = Session().send(req)
  File "C:\Anaconda3\lib\site-packages\requests\sessions.py", line 617, in send
    history = [resp for resp in gen] if allow_redirects else []
  File "C:\Anaconda3\lib\site-packages\requests\sessions.py", line 617, in <listcomp>
    history = [resp for resp in gen] if allow_redirects else []
  File "C:\Anaconda3\lib\site-packages\requests\sessions.py", line 159, in resolve_redirects
    prepared_request._cookies.update(self.cookies)
AttributeError: 'CookieJar' object has no attribute 'update'
```

I'm able to avoid this by using `Session.prepare_request` or by passing the cookies via `Session.cookies`.


Thanks for opening this issue, @agacek. So the problem we're encountering here is a difference in how we "prepare" the CookieJar between a `PreparedRequest` and a `Session`.

`Session` will always [merge the cookies into a fresh `RequestsCookieJar`](https://github.com/kennethreitz/requests/blob/master/requests/sessions.py#L375-L376) when `prepare_request()` is called. `RequestsCookieJar` will have the update method, and is a subclass of `cookielib.CookieJar` so everything works fine.

`PreparedRequest` however doesn't perform this same merge, and won't modify the CookieJar if it's an instance of cookielib.CookieJar, so this one remains untouched. I'm not sure if this was an intentional feature of `PreparedRequest` to allow people to do what they wanted, or if it was an oversight. The code base is obviously expecting `cookies` to be `RequestsCookieJar`-like now though. If we're enforcing this in Session, we should probably also implement the same logic in `prepare_cookies` for the `PreparedRequest`. The user can always override the `cookies` param with their own CookieJar after if needed.

@agacek as an interim fix, I would suggest you either use the [`RequestsCookieJar`](https://github.com/kennethreitz/requests/blob/master/requests/cookies.py#L172) class instead of `http.cookiejar.CookieJar`, or use the [`merge_cookies`](https://github.com/kennethreitz/requests/blob/master/requests/cookies.py#L521) function to merge your existing `CookieJar` into a new `RequestsCookieJar`. You can, of course, also continue using `Session.prepare_request()` too. Hope that helps!


Another quick thought, if we don't want to coerce a `CookieJar` into a `RequestsCookieJar`, we could also replace the [line](https://github.com/kennethreitz/requests/blob/master/requests/sessions.py#L159) in `resolve_redirects` with `merge_cookies` to catch this error.

It seems odd to me though to subtly create a new object in `Session`, but not do this consistently in `PreparedRequest`. This isn't the first time this behaviour has been problematic (#3416).


We may need to tolerate having non-RequestsCookieJar cookiejars provided during the PreparedRequest flow. It may be that the best way to do that is to duplicate the `update` method into a helper in `cookies.py` which we can use.


I believe that's what [this portion](https://github.com/kennethreitz/requests/blob/master/requests/cookies.py#L533-L538) of `merge_cookies` is doing. Were you suggesting moving that logic out into another helper function to avoid the extra conditionals?


Hrm, I hadn't noticed that. `merge_cookies` is _probably_ the right choice here, yes.


This should be resolved with #3591.