Fixes from review
This commit is contained in:
parent
b19c1a310e
commit
cebb10ddae
@ -1,10 +1,10 @@
|
|||||||
:mod:`uerrno` -- system error codes
|
:mod:`errno` -- system error codes
|
||||||
===================================
|
===================================
|
||||||
|
|
||||||
.. module:: uerrno
|
.. module:: errno
|
||||||
:synopsis: system error codes
|
:synopsis: system error codes
|
||||||
|
|
||||||
|see_cpython_module| :mod:`python:errno`.
|
|see_cpython_module| :mod:`cpython:errno`.
|
||||||
|
|
||||||
This module provides access to symbolic error codes for `OSError` exception.
|
This module provides access to symbolic error codes for `OSError` exception.
|
||||||
A particular inventory of codes depends on :term:`MicroPython port`.
|
A particular inventory of codes depends on :term:`MicroPython port`.
|
||||||
@ -20,9 +20,9 @@ Constants
|
|||||||
where ``exc`` is an instance of `OSError`. Usage example::
|
where ``exc`` is an instance of `OSError`. Usage example::
|
||||||
|
|
||||||
try:
|
try:
|
||||||
uos.mkdir("my_dir")
|
os.mkdir("my_dir")
|
||||||
except OSError as exc:
|
except OSError as exc:
|
||||||
if exc.args[0] == uerrno.EEXIST:
|
if exc.args[0] == errno.EEXIST:
|
||||||
print("Directory already exists")
|
print("Directory already exists")
|
||||||
|
|
||||||
.. data:: errorcode
|
.. data:: errorcode
|
||||||
@ -30,5 +30,5 @@ Constants
|
|||||||
Dictionary mapping numeric error codes to strings with symbolic error
|
Dictionary mapping numeric error codes to strings with symbolic error
|
||||||
code (see above)::
|
code (see above)::
|
||||||
|
|
||||||
>>> print(uerrno.errorcode[uerrno.EEXIST])
|
>>> print(errno.errorcode[errno.EEXIST])
|
||||||
EEXIST
|
EEXIST
|
||||||
|
@ -52,8 +52,7 @@ void mp_arg_check_num_sig(size_t n_args, size_t n_kw, uint32_t sig) {
|
|||||||
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
|
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
|
||||||
mp_arg_error_terse_mismatch();
|
mp_arg_error_terse_mismatch();
|
||||||
#else
|
#else
|
||||||
mp_raise_msg_varg(&mp_type_TypeError,
|
mp_raise_TypeError_varg(MP_ERROR_TEXT("function takes %d positional arguments but %d were given"),
|
||||||
MP_ERROR_TEXT("function takes %d positional arguments but %d were given"),
|
|
||||||
n_args_min, n_args);
|
n_args_min, n_args);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -62,7 +61,7 @@ void mp_arg_check_num_sig(size_t n_args, size_t n_kw, uint32_t sig) {
|
|||||||
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
|
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
|
||||||
mp_arg_error_terse_mismatch();
|
mp_arg_error_terse_mismatch();
|
||||||
#else
|
#else
|
||||||
mp_raise_msg_varg(&mp_type_TypeError,
|
mp_raise_TypeError_varg(
|
||||||
MP_ERROR_TEXT("function missing %d required positional arguments"),
|
MP_ERROR_TEXT("function missing %d required positional arguments"),
|
||||||
n_args_min - n_args);
|
n_args_min - n_args);
|
||||||
#endif
|
#endif
|
||||||
@ -70,7 +69,7 @@ void mp_arg_check_num_sig(size_t n_args, size_t n_kw, uint32_t sig) {
|
|||||||
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
|
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
|
||||||
mp_arg_error_terse_mismatch();
|
mp_arg_error_terse_mismatch();
|
||||||
#else
|
#else
|
||||||
mp_raise_msg_varg(&mp_type_TypeError,
|
mp_raise_TypeError_varg(
|
||||||
MP_ERROR_TEXT("function expected at most %d arguments, got %d"),
|
MP_ERROR_TEXT("function expected at most %d arguments, got %d"),
|
||||||
n_args_max, n_args);
|
n_args_max, n_args);
|
||||||
#endif
|
#endif
|
||||||
@ -107,7 +106,7 @@ void mp_arg_parse_all(size_t n_pos, const mp_obj_t *pos, mp_map_t *kws, size_t n
|
|||||||
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
|
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
|
||||||
mp_arg_error_terse_mismatch();
|
mp_arg_error_terse_mismatch();
|
||||||
#else
|
#else
|
||||||
mp_raise_msg_varg(&mp_type_TypeError, MP_ERROR_TEXT("'%q' argument required"), allowed[i].qst);
|
mp_raise_TypeError_varg(MP_ERROR_TEXT("'%q' argument required"), allowed[i].qst);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
out_vals[i] = allowed[i].defval;
|
out_vals[i] = allowed[i].defval;
|
||||||
|
@ -37,9 +37,6 @@
|
|||||||
// type check is done on getiter method to allow tuple, namedtuple, attrtuple
|
// type check is done on getiter method to allow tuple, namedtuple, attrtuple
|
||||||
#define mp_obj_is_tuple_compatible(o) (mp_obj_get_type(o)->getiter == mp_obj_tuple_getiter)
|
#define mp_obj_is_tuple_compatible(o) (mp_obj_get_type(o)->getiter == mp_obj_tuple_getiter)
|
||||||
|
|
||||||
// type check is done on getiter method to allow tuple, namedtuple, attrtuple
|
|
||||||
#define mp_obj_is_tuple_compatible(o) (mp_obj_get_type(o)->getiter == mp_obj_tuple_getiter)
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/* tuple */
|
/* tuple */
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ for i in range(N):
|
|||||||
f = vfs.open(n, "w")
|
f = vfs.open(n, "w")
|
||||||
f.write(n)
|
f.write(n)
|
||||||
f = None # release f without closing
|
f = None # release f without closing
|
||||||
[0, 1, 2, 3] # use up Python stack so f is really gone
|
[0, 1, 2, 3, 4, 5] # use up Python stack so f is really gone
|
||||||
gc.collect() # should finalise all N files by closing them
|
gc.collect() # should finalise all N files by closing them
|
||||||
for i in range(N):
|
for i in range(N):
|
||||||
with vfs.open("x%d" % i, "r") as f:
|
with vfs.open("x%d" % i, "r") as f:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user