Skip to content

Commit 68a59cc

Browse files
committed
Optimized the code to not use the urlopen_with_ssl function
1 parent 06e5960 commit 68a59cc

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

web/pgadmin/misc/__init__.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,16 @@ def upgrade_check():
357357
# Do not wait for more than 5 seconds.
358358
# It stuck on rendering the browser.html, while working in the
359359
# broken network.
360-
if os.path.exists(config.CA_FILE):
361-
response = urlopen_with_ssl(
362-
url, data, 5, config.CA_FILE)
360+
if os.path.exists(config.CA_FILE) and sys.version_info >= (
361+
3, 13):
362+
# Use SSL context for Python 3.13+
363+
context = ssl.create_default_context(cafile=config.CA_FILE)
364+
response = urlopen(url, data=data, timeout=5,
365+
context=context)
366+
elif os.path.exists(config.CA_FILE):
367+
# Use cafile parameter for older versions
368+
response = urlopen(url, data=data, timeout=5,
369+
cafile=config.CA_FILE)
363370
else:
364371
response = urlopen(url, data, 5)
365372
current_app.logger.debug(

0 commit comments

Comments
 (0)