diff --git a/compiler/erg_common/config.rs b/compiler/erg_common/config.rs index f1d9d483..0a273cb9 100644 --- a/compiler/erg_common/config.rs +++ b/compiler/erg_common/config.rs @@ -295,15 +295,23 @@ impl ErgConfig { .expect("the value of `-py-command` is not a valid Python command"); cfg.py_command = Some(Box::leak(py_command.into_boxed_str())); } - "--py-magic-num" | "--python-magic-number" => { + "--hex-py-magic-num" | "--hex-python-magic-number" => { let s_hex_magic_num = args .next() - .expect("the value of `--py-magic-num` is not passed"); + .expect("the value of `--hex-py-magic-num` is not passed"); let first_byte = u8::from_str_radix(&s_hex_magic_num[0..=1], 16).unwrap(); let second_byte = u8::from_str_radix(&s_hex_magic_num[2..=3], 16).unwrap(); let py_magic_num = get_magic_num_from_bytes(&[first_byte, second_byte, 0, 0]); cfg.py_magic_num = Some(py_magic_num); } + "--py-magic-num" | "--python-magic-number" => { + cfg.py_magic_num = Some( + args.next() + .expect("the value of `--py-magic-num` is not passed") + .parse::() + .expect("the value of `--py-magic-num` is not a number"), + ); + } "--py-server-timeout" => { cfg.py_server_timeout = args .next() diff --git a/tests/test.rs b/tests/test.rs index e786c252..32a6e755 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -196,6 +196,7 @@ fn _exec_vm(file_path: &'static str) -> Result { let mut cfg = ErgConfig::with_main_path(PathBuf::from(file_path)); cfg.py_command = Some("python"); cfg.target_version = Some(PythonVersion::new(3, Some(10), Some(8))); + cfg.py_magic_num = Some(3439); let mut vm = DummyVM::new(cfg); vm.exec() }