[Python-Dev] When to signal an error

Neal Norwitz neal@metaslash.com
Sat, 19 Jan 2002 14:25:18 -0500


Guido van Rossum wrote:

> I believe that evertually some PyChecker-like technology will be
> incorporated in the Python compiler.  The same happened to C
> compilers: the lint program became useless once GCC incorporated the
> same technology.

pychecker was (and still is) an experiment to me.  But I think 
it would be great if the lessons from pychecker could be integrated
into the compiler.

Currently, I think there are 2 or 3 warnings which definitely fit this class:
No global found, using ++/--, and expressions with no effect as Jason
described.  I have posted a patch on SF to demonstrate the feasibility
of expressions with no effect:  

https://sourceforge.net/tracker/index.php?func=detail&aid=505826&group_id=5470&atid=305470

It should be pretty easy to warn about ++ and --.  No global found
would probably require another pass of the code after compilation.

I'd be happy to help the process of integrating warnings into the compiler,
however, I'm not sure how to proceed.  Should pychecker be put into the
standard library (users can now do:  import pychecker.checker and all
modules imported are checked by installing an __import__)?  Should
pychecker be added as a tool?  Should a PEP be written?  etc.

> But these warnings will always have a different status than purely
> syntactical error: there are often cases where the user knows better
> (for example, sometimes an attribute reference can have a desirable
> side effect).

I agree.

Neal