[PATCH 0 of 1] extensions doc: no-import approach

Cédric Duval cedricduval at free.fr
Fri Aug 7 14:46:58 CDT 2009


A number of concerns have been voiced about using import for extracting
the documentation, as it may incur adverse side-effects, so this patch
implements an alternate method avoiding importing (and hence executing)
code.

This is not yet for crew (I am leaving out the rest of the series for
now, which has hardly changed since the first post anyway), but just
to gather opinions on the approach.

This obviously requires more code than simply using the import machinery
to fetch the __doc__ attribute, but on the other hand will be safer.

It should also be noted that the Python bytecode is analyzed in order
to extract the docstring. This may not work with some alternative
Python implementations, in particular it seems Jython code object don't
have a co_code attribute (so maybe we should have a fallback of some kind).

Since there is no ideal approach, it will be a matter of choice and
trade-offs, so comments are most welcome.

-- 
Cédric



More information about the Mercurial-devel mailing list