Skip to content

Commit cb597d0

Browse files
authored
Fixed an issue where the upgrade_check API returned an unexpected keyword argument 'cafile' due to changes in the urllib package supporting Python v3.13. #8577
1 parent badc6f3 commit cb597d0

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Diff for: web/pgadmin/misc/__init__.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import time
3030
import json
3131
import os
32+
import sys
33+
import ssl
3234
from urllib.request import urlopen
3335
from pgadmin.settings import get_setting, store_setting
3436

@@ -345,8 +347,16 @@ def upgrade_check():
345347
# Do not wait for more than 5 seconds.
346348
# It stuck on rendering the browser.html, while working in the
347349
# broken network.
348-
if os.path.exists(config.CA_FILE):
349-
response = urlopen(url, data, 5, cafile=config.CA_FILE)
350+
if os.path.exists(config.CA_FILE) and sys.version_info >= (
351+
3, 13):
352+
# Use SSL context for Python 3.13+
353+
context = ssl.create_default_context(cafile=config.CA_FILE)
354+
response = urlopen(url, data=data, timeout=5,
355+
context=context)
356+
elif os.path.exists(config.CA_FILE):
357+
# Use cafile parameter for older versions
358+
response = urlopen(url, data=data, timeout=5,
359+
cafile=config.CA_FILE)
350360
else:
351361
response = urlopen(url, data, 5)
352362
current_app.logger.debug(

0 commit comments

Comments
 (0)