Skip to content

Commit f204f2b

Browse files
authored
Merge pull request #1 from Tanmaykaturi/fix/semgrep-dynamic-urllib-use-detected-458-KAphqxWbd0
fix: semgrep-dynamic-urllib-use-detected
2 parents 8106aea + b3f0bb7 commit f204f2b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

machine_learning/sequential_minimum_optimization.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
import os
3232
import sys
33-
import urllib.request
33+
import requests
3434

3535
import numpy as np
3636
import pandas as pd
@@ -451,12 +451,12 @@ def test_cancer_data():
451451
print("Hello!\nStart test SVM using the SMO algorithm!")
452452
# 0: download dataset and load into pandas' dataframe
453453
if not os.path.exists(r"cancer_data.csv"):
454-
request = urllib.request.Request( # noqa: S310
454+
response = requests.get(
455455
CANCER_DATASET_URL,
456456
headers={"User-Agent": "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)"},
457457
)
458-
response = urllib.request.urlopen(request) # noqa: S310
459-
content = response.read().decode("utf-8")
458+
response.raise_for_status() # Raise an exception for bad status codes
459+
content = response.text
460460
with open(r"cancer_data.csv", "w") as f:
461461
f.write(content)
462462

0 commit comments

Comments
 (0)