GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • [ date ]
  • [ thread ]
  • [ subject ]
  • [ author ]

This view

  • Original page
  • New address

GeezerVison is showing mail.python.org — [Python-Dev] Why is type_modified() in typeobject.c not a public function?

[Python-Dev] Why is type_modified() in typeobject.c not a public function?

Stefan Behnel stefan_ml at behnel.de
Wed May 28 07:47:16 CEST 2008

  • Previous message: [Python-Dev] Why is type_modified() in typeobject.c not a public function?
  • Next message: [Python-Dev] Why is type_modified() in typeobject.c not a public function?
  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

Hi,

Guido van Rossum wrote:
> On Tue, May 27, 2008 at 9:47 AM, Stefan Behnel <stefan_ml at behnel.de> wrote:
>> Could this function get a public interface? I do not think Cython is the only
>> case where C code wants to modify a type after its creation, and copying the
>> code over seems like a hack to me.
>>
> I'm fine with giving it a public interface. Please submit a patch with
> docs included.

Straight forward patch is attached (against 3.0a5). Works for me in Cython. I
thought about a name like "Taint(t)" or "ClearTypeCache(t)", but then went
with the coward solution of calling the function PyType_Modified() as it was
(almost) named internally.

BTW, I noticed that the code in typeobject.c uses "DECREF before set" two
times, like this:

		method_cache[h].version = type->tp_version_tag;
		method_cache[h].value = res;  /* borrowed */
		Py_INCREF(name);
		Py_DECREF(method_cache[h].name);
		method_cache[h].name = name;

During the call to Py_DECREF, the cache content is incorrect, so can't this
run into the same problem that Py_CLEAR() aims to solve? I attached a patch
for that, too, just in case.

Stefan


-------------- next part --------------
A non-text attachment was scrubbed...
Name: pytype_modified.patch
Type: text/x-patch
Size: 3095 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-dev/attachments/20080528/9c4d77f4/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: possible-decref-before-set-fix.patch
Type: text/x-patch
Size: 1311 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-dev/attachments/20080528/9c4d77f4/attachment-0001.bin>

  • Previous message: [Python-Dev] Why is type_modified() in typeobject.c not a public function?
  • Next message: [Python-Dev] Why is type_modified() in typeobject.c not a public function?
  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

More information about the Python-Dev mailing list
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.