Skip to content

PEP 3121, 384 refactoring applied to dbm module #59855

Closed

Description

@RobinSchreiber
BPO 15650
Nosy @loewis, @vstinner, @asvetlov
Superseder
  • bpo-1635741: Py_Finalize() doesn't clear all Python objects at exit
  • Files
  • _dbmmodule_pep3121-384_v0.patch
  • Issue15650_v2.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 2020-12-18.00:43:53.569>
    created_at = <Date 2012-08-14.18:14:33.875>
    labels = ['extension-modules']
    title = 'PEP 3121, 384 refactoring applied to dbm module'
    updated_at = <Date 2020-12-18.00:43:53.568>
    user = 'https://bugs.python.org/RobinSchreiber'

    bugs.python.org fields:

    activity = <Date 2020-12-18.00:43:53.568>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-12-18.00:43:53.569>
    closer = 'vstinner'
    components = ['Extension Modules']
    creation = <Date 2012-08-14.18:14:33.875>
    creator = 'Robin.Schreiber'
    dependencies = []
    files = ['26804', '27774']
    hgrepos = []
    issue_num = 15650
    keywords = ['pep3121']
    message_count = 7.0
    messages = ['168216', '172310', '172320', '172323', '172644', '176650', '383279']
    nosy_count = 4.0
    nosy_names = ['loewis', 'vstinner', 'asvetlov', 'Robin.Schreiber']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '1635741'
    type = None
    url = 'https://bugs.python.org/issue15650'
    versions = ['Python 3.4']

    Activity

    1. RobinSchreiber commented on Aug 14, 2012

      RobinSchreibermannequin
      MannequinAuthor

      Changes proposed in PEP-3121 and PEP-384 have now been applied to the dbm module!

    2. asvetlov commented on Oct 7, 2012

      @asvetlov
      Contributor

      Robin, why do you increment refcounter for type object on every construction of dbm instance?

      Also I would to see macros in uppercase if possible.

    3. RobinSchreiber commented on Oct 7, 2012

      RobinSchreibermannequin
      MannequinAuthor

      PEP-384 demands, among other things, that the TypeObjects themselves are transformed to Heaptypes. This means that the Typeobjects, that are created from this new stable ABI, reside within the heap and therefore have to be managed by the Python GC. This is of course done by appropriately incref- and decrefing of the specific Heaptype.

    4. asvetlov commented on Oct 7, 2012

      @asvetlov
      Contributor

      From my perspective type object is referenced by module state.
      While module is present it's state hold all types exposed by module.
      After module has deleted it's state has cleaned up and types has gone away — thats look good to me.

      Instances of python classes (not extensions) hold ownership for it's class. I guess it done because python class can be constructed inside function and instance of this class should work after exit from that function like closure does.

      In case of extension modules enough to hold type reference into module state itself.

      Thoughts?

    5. asvetlov commented on Oct 11, 2012

      @asvetlov
      Contributor

      Robin, after thinking I would to agree with your decision to hold reference to type into type instance.

      Please, can you describe your check like:

      if((void *)type->tp_dealloc == (void *)dbm_dealloc) {
          Py_DECREF(type);
      }

      Why you decref only if type->tp_dealloc points to module's dealloc? What are you protected from? What other values also possible?

    6. RobinSchreiber commented on Nov 29, 2012

      RobinSchreibermannequin
      MannequinAuthor

      Take a look at the discussion in bpo-15653.

    7. vstinner commented on Dec 18, 2020

      @vstinner
      Member

      Fixed by:

      commit bf69a8f
      Author: Dong-hee Na <donghee.na92@gmail.com>
      Date: Tue Jun 16 01:20:54 2020 +0900

      bpo-1635741: Port _dbm module to multiphase initialization (GH-20848)
      
    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

      Labels

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions