Skip to content
Myr

Fix tried_encodings scope

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

authored by Rick Mak · committed by Rick Mak · parent 820e2c7 · Browse files · 1 file+4 added−3 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+4 added−3 removed

  • other:+4 added−3 removed

1 file+4 added−3 removed

modified:requests/models.py+4 added-3 removed
428 unmodified lines
429 1. charset from content-type430 2. every encodings from <meta ... charset=XXX>431 3. fall back and replace all unicode characters432 """433 tried_encodings = []434 # Try charset from content-type435 encoding = self.get_encoding_from_content_type()436 if encoding:437 try:438 return unicode(content, encoding)439 except UnicodeError:439 self.tried_encodings.append(encoding)440 tried_encodings.append(encoding)441442 # Try every encodings from <meta ... charset=XXX>443 encodings = self.get_encodings_from_content(content)444 for encoding in encodings:444 if encoding in self.tried_encodings:445 if encoding in tried_encodings:446 continue447 try:448 return unicode(content, encoding)449 except UnicodeError:449 self.tried_encodings.append(encoding)450 tried_encodings.append(encoding)451452 # Fall back:453 return unicode(content, encoding, errors="replace")454
176 unmodified lines