[issue21912] Deferred logging may use outdated references

2014-07-03 Thread Jonas Diemer
New submission from Jonas Diemer: I was having trouble with the logging module under Jython: I was getting seemingly sporadic wierd null pointer exceptions in the logging code. The problem seemed to be related to references that were passed to the logger, e.g. logger.debug("My objec

[issue21912] Deferred logging may use outdated references

2014-07-03 Thread Jonas Diemer
Jonas Diemer added the comment: Find attached a demo script that causes the erratic behavior in regular Python (2.7.5 on Windows). The log file contains two lines, both show the new name of the object, although the first debug() was called befor the name change. I think this problem could be

[issue21912] Deferred logging may use outdated references

2014-07-03 Thread Jonas Diemer
Jonas Diemer added the comment: I see your point. The decision whether to log or not is actually made synchronously to the actual logging call, as far as I can tell (i.e. "if self.isEnabledFor..." is checked directly in debug()). So at this place, the formatting could already happe

[issue21912] Deferred logging may use outdated references

2014-07-03 Thread Jonas Diemer
Jonas Diemer added the comment: Thanks for the explanation. Throughput is a valid reason. Your workaround does of course work, but it means that the string formatting is always done, even if the message is filtered out. Is this delayed logging behavior documented in any way (maybe I have

[issue21912] Deferred logging may use outdated references

2014-07-03 Thread Jonas Diemer
Jonas Diemer added the comment: 2014-07-03 16:42 GMT+02:00 Vinay Sajip : > > I "forked" logging and am catching exceptions during the string > formatting > > That might work with Jython and invalidated objects, but in the case of > e.g. CPython (where the objects