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
1diff --git a/src/pytz/__init__.py b/src/pytz/__init__.py
2index 3ef1636..a8980a6 100644
3--- a/src/pytz/__init__.py
4+++ b/src/pytz/__init__.py
5@@ -57,7 +57,7 @@ except NameError: # Python 3.x
6 ...
7 UnicodeEncodeError: ...
8 """
9- s.encode('US-ASCII') # Raise an exception if not ASCII
10+ s.encode('ASCII') # Raise an exception if not ASCII
11 return s # But return the original string - not a byte string.
12
13 else: # Python 2.x
14@@ -73,7 +73,7 @@ else: # Python 2.x
15 ...
16 UnicodeEncodeError: ...
17 """
18- return s.encode('US-ASCII')
19+ return s.encode('ASCII')
20
21
22 def open_resource(name):
23diff --git a/src/pytz/tests/test_docs.py b/src/pytz/tests/test_docs.py
24index fb49ec1..ae189d3 100644
25--- a/src/pytz/tests/test_docs.py
26+++ b/src/pytz/tests/test_docs.py
27@@ -13,7 +13,7 @@ class DocumentationTestCase(unittest.TestCase):
28 '''Confirm the README.txt is pure ASCII.'''
29 f = open(README, 'rb')
30 try:
31- f.read().decode('US-ASCII')
32+ f.read().decode('ASCII')
33 finally:
34 f.close()
35
36diff --git a/src/pytz/tzfile.py b/src/pytz/tzfile.py
37index 9c007c8..323e097 100644
38--- a/src/pytz/tzfile.py
39+++ b/src/pytz/tzfile.py
40@@ -15,13 +15,13 @@ from pytz.tzinfo import memorized_datetime, memorized_timedelta
41
42 def _byte_string(s):
43 """Cast a string or byte string to an ASCII byte string."""
44- return s.encode('US-ASCII')
45+ return s.encode('ASCII')
46
47 _NULL = _byte_string('\0')
48
49 def _std_string(s):
50 """Cast a string or byte string to an ASCII string."""
51- return str(s.decode('US-ASCII'))
52+ return str(s.decode('ASCII'))
53
54 def build_tzinfo(zone, fp):
55 head_fmt = '>4s c 15x 6l'

Subscribers

People subscribed via source and target branches

to all changes: