2.7 has a new DeprecationWarning inside the build_ext command for code which sets the 'compiler' to anything other than a string or None. Because the warning occurs within property getter / setters, it needs to boost the stacklevel for the warning above the default value of 1. In addition, the setter is called from within '__setattr__', which means that it needs to be incremented again in that case. The attached patch does both of these things.
This change has been reverted in 2.7 and 3.x, I’ll check distutils2. Thank you. We should test that warnings stacklevels make sense; it’s on my todo list.
I checked again and found those files to be fixed in 3.2: (in Lib/distutils) command/register.py command/sdist.py dist.py extension.py. Instances of self.warn or file.warn are false positives, they are logging calls. The situation is different in distutils2: Deprecated code is ripped off, and remaining warnings should probably be made logging warnings.
Due to the feature freeze of distutils and official upgrade path to distutils2, I think the DeprecationWarnings in distutils should just be removed, as they serve no useful purpose.
> [...] I think the DeprecationWarnings in distutils should just be removed, as they serve no useful purpose. There are no DeprecationWarning warnings (only four PendingDeprecationWarning warnings -- two of them are for 'check_metadata') in distutils codebase in both 2.7 and 3.x anymore. Closing this as out of date.
History
Date
User
Action
Args
2022-04-11 14:56:56
admin
set
github: 51943
2016-04-16 20:24:00
berker.peksag
set
status: open -> closednosy: + berker.peksagmessages: + resolution: out of datestage: needs patch -> resolved
2012-02-18 01🔞36
eric.araujo
set
keywords: - patch, easytitle: DeprecationWarning from build_ext needs stacklevel -> DeprecationWarnings in distutils are pointlessmessages: + versions: + Python 3.3, - Python 3.1