summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Bishop <stuart.bishop@canonical.com>2016-07-13 20:18:43 +0700
committerStuart Bishop <stuart.bishop@canonical.com>2016-07-13 20:18:43 +0700
commitda34db62c844307ff170e130cfd0c2d2b33df7bb (patch)
tree4354a22d212bde589d4e83d007cebd529e2eba56
parentcf9934f7490ceb2ea0d72a13c98a89c2615daa18 (diff)
downloadpytz-git-da34db62c844307ff170e130cfd0c2d2b33df7bb.tar.gz
Prefer ASCII to US-ASCII for performance reasons (lp:1523110) [Ville Skyttä]release_2016.6
-rw-r--r--src/pytz/__init__.py4
-rw-r--r--src/pytz/tests/test_docs.py2
-rw-r--r--src/pytz/tzfile.py4
3 files changed, 5 insertions, 5 deletions
diff --git a/src/pytz/__init__.py b/src/pytz/__init__.py
index 0a364d0..cc75080 100644
--- a/src/pytz/__init__.py
+++ b/src/pytz/__init__.py
@@ -52,7 +52,7 @@ except NameError: # Python 3.x
...
UnicodeEncodeError: ...
"""
- s.encode('US-ASCII') # Raise an exception if not ASCII
+ s.encode('ASCII') # Raise an exception if not ASCII
return s # But return the original string - not a byte string.
else: # Python 2.x
@@ -68,7 +68,7 @@ else: # Python 2.x
...
UnicodeEncodeError: ...
"""
- return s.encode('US-ASCII')
+ return s.encode('ASCII')
def open_resource(name):
diff --git a/src/pytz/tests/test_docs.py b/src/pytz/tests/test_docs.py
index fb49ec1..ae189d3 100644
--- a/src/pytz/tests/test_docs.py
+++ b/src/pytz/tests/test_docs.py
@@ -13,7 +13,7 @@ class DocumentationTestCase(unittest.TestCase):
'''Confirm the README.txt is pure ASCII.'''
f = open(README, 'rb')
try:
- f.read().decode('US-ASCII')
+ f.read().decode('ASCII')
finally:
f.close()
diff --git a/src/pytz/tzfile.py b/src/pytz/tzfile.py
index 9c007c8..323e097 100644
--- a/src/pytz/tzfile.py
+++ b/src/pytz/tzfile.py
@@ -15,13 +15,13 @@ from pytz.tzinfo import memorized_datetime, memorized_timedelta
def _byte_string(s):
"""Cast a string or byte string to an ASCII byte string."""
- return s.encode('US-ASCII')
+ return s.encode('ASCII')
_NULL = _byte_string('\0')
def _std_string(s):
"""Cast a string or byte string to an ASCII string."""
- return str(s.decode('US-ASCII'))
+ return str(s.decode('ASCII'))
def build_tzinfo(zone, fp):
head_fmt = '>4s c 15x 6l'