Code Monkey home page Code Monkey logo

Comments (3)

davisagli avatar davisagli commented on June 12, 2024

I don't know the answers, but anecdotally, I was just able to get AccessControl to build by changing its copy of ExtensionClass.h to use HAS_TP_DESCR_GET here, even without including _compat.h anywhere new.

from extensionclass.

stephan-hof avatar stephan-hof commented on June 12, 2024

From my point of view this whole macro is very dangerous and the best would be to get rid of it.
PyMem_DEL is meant to delete an arbitrary chunk of data. See here https://docs.python.org/3.5/c-api/memory.html?highlight=pymem_del#c.PyMem_Del

With this redefinition we change the meaning to: "Free an object". So if people use PyMem_Del as documented in the python docu they are risking segfaults.

Mapping PyObject_DEL to PyMem_DEL is also dangerous, because different allocators are used behind the scenes.
According to this https://docs.python.org/2/whatsnew/2.5.html PyObject_XX and PyMEM_XX cannot be mixed anymore.
With 2.5’s changes to obmalloc, these families now do different things and mismatches will probably result in a segfault. You should carefully test your C extension modules with Python 2.5

I searched where PyMem_Del is used inside zopefoundation code.
https://github.com/search?q=org%3Azopefoundation+PyMem_DEL&type=Code
The only occurrence is in ExtensionClass.h copied to the various repos using ExtensionClass.
The same is true for PyObject_FREE.

I guess back at the days, when new style classes were introduced, there was a use for this macro.
Hence the comment, but nowadays they have no use.

So if nobody objects I'll prepare a pull request to get rid of this macros.

from extensionclass.

hannosch avatar hannosch commented on June 12, 2024

+1 for removing the macro

from extensionclass.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.