This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients Mark.Shannon, methane, rhettinger, terry.reedy
Date 2022-02-25.21:09:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1645823366.53.0.282544941794.issue46845@roundup.psfhosted.org>
In-reply-to
Content
CPython, at least, allows users to insert non-string keys in namespace dicts that are conceptually string-key only.

>>> globals()[0] = 'zero'
>>> globals()[0]
'zero'
>>> vars()
{'__name__': '__main__', ..., 0: 'zero'}

[This is for consenting adults only, as it prevents sorting keys and string-only operations on keys.
>>> dir()
...
TypeError: '<' not supported between instances of 'int' and 'str']
 
Do you propose to
1. Only use StringKeyDicts when non-string keys are not possible?  (Where would this be?)
2. Switch to a normal dict when a non-string key is added?  (But likely not switch back when the last non-string key is removed.)
3. Deprecate and remove the option to add non-string keys to namespace dicts?  (Proposed and rejected at least once as not gaining much.)
History
Date User Action Args
2022-02-25 21:09:26terry.reedysetrecipients: + terry.reedy, rhettinger, methane, Mark.Shannon
2022-02-25 21:09:26terry.reedysetmessageid: <1645823366.53.0.282544941794.issue46845@roundup.psfhosted.org>
2022-02-25 21:09:26terry.reedylinkissue46845 messages
2022-02-25 21:09:26terry.reedycreate