New submission from Brett Cannon <>:

If you look at
 you will notice there are a lot of attributes on modules. But since the 
introduction of module specs 
 all of those attributes became redundant.

Now some attributes can never be taken away based on common idioms in the 
Python community. __name__ can't go due to `if __name__ == '__main__'`. 
__path__ can't go due to people manipulating it with e.g. pkg_resources or 
pkgutil. The rest, though, don't have such strong idioms tied to them (and in 
the case of __package__, has actually been made officially redundant by the 
import system since Python 3.6). That means setting them is unnecessary and any 
time someone wants to read or potentially manipulate them they have to choose 
between those attributes or the spec (or update both). Either way it can lead 
to bugs (I know I have nearly forgotten to set both the spec and the attribute 

I don't know if we can easily deprecate these attributes using __getattr__ on 
modules as added in Python 3.7, or if this is more of a documentation thing and 
need a long period of clearly messaging that these redundant attributes will no 
longer be set at some point.

components: Library (Lib)
messages: 315269
nosy: brett.cannon, eric.snow
priority: normal
severity: normal
stage: test needed
status: open
title: Deprecate __loader__, __package__, __file__, and __cached__ on modules
versions: Python 3.8

Python tracker <>
Python-bugs-list mailing list

Reply via email to