Thanks to visit codestin.com
Credit goes to github.com

Skip to content

AttributeError in 'python -m dis -C' #112620

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

Closed
gvanrossum opened this issue Dec 2, 2023 · 1 comment · Fixed by #112621
Closed

AttributeError in 'python -m dis -C' #112620

gvanrossum opened this issue Dec 2, 2023 · 1 comment · Fixed by #112621
Labels
3.13 bugs and security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@gvanrossum
Copy link
Member

gvanrossum commented Dec 2, 2023

Bug report

Bug description:

Sorry @iritkatriel, I hit another crash in the new dis code:

~/cpython$ ./python.exe -m dis -C Lib/re/_compiler.py >/dev/null
Traceback (most recent call last):
  File "/Users/guido/cpython/Lib/runpy.py", line 198, in _run_module_as_main
    return _run_code(code, main_globals, None,
           ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
                     "__main__", mod_spec)
                     ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/guido/cpython/Lib/runpy.py", line 88, in _run_code
    exec(code, run_globals)
    ~~~~^^^^^^^^^^^^^^^^^^^
  File "/Users/guido/cpython/Lib/dis.py", line 991, in <module>
    main()
    ~~~~^^
  File "/Users/guido/cpython/Lib/dis.py", line 988, in main
    dis(code, show_caches=args.show_caches, show_offsets=args.show_offsets)
    ~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/guido/cpython/Lib/dis.py", line 114, in dis
    _disassemble_recursive(x, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive, show_offsets=show_offsets)
    ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/guido/cpython/Lib/dis.py", line 714, in _disassemble_recursive
    disassemble(co, file=file, show_caches=show_caches, adaptive=adaptive, show_offsets=show_offsets)
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/guido/cpython/Lib/dis.py", line 706, in disassemble
    _disassemble_bytes(_get_code_array(co, adaptive),
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                       lasti, co._varname_from_oparg,
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<2 lines>...
                       co_positions=co.co_positions(), show_caches=show_caches,
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                       original_code=co.co_code, show_offsets=show_offsets)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/guido/cpython/Lib/dis.py", line 777, in _disassemble_bytes
    print(instr._disassemble(lineno_width, is_current_instr, offset_width),
          ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/guido/cpython/Lib/dis.py", line 493, in _disassemble
    fields.append(' ' * self.label_width)
                        ^^^^^^^^^^^^^^^^
AttributeError: 'Instruction' object has no attribute 'label_width'

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs

@gvanrossum gvanrossum added the type-bug An unexpected behavior, bug, or error label Dec 2, 2023
@AlexWaygood AlexWaygood added stdlib Python modules in the Lib dir 3.13 bugs and security fixes labels Dec 2, 2023
@iritkatriel
Copy link
Member

iritkatriel commented Dec 2, 2023

Thanks, I'll fix. In the meantime you can replace locally the self.label_width with getattr(self, "label_width", 6) so you can get on with your work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants