Arusekk added the comment:
Sorry, I forgot to state what is my actual goal: for the module objects to be
pickleable in native CPython (possibly from C layer) without the need to add
this to every code that wants to pickle module objects.
The point is that they can already be unpickled from
New submission from Arusekk :
Currently pickling functions and types stores modules by their name.
So I believe it is possible to support pickling module objects with the
following code (based on the logic in PyPy, which supports pickling modules):
import copyreg
import types
import pickle
Arusekk added the comment:
Feel free to reuse the patches if you have better ideas
--
Added file: https://bugs.python.org/file49123/robust.patch
___
Python tracker
<https://bugs.python.org/issue40
New submission from Arusekk :
This is another attempt at issue 39865, but with a different attitude. Please
see that issue for some extra motivation for this change.
My suggestion is to change getattr logic, which now is (in this case):
def getattr(obj, attr):
try:
return
New submission from Arusekk :
If this is a duplicate, please excuse me.
In particular, the most noticeable inaccuracy happens when the postfix if-else
expression is involved. Maybe there are more of them.
The problem is quite self-explaining. The module named 'dis' will be
Arusekk added the comment:
Since the issue seems to have been active lately, may I suggest my view on
solving it.
One solution that comes to my mind is to keep a weak reference to the file, and
to register an atexit function per file (and to unregister it when the file is
closed). Example