[issue1878] class attribute cache failure (regression)

2008-10-13 Thread Jesús Cea Avión

Changes by Jesús Cea Avión [EMAIL PROTECTED]:


--
nosy: +jcea

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1878
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1878] class attribute cache failure (regression)

2008-08-19 Thread Guido van Rossum

Guido van Rossum [EMAIL PROTECTED] added the comment:

I like Armin's latest proposal: have Py_TPFLAGS_DEFAULT include
Py_TPFLAGS_HAVE_VERSION_TAG when compiling the core only.  ISTR there's
a way to do this, but I can't find it right now.

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1878
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1878] class attribute cache failure (regression)

2008-08-19 Thread Guido van Rossum

Guido van Rossum [EMAIL PROTECTED] added the comment:

Please review the patch here: http://codereview.appspot.com/3005

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1878
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1878] class attribute cache failure (regression)

2008-08-19 Thread Guido van Rossum

Guido van Rossum [EMAIL PROTECTED] added the comment:

Submitted as r65874.

I will block this for 3.0; 3.0 extensions that want to mess with tp_dict
must explicitly disable this flag.

--
resolution:  - fixed
status: open - closed

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1878
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1878] class attribute cache failure (regression)

2008-08-19 Thread Benjamin Peterson

Benjamin Peterson [EMAIL PROTECTED] added the comment:

Do we want a test?

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1878
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1878] class attribute cache failure (regression)

2008-08-19 Thread Guido van Rossum

Guido van Rossum [EMAIL PROTECTED] added the comment:

Sure, go right ahead.

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1878
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1878] class attribute cache failure (regression)

2008-07-31 Thread Raymond Hettinger

Raymond Hettinger [EMAIL PROTECTED] added the comment:

Guido, what say you, live with it, revert it, or apply 
Py_TPFLAGS_HAVE_VERSION_TAG to all core types?

--
assignee: arigo - gvanrossum
nosy: +gvanrossum, rhettinger

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1878
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1878] class attribute cache failure (regression)

2008-07-31 Thread Armin Rigo

Armin Rigo [EMAIL PROTECTED] added the comment:

Maybe there is a better solution along the following line: conditionally
define Py_TPFLAGS_DEFAULT so that when compiling the Python core it
includes the Py_TPFLAGS_HAVE_VERSION_TAG, but when compiling extension
modules it does not.  This should ensure compatibility with many
existing extension modules.  (It would still break if they play tricks
like modifying the tp_dict of types other than their own.)

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;

* new C API functions should be introduced to give an official way to
access the tp_dict of a type, e.g. PyType_{Get,Set,Del}DictItemString().

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1878
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1878] class attribute cache failure (regression)

2008-07-30 Thread Benjamin Peterson

Benjamin Peterson [EMAIL PROTECTED] added the comment:

Ping

--
nosy: +benjamin.peterson
priority: critical - release blocker

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1878
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1878] class attribute cache failure (regression)

2008-01-21 Thread Armin Rigo

Armin Rigo added the comment:

I don't see in general how the patch can be kept compatible with
extension modules that change the tp_dict of arbitrary types.  All I can
think of is a way to be safe against extension modules that only change
the tp_dict of their own non-heap types (i.e. types defined in C).  The
method cache is disabled for types that don't have the
Py_TPFLAGS_HAVE_VERSION_TAG flag; so if we would leave this flag out of
Py_TPFLAGS_DEFAULT, non-heap types from extension modules would by
default not use the cache.

I'm not sure about the API for this.  Would we then need to put
Py_TPFLAGS_HAVE_VERSION_TAG explicitly on all core types?  And about how
to change tp_dict in a way that makes the cache happy - do we need to
turn type_modified() into a public API?

All in all, the lack of abstraction of the C API might kill the idea of
this patch for CPython.

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1878
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1878] class attribute cache failure (regression)

2008-01-21 Thread Georg Brandl

Changes by Georg Brandl:


--
priority:  - urgent

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1878
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1878] class attribute cache failure (regression)

2008-01-21 Thread Georg Brandl

Georg Brandl added the comment:

We can of course add something like in #1229239, which allows type
attributes to be set with PyObject_SetAttr, thereby updating the cache.

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1878
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1878] class attribute cache failure (regression)

2008-01-21 Thread Paul Pogonyshev

Paul Pogonyshev added the comment:

I personally think that this bug is a showstopper for the caching patch
in 2.6.  Well, the problem can be deemed insignificant, but it is sure a
break of backward compatibility and, worse yet, it results in _very_
obscure fails.  Even if type dictionary changes are not all that common,
I'm sure there are extensions out there that do it.

For Py3k things can be different.  I'm not sure what would be the best
way, but at least Py3k is not required to be compatible with 2.x in all
aspects.

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1878
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1878] class attribute cache failure (regression)

2008-01-20 Thread Paul Pogonyshev

New submission from Paul Pogonyshev:

I have a regression from Python 2.5 to Python SVN (would-be-2.6).  I
believe this because of class attribute caching.  The problem shown
below happens because AbstractGCProtector is an extension class.  So,
Python interpreter doesn't have a chance to notice set_default() method
below changes a class attribute.

 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
and 2.5.

--
components: Interpreter Core
messages: 61316
nosy: _doublep
severity: major
status: open
title: class attribute cache failure (regression)
type: behavior
versions: Python 2.6

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1878
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1878] class attribute cache failure (regression)

2008-01-20 Thread Paul Pogonyshev

Paul Pogonyshev added the comment:

Eh, disregard that, I missed one line with set_default() call.  Still,
the unit test fails...

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1878
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1878] class attribute cache failure (regression)

2008-01-20 Thread Paul Pogonyshev

Paul Pogonyshev added the comment:

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
False/True lines are reversed, as expected.  I.e. it seems that
attribute cache is sometimes recomputed...

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1878
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1878] class attribute cache failure (regression)

2008-01-20 Thread Paul Pogonyshev

Paul Pogonyshev added the comment:

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,
unpack and do './run-tests.py' at top level.  One test fails with Python
SVN precisely because of this problem.

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1878
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1878] class attribute cache failure (regression)

2008-01-20 Thread Georg Brandl

Georg Brandl added the comment:

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
anything about this.

--
nosy: +georg.brandl

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1878
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1878] class attribute cache failure (regression)

2008-01-20 Thread Georg Brandl

Georg Brandl added the comment:

I'm sorry, but I can't get this to run. With a clean 0.1.14 tarball, I get

Building extension...
running build_ext
building 'notify.gc' extension
creating build
creating build/temp.linux-i686-2.5
creating build/temp.linux-i686-2.5/notify
i686-pc-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -fPIC
-I/usr/include/python2.5 -c notify/gc.c -o
build/temp.linux-i686-2.5/notify/gc.o
creating build/lib.linux-i686-2.5
creating build/lib.linux-i686-2.5/notify
i686-pc-linux-gnu-gcc -pthread -shared
build/temp.linux-i686-2.5/notify/gc.o -L/usr/lib -lpython2.5 -o
build/lib.linux-i686-2.5/notify/gc.so
[1]28189 segmentation fault  ~/devel/python/python run-tests.py

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
in run-tests.py, I get


Note that most of the time is spent in gc.collect() calls, not in this
package

..Fatal
Python error: Objects/classobject.c:2311 object at 0x82dd2bc has
negative ref count -606348326
[1]28540 abort  ~/devel/python/python run-tests.py

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1878
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1878] class attribute cache failure (regression)

2008-01-20 Thread Paul Pogonyshev

Paul Pogonyshev added the comment:

Weird.  Does it even run with a stable Python (not trunk)?

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1878
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1878] class attribute cache failure (regression)

2008-01-20 Thread Paul Pogonyshev

Paul Pogonyshev added the comment:

Can you run the pasted script (from the third comment) manually then? 
The crash might be related to the bug in question.

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1878
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1878] class attribute cache failure (regression)

2008-01-20 Thread Georg Brandl

Georg Brandl added the comment:

Yes, runs fine with 2.5.

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1878
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1878] class attribute cache failure (regression)

2008-01-20 Thread Georg Brandl

Georg Brandl added the comment:

I've now built my trunk python without debugging enabled, and can
reproduce your problem.

Armin: the extension module directly modifies an extension type's
tp_dict -- what should it do instead to make the cache happy?

--
assignee:  - arigo
nosy: +arigo

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1878
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1878] class attribute cache failure (regression)

2008-01-20 Thread Paul Pogonyshev

Paul Pogonyshev added the comment:

Even if there is an easy workaround for the extension (or even a fix, if
modifying 'tp_dict' is not legal), I don't think it would be acceptable
to make a backward-incompatible change in 2.6.  I mean, sure Py-notify
is by no means a widely-used library, but can you guarantee that no
other extension will get broken?

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1878
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1878] class attribute cache failure (regression)

2008-01-20 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

The issue seems similar to the one we had in ctypes when the method
attribute cache was implemented. 

Ctypes was corrected in r59943. Maybe similar changes are needed for
this extension.

For example,
  PyDict_SetItemString (AbstractGCProtector_Type.tp_dict, default,
new_protector)
should be modified like this:
  PyObject_SetAttr(AbstractGCProtector_Type, default, new_protector)

--
nosy: +amaury.forgeotdarc

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1878
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1878] class attribute cache failure (regression)

2008-01-20 Thread Paul Pogonyshev

Paul Pogonyshev added the comment:

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,
default, new_protector)
  == -1)
return NULL;

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1878
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com