Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
1f85d625
Commit
1f85d625
authored
10 years ago
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
py: Add tentative scheme for error messages configuration.
parent
68551a84
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
py/mpconfig.h
+11
-0
11 additions, 0 deletions
py/mpconfig.h
py/objfun.c
+10
-0
10 additions, 0 deletions
py/objfun.c
unix/mpconfigport.h
+3
-0
3 additions, 0 deletions
unix/mpconfigport.h
with
24 additions
and
0 deletions
py/mpconfig.h
+
11
−
0
View file @
1f85d625
...
...
@@ -94,6 +94,17 @@ typedef long long mp_longint_impl_t;
#define MICROPY_ENABLE_DOC_STRING (0)
#endif
// Exception messages are short static strings (TODO)
#define MICROPY_ERROR_REPORTING_TERSE (1)
// Exception messages provide basic error details
#define MICROPY_ERROR_REPORTING_NORMAL (2)
// Exception messages provide full info, e.g. object names
#define MICROPY_ERROR_REPORTING_DETAILED (3)
#ifndef MICROPY_ERROR_REPORTING
#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL)
#endif
// Float and complex implementation
#define MICROPY_FLOAT_IMPL_NONE (0)
#define MICROPY_FLOAT_IMPL_FLOAT (1)
...
...
This diff is collapsed.
Click to expand it.
py/objfun.c
+
10
−
0
View file @
1f85d625
...
...
@@ -152,8 +152,18 @@ STATIC void dump_args(const mp_obj_t *a, int sz) {
#endif
STATIC
NORETURN
void
fun_pos_args_mismatch
(
mp_obj_fun_bc_t
*
f
,
uint
expected
,
uint
given
)
{
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
// Generic message, to be reused for other argument issues
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_TypeError
,
"argument num/types mismatch"
));
#elif MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NORMAL
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_TypeError
,
"function takes %d positional arguments but %d were given"
,
expected
,
given
));
#elif MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_TypeError
,
"%s() takes %d positional arguments but %d were given"
,
mp_obj_fun_get_name
(
f
),
expected
,
given
));
#endif
}
// If it's possible to call a function without allocating new argument array,
...
...
This diff is collapsed.
Click to expand it.
unix/mpconfigport.h
+
3
−
0
View file @
1f85d625
...
...
@@ -16,6 +16,9 @@
#define MICROPY_USE_COMPUTED_GOTO (1)
#define MICROPY_MOD_SYS_STDFILES (1)
#define MICROPY_ENABLE_MOD_CMATH (1)
// Define to MICROPY_ERROR_REPORTING_DETAILED to get function, etc.
// names in exception messages (may require more RAM).
#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_DETAILED)
extern
const
struct
_mp_obj_module_t
mp_module_time
;
extern
const
struct
_mp_obj_module_t
mp_module_socket
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment