Guido van Rossum <guido@python.org> writes: > Maybe we can add even detect the abusing cases by putting a test in > PyString_InternInPlace() like this: > > if (s->ob_refcnt == 1) { > PyErr_Warn(PyExc_DeprecationWarning, > "interning won't keep your string alive"); > PyErr_Clear(); /* In case the warning was an error, ignore it */ > Py_INCREF(s); /* Make s immortal */ > } I believe this will trigger very often; the first usage of InternFromString (for a certain string) will likely trigger it. If people do PyObject *__foo__; int init(){ __foo__ = PyString_InternFromString("__foo__"); } then this is perfectly safe: you get an extra reference back (on top of ones that the intern dictionary just stops holding); you can keep this reference as long as you want. So I would agree with your analysis that this will cause only few problems. Unfortunately, those will be hard to track down. Regards, Martin
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4