From 598d7ba1e024d1834378d39990316a509400366a Mon Sep 17 00:00:00 2001 From: sajid-01 <60623690+sajid-01@users.noreply.github.com> Date: Mon, 27 Oct 2025 15:54:47 +0530 Subject: [PATCH] Add missing SSL context argument in retrieve_all() to fix Mac certificate error In the current page, the code only declares the context variable using context = ssl._create_unverified_context() but it never shows that this variable needs to be passed as the second argument to urllib.request.urlopen(). Without adding the context to the function call, the error urllib.error.URLError: still appears on some macOS setups. This change adds the missing part by including the context parameter in the request call: request = urllib.request.urlopen(address, context=my_context) and also defines the address variable for clarity. This ensures the function actually works as intended and resolves the SSL certificate error on macOS. --- data/part-7/4-data-processing.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/data/part-7/4-data-processing.md b/data/part-7/4-data-processing.md index 81c710723..bc1b76806 100644 --- a/data/part-7/4-data-processing.md +++ b/data/part-7/4-data-processing.md @@ -240,7 +240,10 @@ import ssl # add this library to your import section def retrieve_all(): # add the following line to the beginning of all your functions - context = ssl._create_unverified_context() + my_context = ssl._create_unverified_context() + address = "https://studies.cs.helsinki.fi/stats-mock/api/courses" + # add a second argument to the function call + request = urllib.request.urlopen(address, context = my_context) # the rest of your function ```