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

Rule UP022 cause panic #7126

Closed
qarmin opened this issue Sep 4, 2023 · 2 comments · Fixed by #7149
Closed

Rule UP022 cause panic #7126

qarmin opened this issue Sep 4, 2023 · 2 comments · Fixed by #7149
Assignees
Labels
bug Something isn't working fuzzer Surfaced via fuzzing. help wanted Contributions especially welcome

Comments

@qarmin
Copy link

qarmin commented Sep 4, 2023

Ruff 0.0.287 (latest changes from main branch)

ruff  *.py --select UP022 --no-cache --fix

file content(at least simple cpython script shows that this is valid python file):

import subprocess
def _get_test_output(cmd_list):
    try:
        CP = subprocess.run(cmd_list, timeout=5,
                            check=True, capture_output=True,
                            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    except Exception:
        return None

error

warning: Linting panicked /home/rafal/test/tmp_folder/6796824.py: This indicates a bug in `ruff`. If you could open an issue at:

https://github.com/astral-sh/ruff/issues/new?title=%5BLinter%20panic%5D

with the relevant file contents, the `pyproject.toml` settings, and the following stack trace, we'd be very appreciative!

panicked at 'assertion failed: start.raw <= end.raw', /home/rafal/test/ruff/crates/ruff_text_size/src/range.rs:48:9
Backtrace:    0: ruff_cli::panic::catch_unwind::{{closure}}
   1: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/alloc/src/boxed.rs:2007:9
   2: std::panicking::rust_panic_with_hook
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:709:13
   3: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:595:13
   4: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/sys_common/backtrace.rs:151:18
   5: rust_begin_unwind
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:593:5
   6: core::panicking::panic_fmt
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/panicking.rs:67:14
   7: core::panicking::panic
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/panicking.rs:117:5
   8: ruff::linter::lint_fix
   9: ruff_cli::diagnostics::lint_path
  10: rayon::iter::plumbing::bridge_producer_consumer::helper
  11: ruff_cli::commands::check::check
  12: ruff_cli::check
  13: ruff_cli::run
  14: ruff::main
  15: std::sys_common::backtrace::__rust_begin_short_backtrace
  16: main
  17: __libc_start_call_main
             at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  18: __libc_start_main_impl
             at ./csu/../csu/libc-start.c:360:3
  19: _start


@MichaReiser MichaReiser added bug Something isn't working fuzzer Surfaced via fuzzing. help wanted Contributions especially welcome labels Sep 4, 2023
@dhruvmanila
Copy link
Member

Interesting! This is happening because the fixes are being overlapped. The fix generates 2 edits:

  1. Remove stdout=subprocess.PIPE,
  2. Remove , stderr=subprocess.PIPE

Notice that the , (comma, space) are overlapping between the two edits.

@charliermarsh
Copy link
Member

Maybe we just skip this fix when capture_output=True is set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fuzzer Surfaced via fuzzing. help wanted Contributions especially welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants