Merge ~vskytta/pytz:encname into pytz:master

Proposed by Ville Skyttä
Status: Needs review
Proposed branch: ~vskytta/pytz:encname
Merge into: pytz:master
Diff against target: 55 lines (+5/-5)
3 files modified
src/pytz/__init__.py (+2/-2)
src/pytz/tests/test_docs.py (+1/-1)
src/pytz/tzfile.py (+2/-2)
Reviewer Review Type Date Requested Status
Stuart Bishop Pending
Review via email: mp+301211@code.launchpad.net
To post a comment you must log in.

Unmerged commits

d807daf... by Ville Skyttä

Lookup ASCII by alias 'ASCII' instead of 'US-ASCII'

For improved performance on CPython:
https://docs.python.org/library/codecs.html#standard-encodings

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/pytz/__init__.py b/src/pytz/__init__.py
index 3ef1636..a8980a6 100644
--- a/src/pytz/__init__.py
+++ b/src/pytz/__init__.py
@@ -57,7 +57,7 @@ except NameError: # Python 3.x
57 ...57 ...
58 UnicodeEncodeError: ...58 UnicodeEncodeError: ...
59 """59 """
60 s.encode('US-ASCII') # Raise an exception if not ASCII60 s.encode('ASCII') # Raise an exception if not ASCII
61 return s # But return the original string - not a byte string.61 return s # But return the original string - not a byte string.
6262
63else: # Python 2.x63else: # Python 2.x
@@ -73,7 +73,7 @@ else: # Python 2.x
73 ...73 ...
74 UnicodeEncodeError: ...74 UnicodeEncodeError: ...
75 """75 """
76 return s.encode('US-ASCII')76 return s.encode('ASCII')
7777
7878
79def open_resource(name):79def 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):
13 '''Confirm the README.txt is pure ASCII.'''13 '''Confirm the README.txt is pure ASCII.'''
14 f = open(README, 'rb')14 f = open(README, 'rb')
15 try:15 try:
16 f.read().decode('US-ASCII')16 f.read().decode('ASCII')
17 finally:17 finally:
18 f.close()18 f.close()
1919
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
1515
16def _byte_string(s):16def _byte_string(s):
17 """Cast a string or byte string to an ASCII byte string."""17 """Cast a string or byte string to an ASCII byte string."""
18 return s.encode('US-ASCII')18 return s.encode('ASCII')
1919
20_NULL = _byte_string('\0')20_NULL = _byte_string('\0')
2121
22def _std_string(s):22def _std_string(s):
23 """Cast a string or byte string to an ASCII string."""23 """Cast a string or byte string to an ASCII string."""
24 return str(s.decode('US-ASCII'))24 return str(s.decode('ASCII'))
2525
26def build_tzinfo(zone, fp):26def build_tzinfo(zone, fp):
27 head_fmt = '>4s c 15x 6l'27 head_fmt = '>4s c 15x 6l'

Subscribers

People subscribed via source and target branches

to all changes: