This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Remove "capsule hack" from object.c?
Type: behavior Stage: resolved
Components: Versions: Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: larry Nosy List: BreamoreBoy, larry, ncoghlan, pitrou, python-dev, steve.dower, vstinner
Priority: low Keywords: patch

Created on 2014-04-17 23:55 by larry, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
larry.remove.no.capsule.hack.1.diff larry, 2014-04-17 23:55 review
Messages (7)
msg216766 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2014-04-17 23:55
I noticed this code in Objects/object.c today:

    /* Hack to force loading of pycapsule.o */
    PyTypeObject *_PyCapsule_hack = &PyCapsule_Type;

What is this doing?  Note that PyCapsule_Type is referred to inside _Py_ReadyTypes(), so there's already a reference to it from this module.  This global seems redundant.

Attached is a patch that removes it.  Trunk compiles and all tests pass with it applied, though I only tried on 64-bit Linux so I concede if this is handling some obscure edge case I probably wouldn't have hit it.
msg236625 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2015-02-25 21:55
I've taken a bit of a liberty and picked the names of the last three guys who've worked on this file as I assume they're best qualified to comment.
msg236937 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2015-03-01 06:44
I'm inclined to suggest you try removing it and see what happens on the buildbots.

I remember we used to have a few interesting challenges at my old job convincing Visual Studio that we really were using a type definition and we should export it from the DLL. That was way back in the VC6 days though, so I expect the situation has improved by now.

Added Steve to the nosy list to see if he's aware of any current Windows specific reasons this might be needed.
msg237051 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2015-03-02 15:48
No current reasons I'm aware of (apart from not having a working up-to-date Windows buildbot right now - blocked on #23524) so I'd say go ahead. Pull it out and see what breaks.

The fact that the comment says "pycapsule.o" and not "pycapsule.obj" probably means this wasn't a Windows issue in the first place.
msg237052 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2015-03-02 15:52
You give me too much credit.  I'm the chimp who put it there in the first place.  Though, admittedly, it was a copy&paste job based on the ancient CObject.

My guess is this was very helpful in 1.4, or something.  ;-)
msg237059 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-03-02 16:45
New changeset b22755f8ab5f by Larry Hastings in branch 'default':
Issue #21293: Remove unnecessary "capsule hack".
https://hg.python.org/cpython/rev/b22755f8ab5f
msg237060 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2015-03-02 16:46
Yeah, I went ahead and checked this in.  I'm living life on the *edge*.

To the EXTREME!
History
Date User Action Args
2022-04-11 14:58:02adminsetgithub: 65492
2015-03-02 16:46:51larrysetstatus: open -> closed
messages: + msg237060

assignee: larry
resolution: fixed
stage: patch review -> resolved
2015-03-02 16:45:40python-devsetnosy: + python-dev
messages: + msg237059
2015-03-02 15:52:41larrysetmessages: + msg237052
2015-03-02 15:48:49steve.dowersetmessages: + msg237051
2015-03-01 06:44:07ncoghlansetnosy: + steve.dower
messages: + msg236937
2015-02-25 21:55:50BreamoreBoysetnosy: + BreamoreBoy, vstinner, ncoghlan, pitrou
messages: + msg236625
2014-04-17 23:55:53larrycreate