[Python-checkins] r45824 - python/trunk/Lib/inspect.py

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


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

On 4/30/06, georg.brandl <python-checkins at python.org> wrote:
> Author: georg.brandl
> Date: Sun Apr 30 19:42:26 2006
> New Revision: 45824
>
> Modified:
>    python/trunk/Lib/inspect.py
> Log:
> Fix another problem in inspect: if the module for an object cannot be found, don't try to give its __dict__ to linecache.
>
>
>
> Modified: python/trunk/Lib/inspect.py
> ==============================================================================
> --- python/trunk/Lib/inspect.py (original)
> +++ python/trunk/Lib/inspect.py Sun Apr 30 19:42:26 2006
> @@ -412,7 +412,11 @@
>      in the file and the line number indexes a line in that list.  An IOError
>      is raised if the source code cannot be retrieved."""
>      file = getsourcefile(object) or getfile(object)
> -    lines = linecache.getlines(file, getmodule(object).__dict__)
> +    module = getmodule(object)
> +    if module:
> +        lines = linecache.getlines(file, module.__dict__)
> +    else:
> +        lines = linecache.getlines(file)
>      if not lines:
>          raise IOError('could not get source code')
>
> _______________________________________________
> 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