Skip to content
Myr

only try to decode if self.encoding is set

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Kenneth Reitz · committed by Kenneth Reitz · parent 49a38ac · Browse files · 1 file+10 added−10 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+10 added−10 removed

  • other:+10 added−10 removed

1 file+10 added−10 removed

modified:requests/models.py+10 added-10 removed
709 unmodified lines
710 def text(self):711 """Content of the response, in unicode."""712713 # Try charset from content-type714714 content = u''715716 if self.encoding:717 try:718 content = unicode(self.content, self.encoding)719 except UnicodeError:720 pass717 try:718 content = unicode(self.content, self.encoding)719 except UnicodeError:720 pass721722 # Try to fall back:723 try:724 content = unicode(content, self.encoding, errors='replace')725 except TypeError:726 pass722 # Try to fall back:723 try:724 content = unicode(content, self.encoding, errors='replace')725 except TypeError:726 pass727728 return content729730
16 unmodified lines