[Tim Peters]
>> Note:  sometimes _internals_ use deprecated gimmicks in order to
>> support deprecated gimmicks too, and then stacklevel=3 is too small.
>> It's happened so rarely in ZODB that I haven't tried to "do something"
>> about that yet.

[Chris Withers]
> Interestingly, I've found that even this is sometimes not enough, since
> you don't know whether you want the caller, the caller's caller or
> further up the chain than that.

I haven't seen much of that.  One place I did is in deprecating
subtransactions, where many paths thru the ZODB code have to pass on
the original "is this a sub or a 'real' transaction?" flag.  In those
cases, the relevant methods also grew an optional `deprecation_wng`
argument defaulting to True, and _internal_ calls to such methods
explicitly pass "deprecation_wng=False".

> Is there any way to get the warnings stuff to actually emit a traceback
> so it can be followed?

No; the `warnings` module doesn't even import the `traceback` module,
let alone use it.  You can print a traceback yourself by using the
`traceback` module, and if you're determined enough you could replace
warnings.showwarning() with a function of your own (see the docs for
warnings.showwarning, and possible for traceback.print_stack).
Zope-Dev maillist  -  Zope-Dev@zope.org
**  No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope )

Reply via email to