Skip to content

Commit

Permalink
Add DeprecationWarnings to inform users of plans
Browse files Browse the repository at this point in the history
After a long discussion in IRC and on several issues, the developers of
requests have decided to remove specific functions from requests.utils
in version 3.0.0. To give users ample time to prepare for this, we've
added DeprecationWarnings long in advance. See also the planning of this
in issue psf#2266.
  • Loading branch information
sigmavirus24 committed Oct 27, 2014
1 parent be805f9 commit d505b94
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions requests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import sys
import socket
import struct
import warnings

from . import __version__
from . import certs
Expand Down Expand Up @@ -287,6 +288,11 @@ def get_encodings_from_content(content):
:param content: bytestring to extract encodings from.
"""
warnings.warn((
'In requests 3.0, get_encodings_from_content will be removed. For '
'more information, please see the discussion on issue #2266. (This'
' warning should only appear once.)'),
DeprecationWarning)

charset_re = re.compile(r'<meta.*?charset=["\']*(.+?)["\'>]', flags=re.I)
pragma_re = re.compile(r'<meta.*?content=["\']*;?charset=(.+?)["\'>]', flags=re.I)
Expand Down Expand Up @@ -354,6 +360,11 @@ def get_unicode_from_response(r):
2. fall back and replace all unicode characters
"""
warnings.warn((
'In requests 3.0, get_unicode_from_response will be removed. For '
'more information, please see the discussion on issue #2266. (This'
' warning should only appear once.)'),
DeprecationWarning)

tried_encodings = []

Expand Down

0 comments on commit d505b94

Please sign in to comment.