refactor(core): switch to slots-based mp_obj_type_t
What changed, and why it matters
This commit is a routine internal cleanup that switches how Trezor's firmware defines built-in MicroPython object types. It replaces older, manually-written type structures with a newer macro provided by the upstream MicroPython project. There is no user-visible change, no bug fix, and no security patch in the diff.
No action required. Treat as a normal dependency/refactoring commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors all native C module type definitions in core/embed/upymod to use MicroPython’s newer MP_DEFINE_CONST_OBJ_TYPE macro, which encodes type slots by index rather than the older sparse struct representation. The change is purely mechanical: each mp_obj_type_t initializer is rewritten to the macro form, preserving the same name, flags, make_new, locals_dict, and iterator callbacks. No logic, bounds checks, or behavior changes are introduced.
Changed components
core/embed/upymod/modtrezorappcore/embed/upymod/modtrezorcryptocore/embed/upymod/modtrezoriocore/embed/upymod/modtrezoruiInspect captured patch +163 / −166
diff --git a/core/embed/upymod/modtrezorapp/modtrezorapp-image.h b/core/embed/upymod/modtrezorapp/modtrezorapp-image.h
index ffa3819e..5ab97c6e 100644
--- a/core/embed/upymod/modtrezorapp/modtrezorapp-image.h
+++ b/core/embed/upymod/modtrezorapp/modtrezorapp-image.h
@@ -93,8 +93,8 @@ STATIC const mp_rom_map_elem_t mod_trezorapp_AppImage_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(mod_trezorapp_AppImage_locals_dict,
mod_trezorapp_AppImage_locals_dict_table);
-STATIC const mp_obj_type_t mod_trezorapp_AppImage_type = {
- {&mp_type_type},
- .name = MP_QSTR_AppImage,
- .locals_dict = (void *)&mod_trezorapp_AppImage_locals_dict,
-};
+// clang-format off
+static MP_DEFINE_CONST_OBJ_TYPE(mod_trezorapp_AppImage_type,
+ MP_QSTR_AppImage, MP_TYPE_FLAG_NONE,
+ locals_dict, &mod_trezorapp_AppImage_locals_dict);
+// clang-format on
diff --git a/core/embed/upymod/modtrezorapp/modtrezorapp-task.h b/core/embed/upymod/modtrezorapp/modtrezorapp-task.h
index ddfd4179..b3a77cbe 100644
--- a/core/embed/upymod/modtrezorapp/modtrezorapp-task.h
+++ b/core/embed/upymod/modtrezorapp/modtrezorapp-task.h
@@ -84,8 +84,8 @@ STATIC const mp_rom_map_elem_t mod_trezorapp_AppTask_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(mod_trezorapp_AppTask_locals_dict,
mod_trezorapp_AppTask_locals_dict_table);
-STATIC const mp_obj_type_t mod_trezorapp_AppTask_type = {
- {&mp_type_type},
- .name = MP_QSTR_AppTask,
- .locals_dict = (void *)&mod_trezorapp_AppTask_locals_dict,
-};
+// clang-format off
+static MP_DEFINE_CONST_OBJ_TYPE(mod_trezorapp_AppTask_type,
+ MP_QSTR_AppTask, MP_TYPE_FLAG_NONE,
+ locals_dict, &mod_trezorapp_AppTask_locals_dict);
+// clang-format on
diff --git a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-aes.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-aes.h
index ffc184cd..425dfa3d 100644
--- a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-aes.h
+++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-aes.h
@@ -206,9 +206,9 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_AES_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_AES_locals_dict,
mod_trezorcrypto_AES_locals_dict_table);
-STATIC const mp_obj_type_t mod_trezorcrypto_AES_type = {
- {&mp_type_type},
- .name = MP_QSTR_AES,
- .make_new = mod_trezorcrypto_AES_make_new,
- .locals_dict = (void *)&mod_trezorcrypto_AES_locals_dict,
-};
+// clang-format off
+static MP_DEFINE_CONST_OBJ_TYPE(mod_trezorcrypto_AES_type,
+ MP_QSTR_AES, MP_TYPE_FLAG_NONE,
+ make_new, mod_trezorcrypto_AES_make_new,
+ locals_dict, &mod_trezorcrypto_AES_locals_dict);
+// clang-format on
diff --git a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-aesgcm.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-aesgcm.h
index f6bcc78d..4d4e62fe 100644
--- a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-aesgcm.h
+++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-aesgcm.h
@@ -329,16 +329,16 @@ STATIC const mp_rom_map_elem_t
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_AesGcmDecrypt_locals_dict,
mod_trezorcrypto_AesGcmDecrypt_locals_dict_table);
-STATIC const mp_obj_type_t mod_trezorcrypto_AesGcmEncrypt_type = {
- {&mp_type_type},
- .name = MP_QSTR_aesgcm_encrypt,
- .make_new = mod_trezorcrypto_AesGcm_make_new,
- .locals_dict = (void *)&mod_trezorcrypto_AesGcmEncrypt_locals_dict,
-};
+// clang-format off
+static MP_DEFINE_CONST_OBJ_TYPE(mod_trezorcrypto_AesGcmEncrypt_type,
+ MP_QSTR_aesgcm_encrypt, MP_TYPE_FLAG_NONE,
+ make_new, mod_trezorcrypto_AesGcm_make_new,
+ locals_dict, &mod_trezorcrypto_AesGcmEncrypt_locals_dict);
+// clang-format on
-STATIC const mp_obj_type_t mod_trezorcrypto_AesGcmDecrypt_type = {
- {&mp_type_type},
- .name = MP_QSTR_aesgcm_decrypt,
- .make_new = mod_trezorcrypto_AesGcm_make_new,
- .locals_dict = (void *)&mod_trezorcrypto_AesGcmDecrypt_locals_dict,
-};
+// clang-format off
+static MP_DEFINE_CONST_OBJ_TYPE(mod_trezorcrypto_AesGcmDecrypt_type,
+ MP_QSTR_aesgcm_decrypt, MP_TYPE_FLAG_NONE,
+ make_new, mod_trezorcrypto_AesGcm_make_new,
+ locals_dict, &mod_trezorcrypto_AesGcmDecrypt_locals_dict);
+// clang-format on
diff --git a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-bip32.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-bip32.h
index 2d8f5747..e480ab27 100644
--- a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-bip32.h
+++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-bip32.h
@@ -508,12 +508,12 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_HDNode_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_HDNode_locals_dict,
mod_trezorcrypto_HDNode_locals_dict_table);
-const mp_obj_type_t mod_trezorcrypto_HDNode_type = {
- {&mp_type_type},
- .name = MP_QSTR_HDNode,
- .make_new = mod_trezorcrypto_HDNode_make_new,
- .locals_dict = (void *)&mod_trezorcrypto_HDNode_locals_dict,
-};
+// clang-format off
+MP_DEFINE_CONST_OBJ_TYPE(mod_trezorcrypto_HDNode_type,
+ MP_QSTR_HDNode, MP_TYPE_FLAG_NONE,
+ make_new, mod_trezorcrypto_HDNode_make_new,
+ locals_dict, &mod_trezorcrypto_HDNode_locals_dict);
+// clang-format on
/// mock:global
diff --git a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-blake256.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-blake256.h
index aaf981df..16336be1 100644
--- a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-blake256.h
+++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-blake256.h
@@ -108,9 +108,9 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_Blake256_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_Blake256_locals_dict,
mod_trezorcrypto_Blake256_locals_dict_table);
-STATIC const mp_obj_type_t mod_trezorcrypto_Blake256_type = {
- {&mp_type_type},
- .name = MP_QSTR_Blake256,
- .make_new = mod_trezorcrypto_Blake256_make_new,
- .locals_dict = (void *)&mod_trezorcrypto_Blake256_locals_dict,
-};
+// clang-format off
+static MP_DEFINE_CONST_OBJ_TYPE(mod_trezorcrypto_Blake256_type,
+ MP_QSTR_Blake256, MP_TYPE_FLAG_NONE,
+ make_new, mod_trezorcrypto_Blake256_make_new,
+ locals_dict, &mod_trezorcrypto_Blake256_locals_dict);
+// clang-format on
diff --git a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-blake2b.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-blake2b.h
index dc3f988e..540c929d 100644
--- a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-blake2b.h
+++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-blake2b.h
@@ -162,9 +162,9 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_Blake2b_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_Blake2b_locals_dict,
mod_trezorcrypto_Blake2b_locals_dict_table);
-STATIC const mp_obj_type_t mod_trezorcrypto_Blake2b_type = {
- {&mp_type_type},
- .name = MP_QSTR_Blake2b,
- .make_new = mod_trezorcrypto_Blake2b_make_new,
- .locals_dict = (void *)&mod_trezorcrypto_Blake2b_locals_dict,
-};
+// clang-format off
+static MP_DEFINE_CONST_OBJ_TYPE(mod_trezorcrypto_Blake2b_type,
+ MP_QSTR_Blake2b, MP_TYPE_FLAG_NONE,
+ make_new, mod_trezorcrypto_Blake2b_make_new,
+ locals_dict, &mod_trezorcrypto_Blake2b_locals_dict);
+// clang-format on
diff --git a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-blake2s.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-blake2s.h
index 55272706..b674f0ae 100644
--- a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-blake2s.h
+++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-blake2s.h
@@ -162,9 +162,9 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_Blake2s_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_Blake2s_locals_dict,
mod_trezorcrypto_Blake2s_locals_dict_table);
-STATIC const mp_obj_type_t mod_trezorcrypto_Blake2s_type = {
- {&mp_type_type},
- .name = MP_QSTR_Blake2s,
- .make_new = mod_trezorcrypto_Blake2s_make_new,
- .locals_dict = (void *)&mod_trezorcrypto_Blake2s_locals_dict,
-};
+// clang-format off
+static MP_DEFINE_CONST_OBJ_TYPE(mod_trezorcrypto_Blake2s_type,
+ MP_QSTR_Blake2s, MP_TYPE_FLAG_NONE,
+ make_new, mod_trezorcrypto_Blake2s_make_new,
+ locals_dict, &mod_trezorcrypto_Blake2s_locals_dict);
+// clang-format on
diff --git a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-chacha20poly1305.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-chacha20poly1305.h
index 1721dd45..09a22187 100644
--- a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-chacha20poly1305.h
+++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-chacha20poly1305.h
@@ -249,18 +249,16 @@ STATIC MP_DEFINE_CONST_DICT(
mod_trezorcrypto_ChaCha20Poly1305Decrypt_locals_dict,
mod_trezorcrypto_ChaCha20Poly1305Decrypt_locals_dict_table);
-STATIC const mp_obj_type_t mod_trezorcrypto_ChaCha20Poly1305Encrypt_type = {
- {&mp_type_type},
- .name = MP_QSTR_chacha20poly1305_encrypt,
- .make_new = mod_trezorcrypto_ChaCha20Poly1305_make_new,
- .locals_dict =
- (void *)&mod_trezorcrypto_ChaCha20Poly1305Encrypt_locals_dict,
-};
+// clang-format off
+static MP_DEFINE_CONST_OBJ_TYPE(mod_trezorcrypto_ChaCha20Poly1305Encrypt_type,
+ MP_QSTR_chacha20poly1305_encrypt, MP_TYPE_FLAG_NONE,
+ make_new, mod_trezorcrypto_ChaCha20Poly1305_make_new,
+ locals_dict, &mod_trezorcrypto_ChaCha20Poly1305Encrypt_locals_dict);
+// clang-format on
-STATIC const mp_obj_type_t mod_trezorcrypto_ChaCha20Poly1305Decrypt_type = {
- {&mp_type_type},
- .name = MP_QSTR_chacha20poly1305_decrypt,
- .make_new = mod_trezorcrypto_ChaCha20Poly1305_make_new,
- .locals_dict =
- (void *)&mod_trezorcrypto_ChaCha20Poly1305Decrypt_locals_dict,
-};
+// clang-format off
+static MP_DEFINE_CONST_OBJ_TYPE(mod_trezorcrypto_ChaCha20Poly1305Decrypt_type,
+ MP_QSTR_chacha20poly1305_decrypt, MP_TYPE_FLAG_NONE,
+ make_new, mod_trezorcrypto_ChaCha20Poly1305_make_new,
+ locals_dict, &mod_trezorcrypto_ChaCha20Poly1305Decrypt_locals_dict);
+// clang-format on
diff --git a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-groestl.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-groestl.h
index e54b722e..159d970f 100644
--- a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-groestl.h
+++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-groestl.h
@@ -115,9 +115,9 @@ STATIC const mp_rom_map_elem_t
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_Groestl512_locals_dict,
mod_trezorcrypto_Groestl512_locals_dict_table);
-STATIC const mp_obj_type_t mod_trezorcrypto_Groestl512_type = {
- {&mp_type_type},
- .name = MP_QSTR_Groestl512,
- .make_new = mod_trezorcrypto_Groestl512_make_new,
- .locals_dict = (void *)&mod_trezorcrypto_Groestl512_locals_dict,
-};
+// clang-format off
+static MP_DEFINE_CONST_OBJ_TYPE(mod_trezorcrypto_Groestl512_type,
+ MP_QSTR_Groestl512, MP_TYPE_FLAG_NONE,
+ make_new, mod_trezorcrypto_Groestl512_make_new,
+ locals_dict, &mod_trezorcrypto_Groestl512_locals_dict);
+// clang-format on
diff --git a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-hmac.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-hmac.h
index a230f02e..286b50a1 100644
--- a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-hmac.h
+++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-hmac.h
@@ -151,9 +151,9 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_Hmac_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_Hmac_locals_dict,
mod_trezorcrypto_Hmac_locals_dict_table);
-STATIC const mp_obj_type_t mod_trezorcrypto_Hmac_type = {
- {&mp_type_type},
- .name = MP_QSTR_Hmac,
- .make_new = mod_trezorcrypto_Hmac_make_new,
- .locals_dict = (void *)&mod_trezorcrypto_Hmac_locals_dict,
-};
+// clang-format off
+static MP_DEFINE_CONST_OBJ_TYPE(mod_trezorcrypto_Hmac_type,
+ MP_QSTR_Hmac, MP_TYPE_FLAG_NONE,
+ make_new, mod_trezorcrypto_Hmac_make_new,
+ locals_dict, &mod_trezorcrypto_Hmac_locals_dict);
+// clang-format on
diff --git a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-monero.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-monero.h
index b48fc97a..bc168864 100644
--- a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-monero.h
+++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-monero.h
@@ -1089,12 +1089,12 @@ STATIC const mp_rom_map_elem_t
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_monero_ge25519_locals_dict,
mod_trezorcrypto_monero_ge25519_locals_dict_table);
-STATIC const mp_obj_type_t mod_trezorcrypto_monero_ge25519_type = {
- {&mp_type_type},
- .name = MP_QSTR_Point,
- .make_new = mod_trezorcrypto_monero_ge25519_make_new,
- .locals_dict = (void *)&mod_trezorcrypto_monero_ge25519_locals_dict,
-};
+// clang-format off
+MP_DEFINE_CONST_OBJ_TYPE(mod_trezorcrypto_monero_ge25519_type,
+ MP_QSTR_Point, MP_TYPE_FLAG_NONE,
+ make_new, mod_trezorcrypto_monero_ge25519_make_new,
+ locals_dict, &mod_trezorcrypto_monero_ge25519_locals_dict);
+// clang-format on
STATIC const mp_rom_map_elem_t
mod_trezorcrypto_monero_bignum256modm_locals_dict_table[] = {
@@ -1105,12 +1105,12 @@ STATIC MP_DEFINE_CONST_DICT(
mod_trezorcrypto_monero_bignum256modm_locals_dict,
mod_trezorcrypto_monero_bignum256modm_locals_dict_table);
-STATIC const mp_obj_type_t mod_trezorcrypto_monero_bignum256modm_type = {
- {&mp_type_type},
- .name = MP_QSTR_Scalar,
- .make_new = mod_trezorcrypto_monero_bignum256modm_make_new,
- .locals_dict = (void *)&mod_trezorcrypto_monero_bignum256modm_locals_dict,
-};
+// clang-format off
+MP_DEFINE_CONST_OBJ_TYPE(mod_trezorcrypto_monero_bignum256modm_type,
+ MP_QSTR_Scalar, MP_TYPE_FLAG_NONE,
+ make_new, mod_trezorcrypto_monero_bignum256modm_make_new,
+ locals_dict, &mod_trezorcrypto_monero_bignum256modm_locals_dict);
+// clang-format on
/// BP_GI_PLUS_PRE: bytes
STATIC const mp_obj_str_t mod_trezorcrypto_monero_BP_PLUS_GI_PRE_obj = {{&mp_type_bytes}, 0, 8192, (const byte*)""
diff --git a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-pbkdf2.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-pbkdf2.h
index fe386beb..66edc5e2 100644
--- a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-pbkdf2.h
+++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-pbkdf2.h
@@ -166,9 +166,9 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_Pbkdf2_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_Pbkdf2_locals_dict,
mod_trezorcrypto_Pbkdf2_locals_dict_table);
-STATIC const mp_obj_type_t mod_trezorcrypto_Pbkdf2_type = {
- {&mp_type_type},
- .name = MP_QSTR_Pbkdf2,
- .make_new = mod_trezorcrypto_Pbkdf2_make_new,
- .locals_dict = (void *)&mod_trezorcrypto_Pbkdf2_locals_dict,
-};
+// clang-format off
+static MP_DEFINE_CONST_OBJ_TYPE(mod_trezorcrypto_Pbkdf2_type,
+ MP_QSTR_Pbkdf2, MP_TYPE_FLAG_NONE,
+ make_new, mod_trezorcrypto_Pbkdf2_make_new,
+ locals_dict, &mod_trezorcrypto_Pbkdf2_locals_dict);
+// clang-format on
diff --git a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-ripemd160.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-ripemd160.h
index 8136129f..57d8d030 100644
--- a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-ripemd160.h
+++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-ripemd160.h
@@ -111,9 +111,9 @@ STATIC const mp_rom_map_elem_t
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_Ripemd160_locals_dict,
mod_trezorcrypto_Ripemd160_locals_dict_table);
-STATIC const mp_obj_type_t mod_trezorcrypto_Ripemd160_type = {
- {&mp_type_type},
- .name = MP_QSTR_Ripemd160,
- .make_new = mod_trezorcrypto_Ripemd160_make_new,
- .locals_dict = (void *)&mod_trezorcrypto_Ripemd160_locals_dict,
-};
+// clang-format off
+static MP_DEFINE_CONST_OBJ_TYPE(mod_trezorcrypto_Ripemd160_type,
+ MP_QSTR_Ripemd160, MP_TYPE_FLAG_NONE,
+ make_new, mod_trezorcrypto_Ripemd160_make_new,
+ locals_dict, &mod_trezorcrypto_Ripemd160_locals_dict);
+// clang-format on
diff --git a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha1.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha1.h
index d52bc8eb..017586aa 100644
--- a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha1.h
+++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha1.h
@@ -108,9 +108,9 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_Sha1_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_Sha1_locals_dict,
mod_trezorcrypto_Sha1_locals_dict_table);
-STATIC const mp_obj_type_t mod_trezorcrypto_Sha1_type = {
- {&mp_type_type},
- .name = MP_QSTR_Sha1,
- .make_new = mod_trezorcrypto_Sha1_make_new,
- .locals_dict = (void *)&mod_trezorcrypto_Sha1_locals_dict,
-};
+// clang-format off
+static MP_DEFINE_CONST_OBJ_TYPE(mod_trezorcrypto_Sha1_type,
+ MP_QSTR_Sha1, MP_TYPE_FLAG_NONE,
+ make_new, mod_trezorcrypto_Sha1_make_new,
+ locals_dict, &mod_trezorcrypto_Sha1_locals_dict);
+// clang-format on
diff --git a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha256.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha256.h
index c4b5382f..5bbdf5ca 100644
--- a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha256.h
+++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha256.h
@@ -108,9 +108,9 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_Sha256_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_Sha256_locals_dict,
mod_trezorcrypto_Sha256_locals_dict_table);
-STATIC const mp_obj_type_t mod_trezorcrypto_Sha256_type = {
- {&mp_type_type},
- .name = MP_QSTR_Sha256,
- .make_new = mod_trezorcrypto_Sha256_make_new,
- .locals_dict = (void *)&mod_trezorcrypto_Sha256_locals_dict,
-};
+// clang-format off
+static MP_DEFINE_CONST_OBJ_TYPE(mod_trezorcrypto_Sha256_type,
+ MP_QSTR_Sha256, MP_TYPE_FLAG_NONE,
+ make_new, mod_trezorcrypto_Sha256_make_new,
+ locals_dict, &mod_trezorcrypto_Sha256_locals_dict);
+// clang-format on
diff --git a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha3-256.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha3-256.h
index 63b09a04..08b21fcc 100644
--- a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha3-256.h
+++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha3-256.h
@@ -148,9 +148,9 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_Sha3_256_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_Sha3_256_locals_dict,
mod_trezorcrypto_Sha3_256_locals_dict_table);
-STATIC const mp_obj_type_t mod_trezorcrypto_Sha3_256_type = {
- {&mp_type_type},
- .name = MP_QSTR_Sha3_256,
- .make_new = mod_trezorcrypto_Sha3_256_make_new,
- .locals_dict = (void *)&mod_trezorcrypto_Sha3_256_locals_dict,
-};
+// clang-format off
+static MP_DEFINE_CONST_OBJ_TYPE(mod_trezorcrypto_Sha3_256_type,
+ MP_QSTR_Sha3_256, MP_TYPE_FLAG_NONE,
+ make_new, mod_trezorcrypto_Sha3_256_make_new,
+ locals_dict, &mod_trezorcrypto_Sha3_256_locals_dict);
+// clang-format on
diff --git a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha3-512.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha3-512.h
index 27438a56..f07c282e 100644
--- a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha3-512.h
+++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha3-512.h
@@ -148,9 +148,9 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_Sha3_512_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_Sha3_512_locals_dict,
mod_trezorcrypto_Sha3_512_locals_dict_table);
-STATIC const mp_obj_type_t mod_trezorcrypto_Sha3_512_type = {
- {&mp_type_type},
- .name = MP_QSTR_Sha3_512,
- .make_new = mod_trezorcrypto_Sha3_512_make_new,
- .locals_dict = (void *)&mod_trezorcrypto_Sha3_512_locals_dict,
-};
+// clang-format off
+static MP_DEFINE_CONST_OBJ_TYPE(mod_trezorcrypto_Sha3_512_type,
+ MP_QSTR_Sha3_512, MP_TYPE_FLAG_NONE,
+ make_new, mod_trezorcrypto_Sha3_512_make_new,
+ locals_dict, &mod_trezorcrypto_Sha3_512_locals_dict);
+// clang-format on
diff --git a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha512.h b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha512.h
index b17d3c10..b904ff05 100644
--- a/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha512.h
+++ b/core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha512.h
@@ -107,9 +107,9 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_Sha512_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_Sha512_locals_dict,
mod_trezorcrypto_Sha512_locals_dict_table);
-STATIC const mp_obj_type_t mod_trezorcrypto_Sha512_type = {
- {&mp_type_type},
- .name = MP_QSTR_Sha512,
- .make_new = mod_trezorcrypto_Sha512_make_new,
- .locals_dict = (void *)&mod_trezorcrypto_Sha512_locals_dict,
-};
+// clang-format off
+static MP_DEFINE_CONST_OBJ_TYPE(mod_trezorcrypto_Sha512_type,
+ MP_QSTR_Sha512, MP_TYPE_FLAG_NONE,
+ make_new, mod_trezorcrypto_Sha512_make_new,
+ locals_dict, &mod_trezorcrypto_Sha512_locals_dict);
+// clang-format on
diff --git a/core/embed/upymod/modtrezorio/modtrezorio-fatfs.h b/core/embed/upymod/modtrezorio/modtrezorio-fatfs.h
index a75b8e2d..6c8acc17 100644
--- a/core/embed/upymod/modtrezorio/modtrezorio-fatfs.h
+++ b/core/embed/upymod/modtrezorio/modtrezorio-fatfs.h
@@ -305,11 +305,11 @@ STATIC const mp_rom_map_elem_t mod_trezorio_FatFSFile_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(mod_trezorio_FatFSFile_locals_dict,
mod_trezorio_FatFSFile_locals_dict_table);
-STATIC const mp_obj_type_t mod_trezorio_FatFSFile_type = {
- {&mp_type_type},
- .name = MP_QSTR_FatFSFile,
- .locals_dict = (void *)&mod_trezorio_FatFSFile_locals_dict,
-};
+// clang-format off
+static MP_DEFINE_CONST_OBJ_TYPE(mod_trezorio_FatFSFile_type,
+ MP_QSTR_FatFSFile, MP_TYPE_FLAG_NONE,
+ locals_dict, &mod_trezorio_FatFSFile_locals_dict);
+// clang-format on
/// class FatFSDir(Iterator[tuple[int, str, str]]):
/// """
@@ -341,12 +341,11 @@ STATIC mp_obj_t mod_trezorio_FatFSDir_iternext(mp_obj_t self) {
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_trezorio_FatFSDir_iternext_obj,
mod_trezorio_FatFSDir_iternext);
-STATIC const mp_obj_type_t mod_trezorio_FatFSDir_type = {
- {&mp_type_type},
- .name = MP_QSTR_FatFSDir,
- .getiter = mp_identity_getiter,
- .iternext = mod_trezorio_FatFSDir_iternext,
-};
+// clang-format off
+static MP_DEFINE_CONST_OBJ_TYPE(mod_trezorio_FatFSDir_type,
+ MP_QSTR_FatFSDir, MP_TYPE_FLAG_ITER_IS_ITERNEXT,
+ iter, mod_trezorio_FatFSDir_iternext);
+// clang-format on
/// mock:global
diff --git a/core/embed/upymod/modtrezorio/modtrezorio-ipc.h b/core/embed/upymod/modtrezorio/modtrezorio-ipc.h
index 9a44ec6a..80167326 100644
--- a/core/embed/upymod/modtrezorio/modtrezorio-ipc.h
+++ b/core/embed/upymod/modtrezorio/modtrezorio-ipc.h
@@ -112,8 +112,8 @@ STATIC const mp_rom_map_elem_t mod_trezorio_IpcMessage_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(mod_trezorio_IpcMessage_locals_dict,
mod_trezorio_IpcMessage_locals_dict_table);
-STATIC const mp_obj_type_t mod_trezorio_IpcMessage_type = {
- {&mp_type_type},
- .name = MP_QSTR_IpcMessage,
- .locals_dict = (void *)&mod_trezorio_IpcMessage_locals_dict,
-};
+// clang-format off
+static MP_DEFINE_CONST_OBJ_TYPE(mod_trezorio_IpcMessage_type,
+ MP_QSTR_IpcMessage, MP_TYPE_FLAG_NONE,
+ locals_dict, &mod_trezorio_IpcMessage_locals_dict);
+// clang-format on
diff --git a/core/embed/upymod/modtrezorio/modtrezorio-usb-if.h b/core/embed/upymod/modtrezorio/modtrezorio-usb-if.h
index f4ed0631..eaa7e32c 100644
--- a/core/embed/upymod/modtrezorio/modtrezorio-usb-if.h
+++ b/core/embed/upymod/modtrezorio/modtrezorio-usb-if.h
@@ -177,9 +177,9 @@ STATIC const mp_rom_map_elem_t mod_trezorio_USBIF_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(mod_trezorio_USBIF_locals_dict,
mod_trezorio_USBIF_locals_dict_table);
-STATIC const mp_obj_type_t mod_trezorio_USBIF_type = {
- {&mp_type_type},
- .name = MP_QSTR_USBIF,
- .make_new = mod_trezorio_USBIF_make_new,
- .locals_dict = (void *)&mod_trezorio_USBIF_locals_dict,
-};
+// clang-format off
+MP_DEFINE_CONST_OBJ_TYPE(mod_trezorio_USBIF_type,
+ MP_QSTR_USBIF, MP_TYPE_FLAG_NONE,
+ make_new, mod_trezorio_USBIF_make_new,
+ locals_dict, &mod_trezorio_USBIF_locals_dict);
+// clang-format on
diff --git a/core/embed/upymod/modtrezorio/modtrezorio-usb.h b/core/embed/upymod/modtrezorio/modtrezorio-usb.h
index 48a569b5..9dfaa297 100644
--- a/core/embed/upymod/modtrezorio/modtrezorio-usb.h
+++ b/core/embed/upymod/modtrezorio/modtrezorio-usb.h
@@ -109,9 +109,9 @@ STATIC const mp_rom_map_elem_t mod_trezorio_USB_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(mod_trezorio_USB_locals_dict,
mod_trezorio_USB_locals_dict_table);
-STATIC const mp_obj_type_t mod_trezorio_USB_type = {
- {&mp_type_type},
- .name = MP_QSTR_USB,
- .make_new = mod_trezorio_USB_make_new,
- .locals_dict = (void *)&mod_trezorio_USB_locals_dict,
-};
+// clang-format off
+MP_DEFINE_CONST_OBJ_TYPE(mod_trezorio_USB_type,
+ MP_QSTR_USB, MP_TYPE_FLAG_NONE,
+ make_new, mod_trezorio_USB_make_new,
+ locals_dict, &mod_trezorio_USB_locals_dict);
+// clang-format on
diff --git a/core/embed/upymod/modtrezorui/modtrezorui-display.h b/core/embed/upymod/modtrezorui/modtrezorui-display.h
index 3b5b437c..61b38ae5 100644
--- a/core/embed/upymod/modtrezorui/modtrezorui-display.h
+++ b/core/embed/upymod/modtrezorui/modtrezorui-display.h
@@ -116,9 +116,9 @@ STATIC const mp_rom_map_elem_t mod_trezorui_Display_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(mod_trezorui_Display_locals_dict,
mod_trezorui_Display_locals_dict_table);
-STATIC const mp_obj_type_t mod_trezorui_Display_type = {
- {&mp_type_type},
- .name = MP_QSTR_Display,
- .make_new = mod_trezorui_Display_make_new,
- .locals_dict = (void *)&mod_trezorui_Display_locals_dict,
-};
+// clang-format off
+MP_DEFINE_CONST_OBJ_TYPE(mod_trezorui_Display_type,
+ MP_QSTR_Display, MP_TYPE_FLAG_NONE,
+ make_new, mod_trezorui_Display_make_new,
+ locals_dict, &mod_trezorui_Display_locals_dict);
+// clang-format on
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.