New submission from Batuhan Taskaya <isidenti...@gmail.com>:
Currently, buffer is just an instance-level list that is used in various places to avoid directly writing stuff into the real source buffer, though the design is pretty complicated and hard to use. There are various use cases (like omitting the empty space when unparsing argument-less lambdas, e.g: lambda : 2 + 2) we could've use this buffer system if it was offering a stackable version (like multiple levels of buffers). What I think is we should probably do this with a proper context manager and in the context capture all writings into a list where we would return after the context is closed; with self.buffered() as buffer: self._write_fstring_inner(node) return self._write_str_avoiding_backslashes("".join(buffer)) ---------- assignee: BTaskaya components: Library (Lib) messages: 388197 nosy: BTaskaya priority: normal severity: normal status: open title: ast.unparse: Simplify buffering logic versions: Python 3.10 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue43417> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com