Browse Source

Switched to deepcopy for session

pull/2936/head
Dave Chevell 6 years ago
parent
commit
83b258acc5
No known key found for this signature in database
GPG Key ID: 279DF1B52C7C44DC
  1. 3
      flask/ctx.py
  2. 4
      tests/test_reqctx.py

3
flask/ctx.py

@ -11,6 +11,7 @@
import sys
from functools import update_wrapper
from copy import deepcopy
from werkzeug.exceptions import HTTPException
@ -152,7 +153,7 @@ def copy_current_request_context(f):
'when a request context is on the stack. For instance within '
'view functions.')
reqctx = top.copy()
reqctx.session = session.copy()
reqctx.session = deepcopy(session)
def wrapper(*args, **kwargs):
with reqctx:
return f(*args, **kwargs)

4
tests/test_reqctx.py

@ -14,6 +14,8 @@ import pytest
import flask
from flask.sessions import SessionInterface
from copy import deepcopy
try:
from greenlet import greenlet
except ImportError:
@ -158,7 +160,7 @@ class TestGreenletContextCopying(object):
def index():
flask.session['fizz'] = 'buzz'
reqctx = flask._request_ctx_stack.top.copy()
reqctx.session = flask.session.copy()
reqctx.session = deepcopy(flask.session)
def g():
assert not flask.request

Loading…
Cancel
Save