Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
a0af63b2
Commit
a0af63b2
authored
Feb 11, 2002
by
Marc-André Lemburg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Corrected import behaviour for codecs which live outside the encodings
package.
parent
f2f219da
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
17 deletions
+12
-17
Lib/encodings/__init__.py
Lib/encodings/__init__.py
+7
-12
Lib/encodings/aliases.py
Lib/encodings/aliases.py
+5
-5
No files found.
Lib/encodings/__init__.py
View file @
a0af63b2
...
...
@@ -4,8 +4,8 @@
directory.
Codec modules must have names corresponding to standard lower-case
encoding names with hyphens
and periods mapped to underscores,
e.g. 'utf-8' is
implemented by the module 'utf_8.py'.
encoding names with hyphens
mapped to underscores, e.g. 'utf-8' is
implemented by the module 'utf_8.py'.
Each codec module must export the following interface:
...
...
@@ -52,23 +52,18 @@ def search_function(encoding):
# default import module lookup scheme with the alias name.
#
modname
=
encoding
.
replace
(
'-'
,
'_'
)
modname
=
modname
.
replace
(
'.'
,
'_'
)
try
:
mod
=
__import__
(
'encodings.'
+
modname
,
globals
(),
locals
(),
_import_tail
)
except
ImportError
,
why
:
import
aliases
modname
=
aliases
.
aliases
.
get
(
modname
,
_unknown
)
if
modname
is
not
_unknown
:
try
:
mod
=
__import__
(
modname
,
globals
(),
locals
(),
_import_tail
)
except
ImportError
,
why
:
mod
=
None
else
:
modname
=
aliases
.
aliases
.
get
(
modname
,
modname
)
try
:
mod
=
__import__
(
modname
,
globals
(),
locals
(),
_import_tail
)
except
ImportError
,
why
:
mod
=
None
if
mod
is
None
:
#
c
ache misses
#
C
ache misses
_cache
[
encoding
]
=
None
return
None
...
...
Lib/encodings/aliases.py
View file @
a0af63b2
...
...
@@ -4,8 +4,8 @@
map encodings names to module names.
Note that the search function converts the encoding names to lower
case and replaces hyphens
and periods with underscores *before*
performing the
lookup.
case and replaces hyphens
with underscores *before* performing the
lookup.
Contents:
...
...
@@ -25,13 +25,13 @@ aliases = {
# ascii codec
'646'
:
'ascii'
,
'ansi_x3
_
4_1968'
:
'ascii'
,
'ansi_x3
_
4_1986'
:
'ascii'
,
'ansi_x3
.
4_1968'
:
'ascii'
,
'ansi_x3
.
4_1986'
:
'ascii'
,
'cp367'
:
'ascii'
,
'csascii'
:
'ascii'
,
'ibm367'
:
'ascii'
,
'iso646_us'
:
'ascii'
,
'iso_646
_
irv:1991'
:
'ascii'
,
'iso_646
.
irv:1991'
:
'ascii'
,
'iso_ir_6'
:
'ascii'
,
'us'
:
'ascii'
,
'us_ascii'
:
'ascii'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment