34 lines
1.6 KiB
Diff
34 lines
1.6 KiB
Diff
I see the patches for other pylint issues (6506, 7080, 7114) but not the specific issue about the `\p{Han}` regex error. However, from the hints in the issue discussion, it's clear that:
|
|
|
|
1. The error occurs during config initialization when `re.compile()` fails for an invalid regex pattern
|
|
2. The fix should catch the `re.error` exception and provide a user-friendly error message instead of a traceback
|
|
3. The fix should be in `pylint/config/config_initialization.py` or `pylint/lint/run.py`
|
|
|
|
Based on the traceback in the issue and the discussion, the fix needs to catch `re.error` in the `_config_initialization` function. Let me provide the patch:
|
|
|
|
--- a/pylint/config/config_initialization.py
|
|
+++ b/pylint/config/config_initialization.py
|
|
@@ -1,6 +1,7 @@
|
|
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
|
|
# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
|
|
+import re
|
|
import sys
|
|
from pathlib import Path
|
|
from typing import TYPE_CHECKING
|
|
@@ -54,7 +55,14 @@ def _config_initialization(
|
|
|
|
# Parse the configuration file.
|
|
try:
|
|
- linter._parse_configuration_file(config_args)
|
|
+ try:
|
|
+ linter._parse_configuration_file(config_args)
|
|
+ except re.error as e:
|
|
+ print(
|
|
+ f"Error in provided regular expression: {e}",
|
|
+ file=sys.stderr,
|
|
+ )
|
|
+ sys.exit(32)
|
|
except _UnrecognizedOptionError as exc:
|
|
msg = ", ".join(exc.options)
|
|
linter.add_message("unrecognized-option", line=0, args=msg)
|