[issue43417] ast.unparse: Simplify buffering logic

2021-05-08 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43417] ast.unparse: Simplify buffering logic

2021-03-06 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
keywords: +patch
pull_requests: +23540
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/24772

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43417] ast.unparse: Simplify buffering logic

2021-03-06 Thread Batuhan Taskaya


New submission from Batuhan Taskaya :

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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com