GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add missing dis features for modulefinder · Issue #3846 · RustPython/RustPython

Add missing dis features for modulefinder #3846

New issue
Copy link
New issue
Copy link
Closed
Closed
Add missing dis features for modulefinder#3846
Copy link
Labels
A-stdlibgood first issueGood for newcomersGood for newcomers

Description

@youknowone
youknowone
opened on Jul 8, 2022
Issue body actions

It is using a few missing features in _dis module.

Maybe adding them will not be enough for modulefinder due to bytecode imcompatibility.But adding dis items will be a good issue to start looking at RustPython project.

To add a new python module, check this article: https://rustpython.github.io/blog/2020/04/04/how-to-contribute-by-cpython-unittest.html

See #3863 for errors

Activity

  1. youknowone
    added
    good first issueGood for newcomersGood for newcomers
    A-stdlib
    on Jul 8, 2022
  2. itsankitkp commented on Jul 19, 2022

    @itsankitkp
    itsankitkp
    on Jul 19, 2022
    Contributor
    More actions

    Can I pick up this issue? Also, can you suggest a good place to start?

    Reacted by Jeong, YunWon
  3. youknowone
    assigned
    itsankitkp
    on Jul 19, 2022
  4. youknowone commented on Jul 19, 2022

    @youknowone
    youknowone
    on Jul 19, 2022
    MemberAuthor
    More actions

    try to checkout #3863 and check what kind of functions are not implemented.
    reading related cpython code is also helpful.

    In RustPython,
    _dis module is here: https://github.com/RustPython/RustPython/blob/main/stdlib/src/dis.rs
    dis module is here: https://github.com/RustPython/RustPython/blob/main/Lib/dis.py

  5. itsankitkp commented on Jul 19, 2022

    @itsankitkp
    itsankitkp
    on Jul 19, 2022
    Contributor
    More actions

    Thanks @youknowone, I will take a look at PR and specified files.

  6. itsankitkp commented on Jul 19, 2022

    @itsankitkp
    itsankitkp
    on Jul 19, 2022
    Contributor
    More actions

    My observations:

    1. dis.opmap['LOAD_CONST']
      cpython: 100
      rustpython: AttributeError: module 'dis' has no attribute 'opmap'

    2. dis.EXTENDED_ARG
      cpython: 144
      rustpython: AttributeError: module 'dis' has no attribute 'EXTENDED_ARG'

    3. dis._unpack_opargs(100)
      cpython: <generator object _unpack_opargs at 0x7f465322fde0>
      rustpython: AttributeError: module 'dis' has no attribute '_unpack_opargs'

    These are only relevant to #3863

    Additionally:
    dir(dis) in cpython
    ['BINARY_OP', 'Bytecode', 'CACHE', 'COMPILER_FLAG_NAMES', 'EXTENDED_ARG', 'FORMAT_VALUE', 'FORMAT_VALUE_CONVERTERS', 'FOR_ITER', 'HAVE_ARGUMENT', 'Instruction', 'JUMP_BACKWARD', 'LOAD_ATTR', 'LOAD_CONST', 'LOAD_GLOBAL', 'MAKE_FUNCTION', 'MAKE_FUNCTION_FLAGS', 'Positions', 'UNKNOWN', '_ExceptionTableEntry', '_INT_BITS', '_INT_OVERFLOW', '_Instruction', '_OPARG_WIDTH', '_OPNAME_WIDTH', '_Unknown', 'all', 'builtins', 'cached', 'doc', 'file', 'loader', 'name', 'package', 'spec', '_all_opmap', '_all_opname', '_cache_format', '_deoptop', '_disassemble_bytes', '_disassemble_recursive', '_disassemble_str', '_empty_slot', '_find_imports', '_find_store_names', '_format_code_info', '_get_code_array', '_get_code_object', '_get_const_info', '_get_const_value', '_get_instructions_bytes', '_get_name_info', '_have_code', '_inline_cache_entries', '_is_backward_jump', '_nb_ops', '_specializations', '_specialized_instructions', '_test', '_try_compile', '_unpack_opargs', 'cmp_op', 'code_info', 'collections', 'deoptmap', 'dis', 'disassemble', 'disco', 'distb', 'findlabels', 'findlinestarts', 'get_instructions', 'hasarg', 'hascompare', 'hasconst', 'hasexc', 'hasfree', 'hasjabs', 'hasjrel', 'haslocal', 'hasname', 'io', 'opmap', 'opname', 'parse_exception_table', 'parse_varint', 'pretty_flags', 'show_code', 'spec_op', 'specialized', 'stack_effect', 'sys', 'types']
    2. rustpython:
    ['COMPILER_FLAG_NAMES', 'builtins', 'cached', 'doc', 'file', 'loader', 'name', 'package', 'spec', '_test', 'dis', 'disassemble']

    So how do we approach this problem? Module finder needs _unpack_opargs, EXTENDED_ARG and opmap, if these gets implemented in dis module, requirement of this PR gets fulfilled right? @youknowone

  7. youknowone commented on Jul 20, 2022

    @youknowone
    youknowone
    on Jul 20, 2022
    MemberAuthor
    More actions

    yes, I think so. another small part is being ready to be not disappointed even when adding them doesn't fix the module.

    you even don't need to add all of them in single PR.
    we value and encourage every progressing step (without regression).

  8. itsankitkp commented on Jul 20, 2022

    @itsankitkp
    itsankitkp
    on Jul 20, 2022
    Contributor
    More actions

    Thanks for head up, I will be taking incremental approach to this and will mention any challenges.

    Reacted by Jeong, YunWon
  9. itsankitkp commented on Jul 20, 2022

    @itsankitkp
    itsankitkp
    on Jul 20, 2022
    Contributor
    More actions

    A quick question, how do we all translate python libraries? I get that c code is translated into equivalent rust code but what should be done for the Python code?
    For Python code depending on instruction, rustpython equivalent would need to skip out unimplemented piece but for purely python library (think opcode.py, just hard coded values of opcodes), do we need to translate something or code is practically same as cpython (python) library?

  10. youknowone commented on Jul 21, 2022

    @youknowone
    youknowone
    on Jul 21, 2022
    MemberAuthor
    More actions

    Ideally, we run the same code.
    But for opcodes, yes, as you described, it cannot be fully compatible. bytecodes are even not compatible between each cpython versions.
    When I looked in modulefinder a little bit, it only uses a few (probably stable) opcodes. I wish we also has that amount of stability, but I don't know we are or not.

    I don't expect you to translate python code to python code to run it. If you found it is not working, we will accept we cannot run it for now, and try to fix our compiler or vm later.
    But even if it happens, we will get a few new dis module features during the journey.

    Reacted by Lee Dogeon
  11. itsankitkp commented on Jul 24, 2022

    @itsankitkp
    itsankitkp
    on Jul 24, 2022
    Contributor
    More actions

    Okay I got it

  12. youknowone
    unassigned
    itsankitkp
    on Oct 15, 2022
  13. DimitrisJim
    changed the title [-]Add missing dis featues for modulefinder[/-] [+]Add missing dis features for modulefinder[/+] on Mar 30, 2023
  14. youknowone commented on Oct 6, 2026

    @youknowone
    youknowone
    on Oct 6, 2026
    MemberAuthor
    More actions

    The originally reported problem no longer reproduces on current main. Closing per the recheck in #8982.

    — commented by Grok 4.6

  15. youknowone
    closed this as completedon Oct 6, 2026
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

    A-stdlibgood first issueGood for newcomersGood for newcomers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.