[Python-checkins] r53800 - in python/trunk: Lib/encodings/__init__.py Misc/NEWS
brett.cannon
python-checkins at python.org
Thu Feb 15 23:54:40 CET 2007
Author: brett.cannon
Date: Thu Feb 15 23:54:39 2007
New Revision: 53800
Modified:
python/trunk/Lib/encodings/__init__.py
python/trunk/Misc/NEWS
Log:
Update the encoding package's search function to use absolute imports when
calling __import__. This helps make the expected search locations for encoding
modules be more explicit.
One could use an explicit value for __path__ when making the call to __import__
to force the exact location searched for encodings. This would give the most
strict search path possible if one is worried about malicious code being
imported. The unfortunate side-effect of that is that if __path__ was modified
on 'encodings' on purpose in a safe way it would not be picked up in future
__import__ calls.
Modified: python/trunk/Lib/encodings/__init__.py
==============================================================================
--- python/trunk/Lib/encodings/__init__.py (original)
+++ python/trunk/Lib/encodings/__init__.py Thu Feb 15 23:54:39 2007
@@ -93,8 +93,10 @@
if not modname or '.' in modname:
continue
try:
- mod = __import__('encodings.' + modname,
- globals(), locals(), _import_tail)
+ # Import equivalent to `` from .modname import *``.
+ # '*' is used so that __import__ returns the desired module and not
+ # 'encodings' itself.
+ mod = __import__(modname, globals(), locals(), ['*'], 1)
except ImportError:
pass
else:
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Thu Feb 15 23:54:39 2007
@@ -128,6 +128,9 @@
Library
-------
+- Have the encoding package's search function dynamically import using absolute
+ import semantics.
+
- Patch #1647484: Renamed GzipFile's filename attribute to name.
- Patch #1517891: Mode 'a' for ZipFile now creates the file if it
More information about the Python-checkins
mailing list