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

[Linter panic] Panic when trying to fix code with arabic letters #3716

Closed
qarmin opened this issue Mar 24, 2023 · 0 comments · Fixed by #3898
Closed

[Linter panic] Panic when trying to fix code with arabic letters #3716

qarmin opened this issue Mar 24, 2023 · 0 comments · Fixed by #3898
Labels
bug Something isn't working

Comments

@qarmin
Copy link

qarmin commented Mar 24, 2023

Ruff 1bac206

ruff . --fix

File content

sentences = [
    "ಆಪಲ್ ಒಂದು ಯು.ಕೆ. ಸ್ಟಾರ್ಟ್ಅಪ್ ಅನ್ನು ೧ ಶತಕೋಟಿ ಡಾಲರ್ಗಳಿಗೆ ಖರೀದಿಸಲು ನೋಡುತ್ತಿದೆ.",
    "ಸ್ವಾಯತ್ತ ಕಾರುಗಳು ವಿಾ ಹೊಣೆಗಾರಿಕೆಯನ್ನು ತಯಾರರ ಕಡೆಗೆ ಬದಲಾಯಿಸುತ್ತವೆ.",
    "ಕಾಲುದಾರಿ ವಿತರಣಾ ರೋಬೋಟ್‌ಗಳನ್ನು ನಿಷೇಧಿುವುದನ್ನು ಸ್ಯಾನ್ ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​ಪರಿಗಣಿಸುತ್ತದೆ.",
    "ಲಂಡನ್ ಯುನೈಟೆಡ್ ಕಿಂಗ್‌ಡಂನ ದೊಡ್ಡ ನಗರ.",    "ನೀನು ಎಲ್ಲಿದಿಯಾ?",
    "ಫ್ರಾನ್ಸಾದ ಅಧ್ಯಕ್ಷರು ಯಾರು?",
    "ಯುನೈಟೆಡ್ ಸ್ಟೇಟ್ಸ್ನ ರಾಜಧಾನಿ ಯಾವುದು?",
]

crash

panicked at 'begin <= end (876 <= 651) when slicing `sentences = [
    "ಆಪಲ್ ಒಂದು ಯು.ಕೆ. ಸ್ಟಾರ್ಟ್ಅಪ್ ಅನ್ನು ೧ ಶತಕೋಟಿ ಡಾಲರ್ಗಳಿಗೆ ಖರೀದಿಸಲು ನೋಡುತ್ತಿದೆ.",
    "ಸ್ವಾಯತ್ತ ಕ`[...]', /home/rafal/test/ruff/crates/ruff_python_ast/src/source_code/locator.rs:45:10
Backtrace:    0: ruff_cli::panic::catch_unwind::{{closure}}
   1: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/alloc/src/boxed.rs:2032:9
   2: std::panicking::rust_panic_with_hook
             at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panicking.rs:692:13
   3: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panicking.rs:579:13
   4: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/sys_common/backtrace.rs:137:18
   5: rust_begin_unwind
             at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panicking.rs:575:5
   6: core::panicking::panic_fmt
             at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/panicking.rs:64:14
   7: core::str::slice_error_fail_rt
   8: core::str::slice_error_fail
             at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/str/mod.rs:86:9
   9: ruff_python_ast::source_code::locator::Locator::slice
  10: ruff::linter::lint_fix
  11: ruff_cli::diagnostics::lint_path
  12: rayon::iter::plumbing::bridge_producer_consumer::helper
  13: ruff_cli::commands::run::run
  14: ruff_cli::check
  15: ruff_cli::run
  16: ruff::main
  17: std::sys_common::backtrace::__rust_begin_short_backtrace
  18: main
  19: __libc_start_call_main
             at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  20: __libc_start_main_impl
             at ./csu/../csu/libc-start.c:381:3
  21: _start

@charliermarsh charliermarsh added the bug Something isn't working label Mar 24, 2023
konstin added a commit that referenced this issue Apr 6, 2023
Previously, we used byte indices when we should have used char indices, causing crashes when the were non-ascii characters before our replaces

Fixes #3716
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants