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
4c02e542
Commit
4c02e542
authored
9 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py/mpz: Raise NotImplError instead of failing assertion.
parent
5f3c3ec5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
py/mpz.c
+6
-3
6 additions, 3 deletions
py/mpz.c
tests/misc/non_compliant.py
+18
-0
18 additions, 0 deletions
tests/misc/non_compliant.py
tests/misc/non_compliant.py.exp
+3
-0
3 additions, 0 deletions
tests/misc/non_compliant.py.exp
with
27 additions
and
3 deletions
py/mpz.c
+
6
−
3
View file @
4c02e542
...
...
@@ -29,6 +29,9 @@
#include
"py/mpz.h"
// this is only needed for mp_not_implemented, which should eventually be removed
#include
"py/runtime.h"
#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_MPZ
#define DIG_SIZE (MPZ_DIG_SIZE)
...
...
@@ -1108,7 +1111,7 @@ void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) {
dest
->
neg
=
0
;
}
else
{
// TODO both args are negative
assert
(
0
);
mp_not_implemented
(
"bignum and with negative args"
);
}
}
else
{
// args have different sign
...
...
@@ -1141,7 +1144,7 @@ void mpz_or_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) {
}
else
{
mpz_need_dig
(
dest
,
lhs
->
len
);
// TODO
assert
(
0
);
mp_not_implemented
(
"bignum or with negative args"
);
// dest->len = mpn_or_neg(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len);
}
...
...
@@ -1164,7 +1167,7 @@ void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) {
}
else
{
mpz_need_dig
(
dest
,
lhs
->
len
);
// TODO
assert
(
0
);
mp_not_implemented
(
"bignum xor with negative args"
);
// dest->len = mpn_xor_neg(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len);
}
...
...
This diff is collapsed.
Click to expand it.
tests/misc/non_compliant.py
+
18
−
0
View file @
4c02e542
...
...
@@ -69,3 +69,21 @@ try:
b
'
123
'
[
0
:
3
:
2
]
except
NotImplementedError
:
print
(
'
NotImplementedError
'
)
# mpz and with both args negative
try
:
-
(
1
<<
70
)
&
-
2
except
NotImplementedError
:
print
(
'
NotImplementedError
'
)
# mpz or with args opposite sign
try
:
-
(
1
<<
70
)
|
2
except
NotImplementedError
:
print
(
'
NotImplementedError
'
)
# mpz xor with args opposite sign
try
:
-
(
1
<<
70
)
^
2
except
NotImplementedError
:
print
(
'
NotImplementedError
'
)
This diff is collapsed.
Click to expand it.
tests/misc/non_compliant.py.exp
+
3
−
0
View file @
4c02e542
...
...
@@ -9,3 +9,6 @@ NotImplementedError
NotImplementedError
NotImplementedError
NotImplementedError
NotImplementedError
NotImplementedError
NotImplementedError
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