[Import-sig] getting source (was: Long-awaited imputil comments)

Greg Stein gstein@lyra.org
Thu, 17 Feb 2000 10:41:51 -0800 (PST)

On Thu, 17 Feb 2000, Guido van Rossum wrote:
> I don't mind that the implementation for get_source() raises an error
> (any error) when the code came from an archive.

I was thinking of returning None, to follow the get_code() pattern.

> I just want a
> standard API that people who write alternative code repositories
> can implement.  Greg's proposal seems fine:
> module.__importer__.get_module_source(module).

I also plan to have importer.get_source(parent, modname, fqname).

* get_module_source() is needed for things like tracebacks, where it
  somewhat difficult to recover parent/modname/fqname (also described as:
  why make clients repeat the code to recover that data)

* get_source() is needed for cases where a module hasn't been imported at
  that point

Importer subclasses will only need to implement get_source(). The base
class will extract the parent/modname/fqname from information in the


Greg Stein, http://www.lyra.org/