[Twisted-Python] supressess warnings

Glyph Lefkowitz glyph at twistedmatrix.com
Tue Apr 1 16:01:28 EST 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On Tuesday, April 1, 2003, at 02:11 PM, Christopher Armstrong wrote:

> On Tue, Apr 01, 2003 at 07:00:53AM -0500, Andrew Dalke wrote:
>
>> A bit of searching later and I found
>>   twisted/python/log.py
>> which redefines (!) warnings.showwarning to dump the data to a
>> logfile, which is initialized to a NullFile(), which does nothing.
>
> Yeah, replacing showwarnings is the idiomatic way to override the
> display of warnings. The bit that initializes the default logfile to
> NullFile is something moshez and glyph wanted, and, for the record,
> something I'm against. (sorry glyph :-)

The reason that moshez and I have it written this way is simple: we 
don't want library code generating spurious messages that your code may 
not want printed.  However, I think that you're correct in criticizing 
it for throwing away warnings and tracebacks.  Errors, even in library 
code, ought to be presented the same way they're normally presented.

>> And for the life of me I can't figure out why the log file should
>> default (when no logging is enabled) to the NullFile rather than
>> sys.stderr -- if you really want the NullFile, just pass it in.  So
>> I switched it to use sys.stderr.
>
> I wish this could be accepted, but unless glyph changes his mind, it
> probably won't.

As long as we're talking about sys.std*err*, and not std*out*, I think 
this is acceptable.  I'd like to hear if moshez's has any objections 
too, but barring that, let's do it immediately.

> The usual response is to use twistd, but twistd isn't
> appropriate in all use-cases (it is in yours, however).

This should be a FAQ.

	Q.  Is using 'twistd' always appropriate?

	A.  Not always, but it is in your case.

> The *reason*, IIRC, was that "you shouldn't spam unwanted stuff to 
> STDIO", which I think is stupid. Application developers could notice 
> spam to stdio, and, if they don't like it, startLogging to NullFile. 
> (I've heard a lot more complaints about "Why don't I see any output!?" 
> than "Why does Twisted write stuff to my stdio?")

Oh, I heard a lot of complaints about it writing spurious messages to 
stdio before this change was made.  Different people are unhappy, but 
people are unhappy either way :-)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (Darwin)

iD8DBQE+if4svVGR4uSOE2wRArcOAKCKs4sHno57LtUWgB+U2C1Oc1X6qgCfbg5N
qHg2Z9ZDNkGHddmnKvWEFBw=
=FtOD
-----END PGP SIGNATURE-----





More information about the Twisted-Python mailing list