Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
circuitpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
circuitpython
Commits
ad9a0ec8
Commit
ad9a0ec8
authored
Mar 18, 2020
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
all: Convert exceptions to use mp_raise_XXX helpers in remaining places.
parent
8f0778b2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
12 additions
and
12 deletions
+12
-12
extmod/vfs_posix_file.c
extmod/vfs_posix_file.c
+1
-1
ports/esp32/modesp32.c
ports/esp32/modesp32.c
+2
-2
ports/esp32/network_ppp.c
ports/esp32/network_ppp.c
+1
-1
ports/nrf/boards/microbit/modules/microbitimage.c
ports/nrf/boards/microbit/modules/microbitimage.c
+5
-5
py/modbuiltins.c
py/modbuiltins.c
+1
-1
py/modmath.c
py/modmath.c
+2
-2
No files found.
extmod/vfs_posix_file.c
View file @
ad9a0ec8
...
...
@@ -45,7 +45,7 @@ typedef struct _mp_obj_vfs_posix_file_t {
#ifdef MICROPY_CPYTHON_COMPAT
STATIC
void
check_fd_is_open
(
const
mp_obj_vfs_posix_file_t
*
o
)
{
if
(
o
->
fd
<
0
)
{
mp_raise_
msg
(
&
mp_type_ValueError
,
"I/O operation on closed file"
);
mp_raise_
ValueError
(
"I/O operation on closed file"
);
}
}
#else
...
...
ports/esp32/modesp32.c
View file @
ad9a0ec8
...
...
@@ -74,7 +74,7 @@ STATIC mp_obj_t esp32_wake_on_ext0(size_t n_args, const mp_obj_t *pos_args, mp_m
gpio_num_t
pin_id
=
machine_pin_get_id
(
args
[
ARG_pin
].
u_obj
);
if
(
pin_id
!=
machine_rtc_config
.
ext0_pin
)
{
if
(
!
RTC_IS_VALID_EXT_PIN
(
pin_id
))
{
mp_raise_
msg
(
&
mp_type_ValueError
,
"invalid pin"
);
mp_raise_
ValueError
(
"invalid pin"
);
}
machine_rtc_config
.
ext0_pin
=
pin_id
;
}
...
...
@@ -109,7 +109,7 @@ STATIC mp_obj_t esp32_wake_on_ext1(size_t n_args, const mp_obj_t *pos_args, mp_m
gpio_num_t
pin_id
=
machine_pin_get_id
(
elem
[
i
]);
if
(
!
RTC_IS_VALID_EXT_PIN
(
pin_id
))
{
mp_raise_
msg
(
&
mp_type_ValueError
,
"invalid pin"
);
mp_raise_
ValueError
(
"invalid pin"
);
break
;
}
ext1_pins
|=
(
1ll
<<
pin_id
);
...
...
ports/esp32/network_ppp.c
View file @
ad9a0ec8
...
...
@@ -191,7 +191,7 @@ STATIC mp_obj_t ppp_connect_py(size_t n_args, const mp_obj_t *args, mp_map_t *kw
case
PPPAUTHTYPE_CHAP
:
break
;
default:
mp_raise_
msg
(
&
mp_type_ValueError
,
"invalid auth"
);
mp_raise_
ValueError
(
"invalid auth"
);
}
if
(
parsed_args
[
ARG_authmode
].
u_int
!=
PPPAUTHTYPE_NONE
)
{
...
...
ports/nrf/boards/microbit/modules/microbitimage.c
View file @
ad9a0ec8
...
...
@@ -227,7 +227,7 @@ STATIC mp_obj_t microbit_image_make_new(const mp_obj_type_t *type_in, mp_uint_t
return
image_from_parsed_str
(
str
,
len
);
}
}
else
{
mp_raise_
msg
(
&
mp_type_TypeError
,
"Image(s) takes a string."
);
mp_raise_
TypeError
(
"Image(s) takes a string."
);
}
}
...
...
@@ -258,7 +258,7 @@ STATIC mp_obj_t microbit_image_make_new(const mp_obj_type_t *type_in, mp_uint_t
}
default:
{
mp_raise_
msg
(
&
mp_type_TypeError
,
"Image() takes 0 to 3 arguments"
);
mp_raise_
TypeError
(
"Image() takes 0 to 3 arguments"
);
}
}
}
...
...
@@ -363,7 +363,7 @@ MP_DEFINE_CONST_FUN_OBJ_3(microbit_image_get_pixel_obj, microbit_image_get_pixel
/* Raise an exception if not mutable */
static
void
check_mutability
(
microbit_image_obj_t
*
self
)
{
if
(
self
->
base
.
five
)
{
mp_raise_
msg
(
&
mp_type_TypeError
,
"image cannot be modified (try copying first)"
);
mp_raise_
TypeError
(
"image cannot be modified (try copying first)"
);
}
}
...
...
@@ -406,10 +406,10 @@ mp_obj_t microbit_image_blit(mp_uint_t n_args, const mp_obj_t *args) {
mp_obj_t
src
=
args
[
1
];
if
(
mp_obj_get_type
(
src
)
!=
&
microbit_image_type
)
{
mp_raise_
msg
(
&
mp_type_TypeError
,
"expecting an image"
);
mp_raise_
TypeError
(
"expecting an image"
);
}
if
(
n_args
==
7
)
{
mp_raise_
msg
(
&
mp_type_TypeError
,
"must specify both offsets"
);
mp_raise_
TypeError
(
"must specify both offsets"
);
}
mp_int_t
x
=
mp_obj_get_int
(
args
[
2
]);
mp_int_t
y
=
mp_obj_get_int
(
args
[
3
]);
...
...
py/modbuiltins.c
View file @
ad9a0ec8
...
...
@@ -387,7 +387,7 @@ STATIC mp_obj_t mp_builtin_pow(size_t n_args, const mp_obj_t *args) {
return
mp_binary_op
(
MP_BINARY_OP_POWER
,
args
[
0
],
args
[
1
]);
default:
#if !MICROPY_PY_BUILTINS_POW3
mp_raise_
msg
(
&
mp_type_NotImplementedError
,
"3-arg pow() not supported"
);
mp_raise_
NotImplementedError
(
"3-arg pow() not supported"
);
#elif MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_MPZ
return
mp_binary_op
(
MP_BINARY_OP_MODULO
,
mp_binary_op
(
MP_BINARY_OP_POWER
,
args
[
0
],
args
[
1
]),
args
[
2
]);
#else
...
...
py/modmath.c
View file @
ad9a0ec8
...
...
@@ -294,7 +294,7 @@ STATIC mp_obj_t mp_math_factorial_inner(mp_uint_t start, mp_uint_t end) {
STATIC
mp_obj_t
mp_math_factorial
(
mp_obj_t
x_obj
)
{
mp_int_t
max
=
mp_obj_get_int
(
x_obj
);
if
(
max
<
0
)
{
mp_raise_
msg
(
&
mp_type_ValueError
,
"negative factorial"
);
mp_raise_
ValueError
(
"negative factorial"
);
}
else
if
(
max
==
0
)
{
return
MP_OBJ_NEW_SMALL_INT
(
1
);
}
...
...
@@ -308,7 +308,7 @@ STATIC mp_obj_t mp_math_factorial(mp_obj_t x_obj) {
STATIC
mp_obj_t
mp_math_factorial
(
mp_obj_t
x_obj
)
{
mp_int_t
max
=
mp_obj_get_int
(
x_obj
);
if
(
max
<
0
)
{
mp_raise_
msg
(
&
mp_type_ValueError
,
"negative factorial"
);
mp_raise_
ValueError
(
"negative factorial"
);
}
else
if
(
max
<=
1
)
{
return
MP_OBJ_NEW_SMALL_INT
(
1
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment