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
GitLab 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
300c8bd4
Commit
300c8bd4
authored
Mar 20, 2014
by
Rachel Dowdall
Browse files
Options
Downloads
Patches
Plain Diff
Added ZeroDivisionError to float division.
parent
a2f2f734
No related branches found
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
py/obj.h
+1
-0
1 addition, 0 deletions
py/obj.h
py/objexcept.c
+1
-0
1 addition, 0 deletions
py/objexcept.c
py/objfloat.c
+7
-2
7 additions, 2 deletions
py/objfloat.c
py/qstrdefs.h
+1
-0
1 addition, 0 deletions
py/qstrdefs.h
py/runtime.c
+1
-0
1 addition, 0 deletions
py/runtime.c
with
11 additions
and
2 deletions
py/obj.h
+
1
−
0
View file @
300c8bd4
...
@@ -201,6 +201,7 @@ extern const mp_obj_type_t mp_type_OverflowError;
...
@@ -201,6 +201,7 @@ extern const mp_obj_type_t mp_type_OverflowError;
extern
const
mp_obj_type_t
mp_type_OSError
;
extern
const
mp_obj_type_t
mp_type_OSError
;
extern
const
mp_obj_type_t
mp_type_NotImplementedError
;
extern
const
mp_obj_type_t
mp_type_NotImplementedError
;
extern
const
mp_obj_type_t
mp_type_StopIteration
;
extern
const
mp_obj_type_t
mp_type_StopIteration
;
extern
const
mp_obj_type_t
mp_type_ZeroDivisionError
;
// Constant objects, globally accessible
// Constant objects, globally accessible
...
...
This diff is collapsed.
Click to expand it.
py/objexcept.c
+
1
−
0
View file @
300c8bd4
...
@@ -93,6 +93,7 @@ MP_DEFINE_EXCEPTION(OverflowError, BaseException)
...
@@ -93,6 +93,7 @@ MP_DEFINE_EXCEPTION(OverflowError, BaseException)
MP_DEFINE_EXCEPTION
(
OSError
,
BaseException
)
MP_DEFINE_EXCEPTION
(
OSError
,
BaseException
)
MP_DEFINE_EXCEPTION
(
NotImplementedError
,
BaseException
)
MP_DEFINE_EXCEPTION
(
NotImplementedError
,
BaseException
)
MP_DEFINE_EXCEPTION
(
StopIteration
,
BaseException
)
MP_DEFINE_EXCEPTION
(
StopIteration
,
BaseException
)
MP_DEFINE_EXCEPTION
(
ZeroDivisionError
,
BaseException
)
mp_obj_t
mp_obj_new_exception
(
const
mp_obj_type_t
*
exc_type
)
{
mp_obj_t
mp_obj_new_exception
(
const
mp_obj_type_t
*
exc_type
)
{
return
mp_obj_new_exception_msg_varg
(
exc_type
,
NULL
);
return
mp_obj_new_exception_msg_varg
(
exc_type
,
NULL
);
...
...
This diff is collapsed.
Click to expand it.
py/objfloat.c
+
7
−
2
View file @
300c8bd4
#include
<stdlib.h>
#include
<stdlib.h>
#include
<assert.h>
#include
<assert.h>
#include
<math.h>
#include
"nlr.h"
#include
"nlr.h"
#include
"misc.h"
#include
"misc.h"
...
@@ -105,8 +106,12 @@ mp_obj_t mp_obj_float_binary_op(int op, mp_float_t lhs_val, mp_obj_t rhs_in) {
...
@@ -105,8 +106,12 @@ mp_obj_t mp_obj_float_binary_op(int op, mp_float_t lhs_val, mp_obj_t rhs_in) {
case RT_BINARY_OP_INPLACE_FLOOR_DIVIDE: val = lhs_val / rhs_val; break;
case RT_BINARY_OP_INPLACE_FLOOR_DIVIDE: val = lhs_val / rhs_val; break;
*/
*/
case
RT_BINARY_OP_TRUE_DIVIDE
:
case
RT_BINARY_OP_TRUE_DIVIDE
:
case
RT_BINARY_OP_INPLACE_TRUE_DIVIDE
:
lhs_val
/=
rhs_val
;
break
;
case
RT_BINARY_OP_INPLACE_TRUE_DIVIDE
:
lhs_val
/=
rhs_val
;
if
(
isinf
(
lhs_val
)){
// check for division by zero
nlr_jump
(
mp_obj_new_exception_msg
(
&
mp_type_ZeroDivisionError
,
"float division by zero"
));
}
break
;
case
RT_BINARY_OP_LESS
:
return
MP_BOOL
(
lhs_val
<
rhs_val
);
case
RT_BINARY_OP_LESS
:
return
MP_BOOL
(
lhs_val
<
rhs_val
);
case
RT_BINARY_OP_MORE
:
return
MP_BOOL
(
lhs_val
>
rhs_val
);
case
RT_BINARY_OP_MORE
:
return
MP_BOOL
(
lhs_val
>
rhs_val
);
case
RT_BINARY_OP_LESS_EQUAL
:
return
MP_BOOL
(
lhs_val
<=
rhs_val
);
case
RT_BINARY_OP_LESS_EQUAL
:
return
MP_BOOL
(
lhs_val
<=
rhs_val
);
...
...
This diff is collapsed.
Click to expand it.
py/qstrdefs.h
+
1
−
0
View file @
300c8bd4
...
@@ -47,6 +47,7 @@ Q(SyntaxError)
...
@@ -47,6 +47,7 @@ Q(SyntaxError)
Q
(
TypeError
)
Q
(
TypeError
)
Q
(
ValueError
)
Q
(
ValueError
)
Q
(
OverflowError
)
Q
(
OverflowError
)
Q
(
ZeroDivisionError
)
Q
(
NoneType
)
Q
(
NoneType
)
...
...
This diff is collapsed.
Click to expand it.
py/runtime.c
+
1
−
0
View file @
300c8bd4
...
@@ -158,6 +158,7 @@ STATIC const mp_builtin_elem_t builtin_table[] = {
...
@@ -158,6 +158,7 @@ STATIC const mp_builtin_elem_t builtin_table[] = {
{
MP_QSTR_OSError
,
(
mp_obj_t
)
&
mp_type_OSError
},
{
MP_QSTR_OSError
,
(
mp_obj_t
)
&
mp_type_OSError
},
{
MP_QSTR_NotImplementedError
,
(
mp_obj_t
)
&
mp_type_NotImplementedError
},
{
MP_QSTR_NotImplementedError
,
(
mp_obj_t
)
&
mp_type_NotImplementedError
},
{
MP_QSTR_StopIteration
,
(
mp_obj_t
)
&
mp_type_StopIteration
},
{
MP_QSTR_StopIteration
,
(
mp_obj_t
)
&
mp_type_StopIteration
},
{
MP_QSTR_ZeroDivisionError
,
(
mp_obj_t
)
&
mp_type_ZeroDivisionError
},
// Extra builtins as defined by a port
// Extra builtins as defined by a port
MICROPY_EXTRA_BUILTINS
MICROPY_EXTRA_BUILTINS
...
...
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