forked from pallets-eco/secure-cookie
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drop python 2 and 3.5 (pallets-eco#62)
* update noxfile * remove py2 from setup.cfg * remove specific py2 handling * remove _compat.text_type
- Loading branch information
1 parent
8c91262
commit 87beb8e
Showing
5 changed files
with
19 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,24 @@ | ||
import sys | ||
|
||
PY2 = sys.version_info[0] == 2 | ||
_default_encoding = sys.getdefaultencoding() | ||
|
||
if not PY2: | ||
text_type = str | ||
|
||
def to_bytes(x, charset=_default_encoding, errors="strict"): | ||
if x is None: | ||
return None | ||
|
||
if isinstance(x, (bytes, bytearray, memoryview)): | ||
return bytes(x) | ||
|
||
if isinstance(x, str): | ||
return x.encode(charset, errors) | ||
|
||
raise TypeError("Expected bytes") | ||
|
||
def to_native(x, charset=_default_encoding, errors="strict"): | ||
if x is None or isinstance(x, str): | ||
return x | ||
|
||
return x.decode(charset, errors) | ||
_default_encoding = sys.getdefaultencoding() | ||
|
||
|
||
else: | ||
text_type = unicode # noqa: F821 | ||
def to_bytes(x, charset=_default_encoding, errors="strict"): | ||
if x is None: | ||
return None | ||
|
||
def to_bytes(x, encoding=_default_encoding, errors="strict"): | ||
if x is None: | ||
return None | ||
if isinstance(x, (bytes, bytearray, memoryview)): | ||
return bytes(x) | ||
|
||
if isinstance(x, (bytes, bytearray, buffer)): # noqa: F821 | ||
return bytes(x) | ||
if isinstance(x, str): | ||
return x.encode(charset, errors) | ||
|
||
if isinstance(x, unicode): # noqa: F821 | ||
return x.encode(encoding, errors) | ||
raise TypeError("Expected bytes") | ||
|
||
raise TypeError("Expected bytes") | ||
|
||
def to_native(x, encoding=_default_encoding, errors="strict"): | ||
if x is None or isinstance(x, str): | ||
return x | ||
def to_native(x, charset=_default_encoding, errors="strict"): | ||
if x is None or isinstance(x, str): | ||
return x | ||
|
||
return x.encode(encoding, errors) | ||
return x.decode(charset, errors) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters