Skip to content

Redundant doc field in TypeSpec #55344

Closed
Closed

Description

@loewis
mannequin
BPO 11135
Nosy @loewis, @birkenfeld
Files
  • tp_doc.diff
  • 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:

    assignee = None
    closed_at = <Date 2011-02-11.20:48:09.661>
    created_at = <Date 2011-02-06.20:02:06.110>
    labels = ['release-blocker']
    title = 'Redundant doc field in TypeSpec'
    updated_at = <Date 2011-02-16.21:05:52.097>
    user = 'https://github.com/loewis'

    bugs.python.org fields:

    activity = <Date 2011-02-16.21:05:52.097>
    actor = 'loewis'
    assignee = 'none'
    closed = True
    closed_date = <Date 2011-02-11.20:48:09.661>
    closer = 'loewis'
    components = []
    creation = <Date 2011-02-06.20:02:06.110>
    creator = 'loewis'
    dependencies = []
    files = ['20706']
    hgrepos = []
    issue_num = 11135
    keywords = ['patch']
    message_count = 7.0
    messages = ['128077', '128114', '128427', '128665', '128691', '128696', '128697']
    nosy_count = 3.0
    nosy_names = ['loewis', 'georg.brandl', 'Egon.Smiwa']
    pr_nums = []
    priority = 'release blocker'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue11135'
    versions = ['Python 3.2']

    Activity

    1. loewis commented on Feb 6, 2011

      loewismannequin
      MannequinAuthor

      There are currently two ways to specify a type doc string in PyType_FromSpec; either through the doc field (which is not actually processed), or through Py_tp_doc (which works correctly).

      The original concern for adding doc into the TypeSpec was that the slots may only refer to function pointers; as it turns out, putting character pointers in there works fine as well, so I recommend to drop the doc field in TypeSlot.

      The patch also fixes some labelling in the xxlimited module.

    2. birkenfeld commented on Feb 7, 2011

      @birkenfeld
      Member

      Looks good.

    3. loewis commented on Feb 11, 2011

      loewismannequin
      MannequinAuthor

      Thansk for the review. Committed as r88400.

    4. EgonSmiwa commented on Feb 16, 2011

      EgonSmiwamannequin
      Mannequin

      You bring the tp_doc parameter pointer
      into the ownership of the new typeobject?
      and tp_doc is assumed to be created by pyObject_malloc?
      IMO, if CPython wants to be the owner of the string parameter,
      then it should make a copy of that parameter (tp_doc)
      and become owner of that copy.

    5. loewis commented on Feb 16, 2011

      loewismannequin
      MannequinAuthor

      It's the same as the current tp_doc parameter for static type objects, and essentially like any other doc string in the C API. It's owned by the extension module, which must make sure it lives at least as long as the type object.

    6. EgonSmiwa commented on Feb 16, 2011

      EgonSmiwamannequin
      Mannequin

      Hello, I'm just a app developer which is embedding the python32.dll
      and I assumed (and wished) python would simply copy my allocated parameter-string into the type object (( spec->name) is copied too). I looked in the source and see this ownership confirmed:

      static void 
      type_dealloc(PyTypeObject *type)
      .... PyObject_Free((char *)type->tp_doc);

      The typeobject owns tp_doc and even requires a special allocation (pyobject_malloc), which is no problem if the type creates its own copy; the hosting app is not connected.

    7. loewis commented on Feb 16, 2011

      loewismannequin
      MannequinAuthor

      I see. This is an issue independent of the issue discussed here, though, please open a new issue for that. I agree that either tp_dealloc should not release the string, or should make a copy that it can release.

    8. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions