blob: 68a94aa6cc42b8fc66c369b4a6525e53b6bc4436 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
use rustpython::vm::{PyResult, VirtualMachine};
// NOTE(@bpeetz): Remove this, once rust-python supports these features. <2025-06-27>
pub(crate) fn apply_hacks(vm: &VirtualMachine) -> PyResult<()> {
{
// Urllib3 tries to import this value, regardless if it is set.
let ssl_module = vm.import("ssl", 0)?;
ssl_module.set_attr("VERIFY_X509_STRICT", vm.ctx.new_int(0x20), vm)?;
}
{
// Urllib3 tries to set the SSLContext.verify_flags value, regardless if it exists or not.
// So we need to provide a polyfill.
let scope = vm.new_scope_with_builtins();
vm.run_code_string(
scope,
include_str!("urllib3_polyfill.py"),
"<embedded urllib3 polyfill workaround code>".to_owned(),
)?;
}
Ok(())
}
|