Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The tests for the dis module can be too rigid when changing opcodes #79261

Closed
MaximeBelanger mannequin opened this issue Oct 26, 2018 · 3 comments
Closed

The tests for the dis module can be too rigid when changing opcodes #79261

MaximeBelanger mannequin opened this issue Oct 26, 2018 · 3 comments
Labels
3.8 only security fixes stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-feature A feature request or enhancement

Comments

@MaximeBelanger
Copy link
Mannequin

MaximeBelanger mannequin commented Oct 26, 2018

BPO 35080
Nosy @serhiy-storchaka
PRs
  • bpo-35080: Tests for dis are more flexible to opcode changes #10142
  • 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 2018-10-27.05:27:14.637>
    created_at = <Date 2018-10-26.23:35:56.520>
    labels = ['tests', '3.8', 'type-feature', 'library']
    title = 'The tests for the `dis` module can be too rigid when changing opcodes'
    updated_at = <Date 2018-10-27.05:27:14.636>
    user = 'https://bugs.python.org/MaximeBelanger'

    bugs.python.org fields:

    activity = <Date 2018-10-27.05:27:14.636>
    actor = 'Maxime Belanger'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-10-27.05:27:14.637>
    closer = 'Maxime Belanger'
    components = ['Library (Lib)', 'Tests']
    creation = <Date 2018-10-26.23:35:56.520>
    creator = 'Maxime Belanger'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 35080
    keywords = ['patch']
    message_count = 3.0
    messages = ['328615', '328638', '328641']
    nosy_count = 2.0
    nosy_names = ['serhiy.storchaka', 'Maxime Belanger']
    pr_nums = ['10142']
    priority = 'normal'
    resolution = 'wont fix'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue35080'
    versions = ['Python 3.8']

    @MaximeBelanger
    Copy link
    Mannequin Author

    MaximeBelanger mannequin commented Oct 26, 2018

    For various reasons, one may want to change the [Lib/opcode.py](https://github.com/python/cpython/blob/main/Lib/opcode.py) module. In doing so, this has caused us to frequently rewrite test_dis.py. It would be great if those tests used dis.opmap rather than hard-coded/magic numbers, as this would allow easier changes.

    @MaximeBelanger MaximeBelanger mannequin added 3.8 only security fixes type-feature A feature request or enhancement stdlib Python modules in the Lib dir tests Tests in the Lib/test dir labels Oct 26, 2018
    @serhiy-storchaka
    Copy link
    Member

    Actually this change decreases flexibility of tests. Expected output is generated. See the comment above it. When you change the bytecode, you need just uncomment these lines, run tests, copy the output, and comment out them back. The output contains numerical values of opcodes.

    It is rarely they are changed without changing the meaning of opcodes. It is more common to add new opcodes and replace old opcodes with other opcodes with different semantic. This leads to changing opcode arguments and offsets, adding and removing lines.

    @MaximeBelanger
    Copy link
    Mannequin Author

    MaximeBelanger mannequin commented Oct 27, 2018

    Ah, quite right; apologies for the not-so-useful PR!

    @MaximeBelanger MaximeBelanger mannequin closed this as completed Oct 27, 2018
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant