Skip to content

Commit 2eba98f

Browse files
committed
all: Use MP_REGISTER_EXTENSIBLE_MODULE for overrideable built-ins.
Signed-off-by: Jim Mussared <[email protected]>
1 parent 24c02c4 commit 2eba98f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+68
-48
lines changed

extmod/modbinascii.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,6 @@ const mp_obj_module_t mp_module_binascii = {
203203
.globals = (mp_obj_dict_t *)&mp_module_binascii_globals,
204204
};
205205

206-
MP_REGISTER_MODULE(MP_QSTR_binascii, mp_module_binascii);
206+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_binascii, mp_module_binascii);
207207

208208
#endif // MICROPY_PY_BINASCII

extmod/modbluetooth.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,11 @@ const mp_obj_module_t mp_module_bluetooth = {
10041004
.globals = (mp_obj_dict_t *)&mp_module_bluetooth_globals,
10051005
};
10061006

1007-
MP_REGISTER_MODULE(MP_QSTR_bluetooth, mp_module_bluetooth);
1007+
// This module should not be extensible (as it is not a CPython standard
1008+
// library nor is it necessary to override from the filesystem), however it
1009+
// has previously been known as `ubluetooth`, so by making it extensible the
1010+
// `ubluetooth` alias will continue to work.
1011+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_bluetooth, mp_module_bluetooth);
10081012

10091013
// Helpers
10101014

extmod/modcryptolib.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,10 @@ const mp_obj_module_t mp_module_cryptolib = {
375375
.globals = (mp_obj_dict_t *)&mp_module_cryptolib_globals,
376376
};
377377

378-
MP_REGISTER_MODULE(MP_QSTR_cryptolib, mp_module_cryptolib);
378+
// This module should not be extensible (as it is not a CPython standard
379+
// library nor is it necessary to override from the filesystem), however it
380+
// has previously been known as `ucryptolib`, so by making it extensible the
381+
// `ucryptolib` alias will continue to work.
382+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_cryptolib, mp_module_cryptolib);
379383

380384
#endif // MICROPY_PY_CRYPTOLIB

extmod/modhashlib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,6 @@ const mp_obj_module_t mp_module_hashlib = {
374374
.globals = (mp_obj_dict_t *)&mp_module_hashlib_globals,
375375
};
376376

377-
MP_REGISTER_MODULE(MP_QSTR_hashlib, mp_module_hashlib);
377+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_hashlib, mp_module_hashlib);
378378

379379
#endif // MICROPY_PY_HASHLIB

extmod/modheapq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ const mp_obj_module_t mp_module_heapq = {
118118
.globals = (mp_obj_dict_t *)&mp_module_heapq_globals,
119119
};
120120

121-
MP_REGISTER_MODULE(MP_QSTR_heapq, mp_module_heapq);
121+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_heapq, mp_module_heapq);
122122
#endif
123123

124124
#endif // MICROPY_PY_HEAPQ

extmod/modjson.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,6 @@ const mp_obj_module_t mp_module_json = {
381381
.globals = (mp_obj_dict_t *)&mp_module_json_globals,
382382
};
383383

384-
MP_REGISTER_MODULE(MP_QSTR_json, mp_module_json);
384+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_json, mp_module_json);
385385

386386
#endif // MICROPY_PY_JSON

extmod/modlwip.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1802,7 +1802,7 @@ const mp_obj_module_t mp_module_lwip = {
18021802
MP_REGISTER_MODULE(MP_QSTR_lwip, mp_module_lwip);
18031803

18041804
// On LWIP-ports, this is the socket module (replaces extmod/modsocket.c).
1805-
MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_lwip);
1805+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_socket, mp_module_lwip);
18061806

18071807
MP_REGISTER_ROOT_POINTER(mp_obj_t lwip_slip_stream);
18081808

extmod/modos.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,6 @@ const mp_obj_module_t mp_module_os = {
195195
.globals = (mp_obj_dict_t *)&os_module_globals,
196196
};
197197

198-
MP_REGISTER_MODULE(MP_QSTR_os, mp_module_os);
198+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_os, mp_module_os);
199199

200200
#endif // MICROPY_PY_OS

extmod/modplatform.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,6 @@ const mp_obj_module_t mp_module_platform = {
7575
.globals = (mp_obj_dict_t *)&modplatform_globals,
7676
};
7777

78-
MP_REGISTER_MODULE(MP_QSTR_platform, mp_module_platform);
78+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_platform, mp_module_platform);
7979

8080
#endif // MICROPY_PY_PLATFORM

extmod/modrandom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ const mp_obj_module_t mp_module_random = {
255255
.globals = (mp_obj_dict_t *)&mp_module_random_globals,
256256
};
257257

258-
MP_REGISTER_MODULE(MP_QSTR_random, mp_module_random);
258+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_random, mp_module_random);
259259
#endif
260260

261261
#endif // MICROPY_PY_RANDOM

extmod/modre.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ const mp_obj_module_t mp_module_re = {
470470
.globals = (mp_obj_dict_t *)&mp_module_re_globals,
471471
};
472472

473-
MP_REGISTER_MODULE(MP_QSTR_re, mp_module_re);
473+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_re, mp_module_re);
474474
#endif
475475

476476
// Source files #include'd here to make sure they're compiled in

extmod/modselect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,6 @@ const mp_obj_module_t mp_module_select = {
373373
.globals = (mp_obj_dict_t *)&mp_module_select_globals,
374374
};
375375

376-
MP_REGISTER_MODULE(MP_QSTR_select, mp_module_select);
376+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_select, mp_module_select);
377377

378378
#endif // MICROPY_PY_SELECT

extmod/modsocket.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,6 @@ const mp_obj_module_t mp_module_socket = {
653653
.globals = (mp_obj_dict_t *)&mp_module_socket_globals,
654654
};
655655

656-
MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_socket);
656+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_socket, mp_module_socket);
657657

658658
#endif // MICROPY_PY_NETWORK && MICROPY_PY_SOCKET && !MICROPY_PY_LWIP

extmod/modssl_axtls.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,6 @@ const mp_obj_module_t mp_module_ssl = {
357357
.globals = (mp_obj_dict_t *)&mp_module_ssl_globals,
358358
};
359359

360-
MP_REGISTER_MODULE(MP_QSTR_ssl, mp_module_ssl);
360+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_ssl, mp_module_ssl);
361361

362362
#endif // MICROPY_PY_SSL && MICROPY_SSL_AXTLS

extmod/modssl_mbedtls.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,6 @@ const mp_obj_module_t mp_module_ssl = {
507507
.globals = (mp_obj_dict_t *)&mp_module_ssl_globals,
508508
};
509509

510-
MP_REGISTER_MODULE(MP_QSTR_ssl, mp_module_ssl);
510+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_ssl, mp_module_ssl);
511511

512512
#endif // MICROPY_PY_SSL && MICROPY_SSL_MBEDTLS

extmod/modtime.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,6 @@ const mp_obj_module_t mp_module_time = {
231231
.globals = (mp_obj_dict_t *)&mp_module_time_globals,
232232
};
233233

234-
MP_REGISTER_MODULE(MP_QSTR_time, mp_module_time);
234+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_time, mp_module_time);
235235

236236
#endif // MICROPY_PY_TIME

extmod/modtimeq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,6 @@ const mp_obj_module_t mp_module_timeq = {
230230
.globals = (mp_obj_dict_t *)&mp_module_timeq_globals,
231231
};
232232

233-
MP_REGISTER_MODULE(MP_QSTR_timeq, mp_module_timeq);
233+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_timeq, mp_module_timeq);
234234

235235
#endif // MICROPY_PY_TIMEQ

extmod/moductypes.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,8 @@ const mp_obj_module_t mp_module_uctypes = {
718718
.globals = (mp_obj_dict_t *)&mp_module_uctypes_globals,
719719
};
720720

721+
// uctypes is not a Python standard library module (hence "uctypes"
722+
// not "ctypes") and therefore shouldn't be extensible.
721723
MP_REGISTER_MODULE(MP_QSTR_uctypes, mp_module_uctypes);
722724

723725
#endif

extmod/modwebsocket.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,10 @@ const mp_obj_module_t mp_module_websocket = {
311311
.globals = (mp_obj_dict_t *)&websocket_module_globals,
312312
};
313313

314-
MP_REGISTER_MODULE(MP_QSTR_websocket, mp_module_websocket);
314+
// This module should not be extensible (as it is not a CPython standard
315+
// library nor is it necessary to override from the filesystem), however it
316+
// has previously been known as `uwebsocket`, so by making it extensible the
317+
// `uwebsocket` alias will continue to work.
318+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_websocket, mp_module_websocket);
315319

316320
#endif // MICROPY_PY_WEBSOCKET

extmod/modzlib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ const mp_obj_module_t mp_module_zlib = {
224224
};
225225

226226

227-
MP_REGISTER_MODULE(MP_QSTR_zlib, mp_module_zlib);
227+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_zlib, mp_module_zlib);
228228
#endif
229229

230230
// Source files #include'd here to make sure they're compiled in

ports/cc3200/mods/modmachine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,5 +214,5 @@ const mp_obj_module_t mp_module_machine = {
214214
.globals = (mp_obj_dict_t*)&machine_module_globals,
215215
};
216216

217-
MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine);
217+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_machine, mp_module_machine);
218218
MP_REGISTER_ROOT_POINTER(mp_obj_t machine_config_main);

ports/cc3200/mods/modos.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,4 @@ const mp_obj_module_t mp_module_os = {
180180
.globals = (mp_obj_dict_t*)&os_module_globals,
181181
};
182182

183-
MP_REGISTER_MODULE(MP_QSTR_os, mp_module_os);
183+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_os, mp_module_os);

ports/cc3200/mods/modsocket.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,4 +818,4 @@ const mp_obj_module_t mp_module_socket = {
818818
.globals = (mp_obj_dict_t*)&mp_module_socket_globals,
819819
};
820820

821-
MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_socket);
821+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_socket, mp_module_socket);

ports/cc3200/mods/modssl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,4 @@ const mp_obj_module_t mp_module_ssl = {
160160
.globals = (mp_obj_dict_t*)&mp_module_ssl_globals,
161161
};
162162

163-
MP_REGISTER_MODULE(MP_QSTR_ssl, mp_module_ssl);
163+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_ssl, mp_module_ssl);

ports/esp32/modmachine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,6 @@ const mp_obj_module_t mp_module_machine = {
353353
.globals = (mp_obj_dict_t *)&machine_module_globals,
354354
};
355355

356-
MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine);
356+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_machine, mp_module_machine);
357357

358358
#endif // MICROPY_PY_MACHINE

ports/esp32/modsocket.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,4 +872,4 @@ const mp_obj_module_t mp_module_socket = {
872872
// Note: This port doesn't define MICROPY_PY_SOCKET or MICROPY_PY_LWIP so
873873
// this will not conflict with the common implementation provided by
874874
// extmod/mod{lwip,socket}.c.
875-
MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_socket);
875+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_socket, mp_module_socket);

ports/esp8266/modmachine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,6 @@ const mp_obj_module_t mp_module_machine = {
456456
.globals = (mp_obj_dict_t *)&machine_module_globals,
457457
};
458458

459-
MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine);
459+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_machine, mp_module_machine);
460460

461461
#endif // MICROPY_PY_MACHINE

ports/mimxrt/modmachine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,6 @@ const mp_obj_module_t mp_module_machine = {
185185
.globals = (mp_obj_dict_t *)&machine_module_globals,
186186
};
187187

188-
MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine);
188+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_machine, mp_module_machine);
189189

190190
#endif // MICROPY_PY_MACHINE

ports/nrf/modules/machine/modmachine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,6 @@ const mp_obj_module_t mp_module_machine = {
266266
.globals = (mp_obj_dict_t*)&machine_module_globals,
267267
};
268268

269-
MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine);
269+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_machine, mp_module_machine);
270270

271271
#endif // MICROPY_PY_MACHINE

ports/nrf/modules/os/modos.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,4 @@ const mp_obj_module_t mp_module_os = {
197197
.globals = (mp_obj_dict_t*)&os_module_globals,
198198
};
199199

200-
MP_REGISTER_MODULE(MP_QSTR_os, mp_module_os);
200+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_os, mp_module_os);

ports/qemu-arm/modmachine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ const mp_obj_module_t mp_module_machine = {
4848
.globals = (mp_obj_dict_t *)&machine_module_globals,
4949
};
5050

51-
MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine);
51+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_machine, mp_module_machine);
5252

5353
#endif // MICROPY_PY_MACHINE

ports/renesas-ra/modmachine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,6 @@ const mp_obj_module_t mp_module_machine = {
307307
.globals = (mp_obj_dict_t *)&machine_module_globals,
308308
};
309309

310-
MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine);
310+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_machine, mp_module_machine);
311311

312312
#endif // MICROPY_PY_MACHINE

ports/rp2/modmachine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,6 @@ const mp_obj_module_t mp_module_machine = {
278278
.globals = (mp_obj_dict_t *)&machine_module_globals,
279279
};
280280

281-
MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine);
281+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_machine, mp_module_machine);
282282

283283
#endif // MICROPY_PY_MACHINE

ports/samd/modmachine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,6 @@ const mp_obj_module_t mp_module_machine = {
297297
.globals = (mp_obj_dict_t *)&machine_module_globals,
298298
};
299299

300-
MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine);
300+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_machine, mp_module_machine);
301301

302302
#endif // MICROPY_PY_MACHINE

ports/stm32/modmachine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,6 @@ const mp_obj_module_t mp_module_machine = {
471471
.globals = (mp_obj_dict_t *)&machine_module_globals,
472472
};
473473

474-
MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine);
474+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_machine, mp_module_machine);
475475

476476
#endif // MICROPY_PY_MACHINE

ports/unix/modmachine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,6 @@ const mp_obj_module_t mp_module_machine = {
110110
.globals = (mp_obj_dict_t *)&machine_module_globals,
111111
};
112112

113-
MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine);
113+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_machine, mp_module_machine);
114114

115115
#endif // MICROPY_PY_MACHINE

ports/unix/modselect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,6 @@ const mp_obj_module_t mp_module_select = {
351351
.globals = (mp_obj_dict_t *)&mp_module_select_globals,
352352
};
353353

354-
MP_REGISTER_MODULE(MP_QSTR_select, mp_module_select);
354+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_select, mp_module_select);
355355

356356
#endif // MICROPY_PY_SELECT_POSIX

ports/unix/modsocket.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,6 @@ const mp_obj_module_t mp_module_socket = {
707707
.globals = (mp_obj_dict_t *)&mp_module_socket_globals,
708708
};
709709

710-
MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_socket);
710+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_socket, mp_module_socket);
711711

712712
#endif // MICROPY_PY_SOCKET

ports/zephyr/modmachine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,6 @@ const mp_obj_module_t mp_module_machine = {
8989
.globals = (mp_obj_dict_t *)&machine_module_globals,
9090
};
9191

92-
MP_REGISTER_MODULE(MP_QSTR_machine, mp_module_machine);
92+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_machine, mp_module_machine);
9393

9494
#endif // MICROPY_PY_MACHINE

ports/zephyr/modsocket.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,6 @@ const mp_obj_module_t mp_module_socket = {
473473
.globals = (mp_obj_dict_t *)&mp_module_socket_globals,
474474
};
475475

476-
MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_socket);
476+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_socket, mp_module_socket);
477477

478478
#endif // MICROPY_PY_SOCKET

py/builtinimport.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,20 +380,23 @@ STATIC mp_obj_t process_import_at_level(qstr full_mod_name, qstr level_mod_name,
380380
mp_obj_t module_obj;
381381

382382
if (outer_module_obj == MP_OBJ_NULL) {
383+
// First module in the dotted-name path.
383384
DEBUG_printf("Searching for top-level module\n");
384385

385386
// An import of a non-extensible built-in will always bypass the
386-
// filesystem. e.g. `import micropython` or `import pyb`.
387+
// filesystem. e.g. `import micropython` or `import pyb`. So try and
388+
// match a non-extensible built-ins first.
387389
module_obj = mp_module_get_builtin(level_mod_name, false);
388390
if (module_obj != MP_OBJ_NULL) {
389391
return module_obj;
390392
}
391393

392-
// First module in the dotted-name; search for a directory or file
393-
// relative to all the locations in sys.path.
394+
// Next try the filesystem. Search for a directory or file relative to
395+
// all the locations in sys.path.
394396
stat = stat_top_level(level_mod_name, &path);
395397

396-
// TODO: If stat failed, now try extensible built-in modules.
398+
// If filesystem failed, now try and see if it matches an extensible
399+
// built-in module.
397400
if (stat == MP_IMPORT_STAT_NO_EXIST) {
398401
module_obj = mp_module_get_builtin(level_mod_name, true);
399402
if (module_obj != MP_OBJ_NULL) {

py/modarray.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ const mp_obj_module_t mp_module_array = {
4040
.globals = (mp_obj_dict_t *)&mp_module_array_globals,
4141
};
4242

43-
MP_REGISTER_MODULE(MP_QSTR_array, mp_module_array);
43+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_array, mp_module_array);
4444

4545
#endif

py/modcollections.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ const mp_obj_module_t mp_module_collections = {
4646
.globals = (mp_obj_dict_t *)&mp_module_collections_globals,
4747
};
4848

49-
MP_REGISTER_MODULE(MP_QSTR_collections, mp_module_collections);
49+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_collections, mp_module_collections);
5050

5151
#endif // MICROPY_PY_COLLECTIONS

py/moderrno.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ const mp_obj_module_t mp_module_errno = {
9999
.globals = (mp_obj_dict_t *)&mp_module_errno_globals,
100100
};
101101

102-
MP_REGISTER_MODULE(MP_QSTR_errno, mp_module_errno);
102+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_errno, mp_module_errno);
103103

104104
qstr mp_errno_to_str(mp_obj_t errno_val) {
105105
#if MICROPY_PY_ERRNO_ERRORCODE

py/modio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,6 @@ const mp_obj_module_t mp_module_io = {
226226
.globals = (mp_obj_dict_t *)&mp_module_io_globals,
227227
};
228228

229-
MP_REGISTER_MODULE(MP_QSTR_io, mp_module_io);
229+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_io, mp_module_io);
230230

231231
#endif

py/modstruct.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,6 @@ const mp_obj_module_t mp_module_struct = {
266266
.globals = (mp_obj_dict_t *)&mp_module_struct_globals,
267267
};
268268

269-
MP_REGISTER_MODULE(MP_QSTR_struct, mp_module_struct);
269+
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_struct, mp_module_struct);
270270

271271
#endif

0 commit comments

Comments
 (0)