-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
class attribute cache failure (regression) #46186
Comments
I have a regression from Python 2.5 to Python SVN (would-be-2.6). I >>> from notify.all import *
>>> original_protector = AbstractGCProtector.default
>>> new_protector = FastGCProtector ()
>>> AbstractGCProtector.default is new_protector
False
>>> AbstractGCProtector.default is original_protector
True Please note that this a regression. This code works as expected in 2.3 |
Eh, disregard that, I missed one line with set_default() call. Still, |
OK, here it is: >>> from notify.all import *
>>> original_protector = AbstractGCProtector.default
>>> new_protector = FastGCProtector ()
>>> AbstractGCProtector.set_default (new_protector)
>>> AbstractGCProtector.default is new_protector
False
>>> AbstractGCProtector.default is original_protector
True It seems that this behaviour is somewhat random. Sometimes the |
It would be very interesting to know what set_default() actually does. IOW, without the source code of the extension module we can't do |
set_default() is a static method to set 'default'. Because of this: >>> AbstractGCProtector.default = 42
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can't set attributes of built-in/extension type
'notify.gc.AbstractGCProtector' About source code: go to http://download.gna.org/py-notify/ download, |
I'm sorry, but I can't get this to run. With a clean 0.1.14 tarball, I get Building extension... when running with a trunk python (note the "2.5" in the paths...) When I build the extension manually and comment out the building command Note that most of the time is spent in gc.collect() calls, not in this ..............................................................Fatal |
Weird. Does it even run with a stable Python (not trunk)? |
Yes, runs fine with 2.5. |
Can you run the pasted script (from the third comment) manually then? |
I've now built my trunk python without debugging enabled, and can Armin: the extension module directly modifies an extension type's |
Even if there is an easy workaround for the extension (or even a fix, if |
The issue seems similar to the one we had in ctypes when the method Ctypes was corrected in r59943. Maybe similar changes are needed for For example, |
It doesn't help: ERROR: test_default_property (test._gc.AbstractGCProtectorTestCase) Traceback (most recent call last):
File "/home/paul/notify/test/_gc.py", line 59, in test_default_property
AbstractGCProtector.set_default (original_protector)
TypeError: can't set attributes of built-in/extension type
'notify.gc.AbstractGCProtector' With this code: if (PyObject_SetAttrString ((PyObject *) &AbstractGCProtector_Type, |
I don't see in general how the patch can be kept compatible with I'm not sure about the API for this. Would we then need to put All in all, the lack of abstraction of the C API might kill the idea of |
We can of course add something like in bpo-1229239, which allows type |
I personally think that this bug is a showstopper for the caching patch For Py3k things can be different. I'm not sure what would be the best |
Ping |
Guido, what say you, live with it, revert it, or apply |
Maybe there is a better solution along the following line: conditionally In addition, to support the method cache in newer C extension modules: * C types defined by C extension modules can include the
Py_TPFLAGS_HAVE_VERSION_TAG explicitly to enable the cache;
|
I like Armin's latest proposal: have Py_TPFLAGS_DEFAULT include |
Please review the patch here: http://codereview.appspot.com/3005 |
Submitted as r65874. I will block this for 3.0; 3.0 extensions that want to mess with tp_dict |
Do we want a test? |
Sure, go right ahead. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: