[Python-checkins] r45895 - python/trunk/Lib/imputil.py

Neal Norwitz nnorwitz at gmail.com
Fri May 5 06:17:56 CEST 2006


Can we get a test case for this? -- n

On 5/3/06, georg.brandl <python-checkins at python.org> wrote:
> Author: georg.brandl
> Date: Thu May  4 07:08:10 2006
> New Revision: 45895
>
> Modified:
>    python/trunk/Lib/imputil.py
> Log:
> Bug #1481530: allow "from os.path import ..." with imputil
>
>
> Modified: python/trunk/Lib/imputil.py
> ==============================================================================
> --- python/trunk/Lib/imputil.py (original)
> +++ python/trunk/Lib/imputil.py Thu May  4 07:08:10 2006
> @@ -131,9 +131,12 @@
>          if importer:
>              return importer._finish_import(top_module, parts[1:], fromlist)
>
> -        # Grrr, some people "import os.path"
> +        # Grrr, some people "import os.path" or do "from os.path import ..."
>          if len(parts) == 2 and hasattr(top_module, parts[1]):
> -            return top_module
> +            if fromlist:
> +                return getattr(top_module, parts[1])
> +            else:
> +                return top_module
>
>          # If the importer does not exist, then we have to bail. A missing
>          # importer means that something else imported the module, and we have
> _______________________________________________
> Python-checkins mailing list
> Python-checkins at python.org
> http://mail.python.org/mailman/listinfo/python-checkins
>


More information about the Python-checkins mailing list