Skip to content

Namespace disassembly omits some compiled objects #75380

Open

Description

@ncoghlan
BPO 31197
Nosy @ncoghlan

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 = None
created_at = <Date 2017-08-14.06:39:45.401>
labels = ['3.7']
title = 'Namespace disassembly omits some compiled objects'
updated_at = <Date 2017-08-18.02:26:15.646>
user = 'https://github.com/ncoghlan'

bugs.python.org fields:

activity = <Date 2017-08-18.02:26:15.646>
actor = 'ncoghlan'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = []
creation = <Date 2017-08-14.06:39:45.401>
creator = 'ncoghlan'
dependencies = []
files = []
hgrepos = []
issue_num = 31197
keywords = []
message_count = 4.0
messages = ['300234', '300235', '300291', '300469']
nosy_count = 1.0
nosy_names = ['ncoghlan']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = None
url = 'https://bugs.python.org/issue31197'
versions = ['Python 3.7']

Activity

  1. ncoghlan commented on Aug 14, 2017

    @ncoghlan
    ContributorAuthor

    In reviewing the PR for bpo-31183, I noticed that the criteria for deciding which values to disassemble when disassembling a namespace (objects with a __dict__ attribute) has gotten out of sync with the criteria used by the dis() itself.

    The problem is that dis() checks for particular attributes that may contain code objects, while the recursive descent when processing a __dict__ attribute is based on isinstance() and a predefined list of types.

    My proposed remedy for this would be:

    1. Factor out a dis._get_code() helper function that returns either None or a compiled code object
    2. Base the recursive descent in __dict__ processing on the value either having a __dict__ attribute, or else _get_code() returning a non-None result (in the latter case, the code object itself would be passed to the recursive call, rather than the original value from the namespace)
  2. ncoghlan commented on Aug 14, 2017

    @ncoghlan
    ContributorAuthor

    Note that the current dis._get_code_object() helper doesn't *quite* cover this, as it will implicitly compile raw strings, which isn't the desired behaviour for this use case.

  3. ncoghlan commented on Aug 15, 2017

    @ncoghlan
    ContributorAuthor

    Another refactoring point that came up in the same discussion: it might be nice if the objects that expose code attributes all offered a read-only __code__ property, rather than requiring the dis module (and other consumers) to be aware of all the different object-specific property names.

  4. ncoghlan commented on Aug 18, 2017

    @ncoghlan
    ContributorAuthor

    For ease of reference, I separated out the idea of a common __code__ attribute to its own RFE: https://bugs.python.org/issue31230

  5. transferred this issue fromon Apr 10, 2022
  6. added
    stdlib
    on Nov 27, 2023
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

    3.7 (EOL)stdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions