summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/codecs.py21
-rw-r--r--Lib/encodings/cp037.py4
-rw-r--r--Lib/encodings/cp1006.py4
-rw-r--r--Lib/encodings/cp1026.py4
-rw-r--r--Lib/encodings/cp1250.py4
-rw-r--r--Lib/encodings/cp1251.py4
-rw-r--r--Lib/encodings/cp1252.py4
-rw-r--r--Lib/encodings/cp1253.py4
-rw-r--r--Lib/encodings/cp1254.py4
-rw-r--r--Lib/encodings/cp1255.py4
-rw-r--r--Lib/encodings/cp1256.py4
-rw-r--r--Lib/encodings/cp1257.py4
-rw-r--r--Lib/encodings/cp1258.py4
-rw-r--r--Lib/encodings/cp424.py4
-rw-r--r--Lib/encodings/cp437.py4
-rw-r--r--Lib/encodings/cp500.py4
-rw-r--r--Lib/encodings/cp737.py4
-rw-r--r--Lib/encodings/cp775.py4
-rw-r--r--Lib/encodings/cp850.py4
-rw-r--r--Lib/encodings/cp852.py4
-rw-r--r--Lib/encodings/cp855.py4
-rw-r--r--Lib/encodings/cp856.py4
-rw-r--r--Lib/encodings/cp857.py4
-rw-r--r--Lib/encodings/cp860.py4
-rw-r--r--Lib/encodings/cp861.py4
-rw-r--r--Lib/encodings/cp862.py4
-rw-r--r--Lib/encodings/cp863.py4
-rw-r--r--Lib/encodings/cp864.py4
-rw-r--r--Lib/encodings/cp865.py4
-rw-r--r--Lib/encodings/cp866.py4
-rw-r--r--Lib/encodings/cp869.py4
-rw-r--r--Lib/encodings/cp874.py4
-rw-r--r--Lib/encodings/cp875.py4
-rw-r--r--Lib/encodings/iso8859_1.py4
-rw-r--r--Lib/encodings/iso8859_10.py4
-rw-r--r--Lib/encodings/iso8859_13.py4
-rw-r--r--Lib/encodings/iso8859_14.py4
-rw-r--r--Lib/encodings/iso8859_15.py4
-rw-r--r--Lib/encodings/iso8859_2.py4
-rw-r--r--Lib/encodings/iso8859_3.py4
-rw-r--r--Lib/encodings/iso8859_4.py4
-rw-r--r--Lib/encodings/iso8859_5.py4
-rw-r--r--Lib/encodings/iso8859_6.py4
-rw-r--r--Lib/encodings/iso8859_7.py4
-rw-r--r--Lib/encodings/iso8859_8.py4
-rw-r--r--Lib/encodings/iso8859_9.py4
-rw-r--r--Lib/encodings/koi8_r.py4
-rw-r--r--Lib/encodings/mac_cyrillic.py4
-rw-r--r--Lib/encodings/mac_greek.py4
-rw-r--r--Lib/encodings/mac_iceland.py4
-rw-r--r--Lib/encodings/mac_latin2.py4
-rw-r--r--Lib/encodings/mac_roman.py4
-rw-r--r--Lib/encodings/mac_turkish.py4
-rw-r--r--Lib/encodings/rot_13.py4
54 files changed, 74 insertions, 159 deletions
diff --git a/Lib/codecs.py b/Lib/codecs.py
index b2eab1d..bdc8d02 100644
--- a/Lib/codecs.py
+++ b/Lib/codecs.py
@@ -554,6 +554,27 @@ def make_identity_dict(rng):
res[i]=i
return res
+def make_encoding_map(decoding_map):
+
+ """ Creates an encoding map from a decoding map.
+
+ If a target mapping in the decoding map occurrs multiple
+ times, then that target is mapped to None (undefined mapping),
+ causing an exception when encountered by the charmap codec
+ during translation.
+
+ One example where this happens is cp875.py which decodes
+ multiple character to \u001a.
+
+ """
+ m = {}
+ for k,v in decoding_map.items():
+ if not m.has_key(v):
+ m[v] = k
+ else:
+ m[v] = None
+ return m
+
### Tests
if __name__ == '__main__':
diff --git a/Lib/encodings/cp037.py b/Lib/encodings/cp037.py
index 5868372..3b641bb 100644
--- a/Lib/encodings/cp037.py
+++ b/Lib/encodings/cp037.py
@@ -277,6 +277,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp1006.py b/Lib/encodings/cp1006.py
index 593fbb6..0a3c3af 100644
--- a/Lib/encodings/cp1006.py
+++ b/Lib/encodings/cp1006.py
@@ -135,6 +135,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp1026.py b/Lib/encodings/cp1026.py
index 3796a75..cce5af6 100644
--- a/Lib/encodings/cp1026.py
+++ b/Lib/encodings/cp1026.py
@@ -277,6 +277,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp1250.py b/Lib/encodings/cp1250.py
index 03a3e31..39cbc33 100644
--- a/Lib/encodings/cp1250.py
+++ b/Lib/encodings/cp1250.py
@@ -120,6 +120,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp1251.py b/Lib/encodings/cp1251.py
index e27a122..4d4b6ee 100644
--- a/Lib/encodings/cp1251.py
+++ b/Lib/encodings/cp1251.py
@@ -154,6 +154,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp1252.py b/Lib/encodings/cp1252.py
index 5d7bdd6..647f907 100644
--- a/Lib/encodings/cp1252.py
+++ b/Lib/encodings/cp1252.py
@@ -73,6 +73,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp1253.py b/Lib/encodings/cp1253.py
index abc144c..bfb4723 100644
--- a/Lib/encodings/cp1253.py
+++ b/Lib/encodings/cp1253.py
@@ -148,6 +148,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp1254.py b/Lib/encodings/cp1254.py
index 4a2ab3c..dc662ed 100644
--- a/Lib/encodings/cp1254.py
+++ b/Lib/encodings/cp1254.py
@@ -79,6 +79,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp1255.py b/Lib/encodings/cp1255.py
index c987b85..6f70654 100644
--- a/Lib/encodings/cp1255.py
+++ b/Lib/encodings/cp1255.py
@@ -140,6 +140,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp1256.py b/Lib/encodings/cp1256.py
index d72c5bc..40ed577 100644
--- a/Lib/encodings/cp1256.py
+++ b/Lib/encodings/cp1256.py
@@ -126,6 +126,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp1257.py b/Lib/encodings/cp1257.py
index d17a904..baaf367 100644
--- a/Lib/encodings/cp1257.py
+++ b/Lib/encodings/cp1257.py
@@ -128,6 +128,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp1258.py b/Lib/encodings/cp1258.py
index 597f124..9a2827d 100644
--- a/Lib/encodings/cp1258.py
+++ b/Lib/encodings/cp1258.py
@@ -87,6 +87,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp424.py b/Lib/encodings/cp424.py
index bc10379..4689996 100644
--- a/Lib/encodings/cp424.py
+++ b/Lib/encodings/cp424.py
@@ -277,6 +277,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp437.py b/Lib/encodings/cp437.py
index db1b88a..a55e424 100644
--- a/Lib/encodings/cp437.py
+++ b/Lib/encodings/cp437.py
@@ -169,6 +169,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp500.py b/Lib/encodings/cp500.py
index 1c8fb57..bc1acde 100644
--- a/Lib/encodings/cp500.py
+++ b/Lib/encodings/cp500.py
@@ -277,6 +277,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp737.py b/Lib/encodings/cp737.py
index 03665ae..6174d85 100644
--- a/Lib/encodings/cp737.py
+++ b/Lib/encodings/cp737.py
@@ -169,6 +169,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp775.py b/Lib/encodings/cp775.py
index b38ccb5..ee56f01 100644
--- a/Lib/encodings/cp775.py
+++ b/Lib/encodings/cp775.py
@@ -169,6 +169,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp850.py b/Lib/encodings/cp850.py
index e26287b..dd23187 100644
--- a/Lib/encodings/cp850.py
+++ b/Lib/encodings/cp850.py
@@ -169,6 +169,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp852.py b/Lib/encodings/cp852.py
index 431d844..38df00f 100644
--- a/Lib/encodings/cp852.py
+++ b/Lib/encodings/cp852.py
@@ -169,6 +169,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp855.py b/Lib/encodings/cp855.py
index c9e7168..764fe1a 100644
--- a/Lib/encodings/cp855.py
+++ b/Lib/encodings/cp855.py
@@ -169,6 +169,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp856.py b/Lib/encodings/cp856.py
index cc2e01f..9d09c09 100644
--- a/Lib/encodings/cp856.py
+++ b/Lib/encodings/cp856.py
@@ -169,6 +169,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp857.py b/Lib/encodings/cp857.py
index 6f4df23..5c84bb8 100644
--- a/Lib/encodings/cp857.py
+++ b/Lib/encodings/cp857.py
@@ -168,6 +168,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp860.py b/Lib/encodings/cp860.py
index 057d918..a721ea3 100644
--- a/Lib/encodings/cp860.py
+++ b/Lib/encodings/cp860.py
@@ -169,6 +169,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp861.py b/Lib/encodings/cp861.py
index 8db3b40..ccf26b7 100644
--- a/Lib/encodings/cp861.py
+++ b/Lib/encodings/cp861.py
@@ -169,6 +169,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp862.py b/Lib/encodings/cp862.py
index 1cac3e2..8f6d111 100644
--- a/Lib/encodings/cp862.py
+++ b/Lib/encodings/cp862.py
@@ -169,6 +169,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp863.py b/Lib/encodings/cp863.py
index ecdc391..3596e64 100644
--- a/Lib/encodings/cp863.py
+++ b/Lib/encodings/cp863.py
@@ -169,6 +169,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp864.py b/Lib/encodings/cp864.py
index 861fb00..f510a26 100644
--- a/Lib/encodings/cp864.py
+++ b/Lib/encodings/cp864.py
@@ -167,6 +167,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp865.py b/Lib/encodings/cp865.py
index 4d9010d..cc4f719 100644
--- a/Lib/encodings/cp865.py
+++ b/Lib/encodings/cp865.py
@@ -169,6 +169,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp866.py b/Lib/encodings/cp866.py
index 6a8b0b0..518eede 100644
--- a/Lib/encodings/cp866.py
+++ b/Lib/encodings/cp866.py
@@ -169,6 +169,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp869.py b/Lib/encodings/cp869.py
index 65d2b2e..2e3ad35 100644
--- a/Lib/encodings/cp869.py
+++ b/Lib/encodings/cp869.py
@@ -169,6 +169,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp874.py b/Lib/encodings/cp874.py
index 31f4d3d..c43e20b 100644
--- a/Lib/encodings/cp874.py
+++ b/Lib/encodings/cp874.py
@@ -168,6 +168,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/cp875.py b/Lib/encodings/cp875.py
index 3500446..5e74873 100644
--- a/Lib/encodings/cp875.py
+++ b/Lib/encodings/cp875.py
@@ -278,6 +278,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/iso8859_1.py b/Lib/encodings/iso8859_1.py
index f4c0bf7..cea2261 100644
--- a/Lib/encodings/iso8859_1.py
+++ b/Lib/encodings/iso8859_1.py
@@ -41,6 +41,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/iso8859_10.py b/Lib/encodings/iso8859_10.py
index c43c653..f29ebd2 100644
--- a/Lib/encodings/iso8859_10.py
+++ b/Lib/encodings/iso8859_10.py
@@ -87,6 +87,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/iso8859_13.py b/Lib/encodings/iso8859_13.py
index 2ab5292..e0c4ae4 100644
--- a/Lib/encodings/iso8859_13.py
+++ b/Lib/encodings/iso8859_13.py
@@ -97,6 +97,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/iso8859_14.py b/Lib/encodings/iso8859_14.py
index 5533e96..c84bb23 100644
--- a/Lib/encodings/iso8859_14.py
+++ b/Lib/encodings/iso8859_14.py
@@ -72,6 +72,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/iso8859_15.py b/Lib/encodings/iso8859_15.py
index 7bffff4..bf92acb 100644
--- a/Lib/encodings/iso8859_15.py
+++ b/Lib/encodings/iso8859_15.py
@@ -49,6 +49,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/iso8859_2.py b/Lib/encodings/iso8859_2.py
index 481f9a0..1c92a54 100644
--- a/Lib/encodings/iso8859_2.py
+++ b/Lib/encodings/iso8859_2.py
@@ -98,6 +98,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/iso8859_3.py b/Lib/encodings/iso8859_3.py
index c2820ad..ac8c8d9 100644
--- a/Lib/encodings/iso8859_3.py
+++ b/Lib/encodings/iso8859_3.py
@@ -76,6 +76,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/iso8859_4.py b/Lib/encodings/iso8859_4.py
index 30d6ca6..91db126 100644
--- a/Lib/encodings/iso8859_4.py
+++ b/Lib/encodings/iso8859_4.py
@@ -91,6 +91,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/iso8859_5.py b/Lib/encodings/iso8859_5.py
index 2bdaa50..96cb073 100644
--- a/Lib/encodings/iso8859_5.py
+++ b/Lib/encodings/iso8859_5.py
@@ -135,6 +135,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/iso8859_6.py b/Lib/encodings/iso8859_6.py
index 585fa11..298c2d5 100644
--- a/Lib/encodings/iso8859_6.py
+++ b/Lib/encodings/iso8859_6.py
@@ -134,6 +134,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/iso8859_7.py b/Lib/encodings/iso8859_7.py
index 48f1bd5..eea3abf 100644
--- a/Lib/encodings/iso8859_7.py
+++ b/Lib/encodings/iso8859_7.py
@@ -121,6 +121,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/iso8859_8.py b/Lib/encodings/iso8859_8.py
index a19aa67..45b2ada 100644
--- a/Lib/encodings/iso8859_8.py
+++ b/Lib/encodings/iso8859_8.py
@@ -109,6 +109,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/iso8859_9.py b/Lib/encodings/iso8859_9.py
index a278905..ad0c190 100644
--- a/Lib/encodings/iso8859_9.py
+++ b/Lib/encodings/iso8859_9.py
@@ -47,6 +47,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/koi8_r.py b/Lib/encodings/koi8_r.py
index c28004e..242d0c4 100644
--- a/Lib/encodings/koi8_r.py
+++ b/Lib/encodings/koi8_r.py
@@ -169,6 +169,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/mac_cyrillic.py b/Lib/encodings/mac_cyrillic.py
index 4552831..6ae4a30 100644
--- a/Lib/encodings/mac_cyrillic.py
+++ b/Lib/encodings/mac_cyrillic.py
@@ -164,6 +164,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/mac_greek.py b/Lib/encodings/mac_greek.py
index b7040c4..839cf61 100644
--- a/Lib/encodings/mac_greek.py
+++ b/Lib/encodings/mac_greek.py
@@ -167,6 +167,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/mac_iceland.py b/Lib/encodings/mac_iceland.py
index f20e134..284580c 100644
--- a/Lib/encodings/mac_iceland.py
+++ b/Lib/encodings/mac_iceland.py
@@ -163,6 +163,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/mac_latin2.py b/Lib/encodings/mac_latin2.py
index 0fba502..e922178 100644
--- a/Lib/encodings/mac_latin2.py
+++ b/Lib/encodings/mac_latin2.py
@@ -167,6 +167,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/mac_roman.py b/Lib/encodings/mac_roman.py
index 6d048a3..23dca89 100644
--- a/Lib/encodings/mac_roman.py
+++ b/Lib/encodings/mac_roman.py
@@ -164,6 +164,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/mac_turkish.py b/Lib/encodings/mac_turkish.py
index c81a864..c71268b 100644
--- a/Lib/encodings/mac_turkish.py
+++ b/Lib/encodings/mac_turkish.py
@@ -164,6 +164,4 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
diff --git a/Lib/encodings/rot_13.py b/Lib/encodings/rot_13.py
index 8c54811..532ff64 100644
--- a/Lib/encodings/rot_13.py
+++ b/Lib/encodings/rot_13.py
@@ -93,9 +93,7 @@ decoding_map.update({
### Encoding Map
-encoding_map = {}
-for k,v in decoding_map.items():
- encoding_map[v] = k
+encoding_map = codecs.make_encoding_map(decoding_map)
### Filter API