]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Make the __import__ call in encodings.__init__ absolute with a level 0 call.
authorBrett Cannon <bcannon@gmail.com>
Fri, 16 Feb 2007 19:33:01 +0000 (19:33 +0000)
committerBrett Cannon <bcannon@gmail.com>
Fri, 16 Feb 2007 19:33:01 +0000 (19:33 +0000)
Lib/encodings/__init__.py

index 190b3c4950a66351bfccde13da29462caf82241f..7db44cbc4e90d5aeeb01fea71e31ac6a4405cb43 100644 (file)
@@ -93,10 +93,10 @@ def search_function(encoding):
         if not modname or '.' in modname:
             continue
         try:
-            # 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)
+            # Import is absolute to prevent the possibly malicious import of a
+            # module with side-effects that is not in the 'encodings' package.
+            mod = __import__('encodings.' + modname, fromlist=_import_tail,
+                             level=0)
         except ImportError:
             pass
         else: