MCPcopy Index your code
hub / github.com/python/cpython / fix_uplink

Function fix_uplink

PCbuild/prepare_ssl.py:95–114  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

93 os.system(do_script)
94
95def fix_uplink():
96 # uplink.c tries to find the OPENSSL_Applink function exported from the current
97 # executable. However, we export it from _ssl[_d].pyd instead. So we update the
98 # module name here before building.
99 with open('ms\\uplink.c', 'r', encoding='utf-8') as f1:
100 code = list(f1)
101 os.replace('ms\\uplink.c', 'ms\\uplink.c.orig')
102 already_patched = False
103 with open('ms\\uplink.c', 'w', encoding='utf-8') as f2:
104 for line in code:
105 if not already_patched:
106 if re.search('MODIFIED FOR CPYTHON _ssl MODULE', line):
107 already_patched = True
108 elif re.match(r'^\s+if\s*\(\(h\s*=\s*GetModuleHandle[AW]?\(NULL\)\)\s*==\s*NULL\)', line):
109 f2.write("/* MODIFIED FOR CPYTHON _ssl MODULE */\n")
110 f2.write('if ((h = GetModuleHandleW(L"_ssl.pyd")) == NULL) if ((h = GetModuleHandleW(L"_ssl_d.pyd")) == NULL)\n')
111 already_patched = True
112 f2.write(line)
113 if not already_patched:
114 print("WARN: failed to patch ms\\uplink.c")
115
116def prep(arch):
117 makefile_template = "ms\\ntdll{}.mak"

Callers 1

prepFunction · 0.85

Calls 6

listClass · 0.85
openFunction · 0.50
replaceMethod · 0.45
searchMethod · 0.45
matchMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…