mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 09:50:15 +01:00
py/persistentcode: Remove unicode feature flag from .mpy file.
Prior to this commit, even with unicode disabled .py and .mpy files could contain unicode characters, eg by entering them directly in a string as utf-8 encoded. The only thing the compiler disallowed (with unicode disabled) was using \uxxxx and \Uxxxxxxxx notation to specify a character within a string with value >= 0x100; that would give a SyntaxError. With this change mpy-cross will now accept \u and \U notation to insert a character with value >= 0x100 into a string (because the -mno-unicode option is now gone, there's no way to forbid this). The runtime will happily work with strings with such characters, just like it already works with strings with characters that were utf-8 encoded directly. This change simplifies things because there are no longer any feature flags in .mpy files, and any bytecode .mpy will now run on any target. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -108,7 +108,6 @@ STATIC int usage(char **argv) {
|
||||
"\n"
|
||||
"Target specific options:\n"
|
||||
"-msmall-int-bits=number : set the maximum bits used to encode a small-int\n"
|
||||
"-mno-unicode : don't support unicode in compiled strings\n"
|
||||
"-march=<arch> : set architecture for native emitter; x86, x64, armv6, armv7m, armv7em, armv7emsp, armv7emdp, xtensa, xtensawin\n"
|
||||
"\n"
|
||||
"Implementation specific options:\n", argv[0]
|
||||
@@ -203,7 +202,6 @@ MP_NOINLINE int main_(int argc, char **argv) {
|
||||
|
||||
// set default compiler configuration
|
||||
mp_dynamic_compiler.small_int_bits = 31;
|
||||
mp_dynamic_compiler.py_builtins_str_unicode = 1;
|
||||
#if defined(__i386__)
|
||||
mp_dynamic_compiler.native_arch = MP_NATIVE_ARCH_X86;
|
||||
mp_dynamic_compiler.nlr_buf_num_regs = MICROPY_NLR_NUM_REGS_X86;
|
||||
@@ -261,10 +259,6 @@ MP_NOINLINE int main_(int argc, char **argv) {
|
||||
return usage(argv);
|
||||
}
|
||||
// TODO check that small_int_bits is within range of host's capabilities
|
||||
} else if (strcmp(argv[a], "-mno-unicode") == 0) {
|
||||
mp_dynamic_compiler.py_builtins_str_unicode = 0;
|
||||
} else if (strcmp(argv[a], "-municode") == 0) {
|
||||
mp_dynamic_compiler.py_builtins_str_unicode = 1;
|
||||
} else if (strncmp(argv[a], "-march=", sizeof("-march=") - 1) == 0) {
|
||||
const char *arch = argv[a] + sizeof("-march=") - 1;
|
||||
if (strcmp(arch, "x86") == 0) {
|
||||
|
||||
Reference in New Issue
Block a user