Rename and deprecate pygobject dunder attributes
Submitted by Simon Feltman
Link to original bug (#732403)
Description
There are a handful of attributes pygobject exposes using Pythons double underscore followed by double underscore naming convention (<name>
). This naming scheme is reserved for Python operators and should not be used to avoid potential future clashes with Python. I recall reading in Python docs that this naming scheme should not be used in client code but can't seem to find a reference ATM. I was able to find an article which states the same thing though:
http://www.pixelmonkey.org/2013/04/11/python-double-under-double-wonder
"Never, ever, invent your own dunders — Python leaves you with a number of clean namespaces (classes, modules, etc.) for your own code. Use them! The core Python team reserved a somewhat ugly namespace for themselves — don’t trample all over their compromise by stealing their names."
Here's an initial list:
__gtype__
__gtype_name__
__gpointer__
__gproperties__
__gsignals__
__info__
The one that sticks out the most is __info__
as it is such a generic name. Replacing the naming with a single prefixed underscore should be sufficient to avoid clashes with GI library names (which is the purpose of the special naming to begin with):
_gtype
_gtypename
_gpointer
_gproperties
_gsignals
_ginfo
Alternatively we could use a single underscore followed by single underscore: _gtype_
, _ginfo_
, etc...
__gproperties__
and __gsignals__
could probably be deprecated completely because we have Property and Signal descriptors which are cleaner anyhow.