← index #5046PR #4400
Related · high · value 1.451
QUERY · ISSUE

RFC: MICROPY_PY_BUILTINS_NEXT2 always set to (0) ?

openby pmp-popened 2019-08-27updated 2022-12-22
rfc

Current settings for all ports break cpython script compatibility on next()

https://docs.python.org/3.5/library/functions.html#next

because
MICROPY_PY_BUILTINS_NEXT2 is never defined to 1 except in coverage and defaults to 0
https://github.com/micropython/micropython/blob/master/py/mpconfig.h#L910

CANDIDATE · PULL REQUEST

RFC py: Support builtin next() with 2 arguments

closedby stinosopened 2019-01-07updated 2019-01-28

This is a pretty convenient oneliner (to replace 4 lines otherwise) which I miss in uPy. Couple of questions:

  • made it optional with MICROPY_PY_BUILTINS_NEXT2, is that name ok, or should that just go under MICROPY_CPYTHON_COMPAT?
  • mp_builtin_next is still used for implementing __next__ with the side effect that iter([]).__next__(1) now suddenly works, not sure if this is acceptable? And if so this should this be in a seperate cpydiff test probably?
  • ok to enable this by default for unix/windows?

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