8000 FIX possible UnboundLocalError in fetch_openml (#26236) · lesteve/scikit-learn@a187758 · GitHub
[go: up one dir, main page]

10000 Skip to content

Commit a187758

Browse files
authored
FIX possible UnboundLocalError in fetch_openml (scikit-learn#26236)
1 parent 3450c4a commit a187758

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

sklearn/datasets/_openml.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -519,19 +519,21 @@ def _open_url_and_load_gzip_file(url, data_home, n_retries, delay, arff_params):
519519
url, data_home, n_retries, delay, arff_params
520520
)
521521
except Exception as exc:
522-
if parser == "pandas":
523-
from pandas.errors import ParserError
524-
525-
if isinstance(exc, ParserError):
526-
# A parsing error could come from providing the wrong quotechar
527-
# to pandas. By default, we use a double quote. Thus, we retry
528-
# with a single quote before to raise the error.
529-
arff_params["read_csv_kwargs"] = {"quotechar": "'"}
530-
X, y, frame, categories = _open_url_and_load_gzip_file(
531-
url, data_home, n_retries, delay, arff_params
532-
)
533-
else:
534-
raise
522+
if parser != "pandas":
523+
raise
524+
525+
from pandas.errors import ParserError
526+
527+
if not isinstance(exc, ParserError):
528+
raise
529+
530+
# A parsing error could come from providing the wrong quotechar
531+
# to pandas. By default, we use a double quote. Thus, we retry
532+
# with a single quote before to raise the error.
533+
arff_params["read_csv_kwargs"] = {"quotechar": "'"}
534+
X, y, frame, categories = _open_url_and_load_gzip_file(
535+
url, data_home, n_retries, delay, arff_params
536+
)
535537

536538
return X, y, frame, categories
537539

0 commit comments

Comments
 (0)
0