← index #5376Issue #1222
Related · high · value 0.230
QUERY · ISSUE

Empty op name printed when missing from mp_binary_op_method_name

openby Jongyopened 2019-12-04updated 2019-12-04
py-core

With MICROPY_PY_ALL_SPECIAL_METHODS =0,

>>> 1 + 1
2
>>> 1 + 1 / 1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported types for  : 'int', 'int'
>>> 

You can see the print is a bit broken and it makes you question whether something deeper has gone wrong. I think it would be better to print something, like "unknown" or "unknown op".

For example, [0 ... MP_BINARY_OP_NUM_RUNTIME-1] = MP_QSTR_unknown, as the first line of mp_binary_op_method_name does the trick. It basically adds just this single "unknown" qstr.

CANDIDATE · ISSUE

NotImplemented not implemented

closedby pfalconopened 2015-05-04updated 2015-05-05

https://docs.python.org/3/library/constants.html?highlight=notimplemented#NotImplemented

Special value which should be returned by the binary special methods (e.g. eq(), lt(), add(), rsub(), etc.) to indicate that the operation is not implemented with respect to the other type; may be returned by the in-place binary special methods (e.g. imul(), iand(), etc.) for the same purpose. Its truth value is true.

Given that we have Ellipsis, I guess we won't get around implementing this. (Alias it to MP_OBJ_SENTINEL ?)

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied