Skip to content

Commit a422ff1

Browse files
committed
add ascii
1 parent d69583b commit a422ff1

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

.cspell.dict/python-more.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ PYTHONHASHSEED
178178
PYTHONHOME
179179
PYTHONINSPECT
180180
PYTHONINTMAXSTRDIGITS
181+
PYTHONIOENCODING
181182
PYTHONNODEBUGRANGES
182183
PYTHONNOUSERSITE
183184
PYTHONOPTIMIZE

crates/vm/src/vm/mod.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,17 @@ impl VirtualMachine {
261261
Ok(())
262262
}
263263

264-
fn import_utf8_encodings(&mut self) -> PyResult<()> {
264+
fn import_ascii_utf8_encodings(&mut self) -> PyResult<()> {
265265
import::import_frozen(self, "codecs")?;
266+
267+
// Also register ascii encoding
268+
let ascii_module = import::import_frozen(self, "encodings_ascii")?;
269+
let getregentry = ascii_module.get_attr("getregentry", self)?;
270+
let codec_info = getregentry.call((), self)?;
271+
self.state
272+
.codec_registry
273+
.register_manual("ascii", codec_info.try_into_value(self)?)?;
274+
266275
// FIXME: See corresponding part of `core_frozen_inits`
267276
// let encoding_module_name = if cfg!(feature = "freeze-stdlib") {
268277
// "encodings.utf_8"
@@ -298,7 +307,7 @@ impl VirtualMachine {
298307
#[cfg(not(feature = "threading"))]
299308
import::import_frozen(self, "_thread")?;
300309
let importlib = import::init_importlib_base(self)?;
301-
self.import_utf8_encodings()?;
310+
self.import_ascii_utf8_encodings()?;
302311

303312
#[cfg(any(not(target_arch = "wasm32"), target_os = "wasi"))]
304313
{

0 commit comments

Comments
 (0)