[issue33520] ast.Tuple has wrong col_offset
New submission from Isaiah Peng : The `col_offset` of the ast.Tuple node is set to the column offset of the first element, shown in code: >>> a = "{1,2,3}" >>> b = ast.parse(a).body[0] >>> >>> >>> b.value.col_offset 0 >>> a = "[1,2,3]" >>> >>> >>> b = ast.parse(a).body[0] >>> >>> >>> b.value.col_offset >>> >>> 0 >>> a = "(1,2,3)" >>> >>> >>> ast.parse(a).body[0].value.col_offset >>> >>> 1 >>> a = "()" >>> >>> >>> ast.parse(a).body[0].value.col_offset >>> >>> 0 It's correct for dict, set, list, even empty tuple, Though this is not a serious bug, for other python implementations that uses the tests as language spec, this is annoying. -- components: Library (Lib) messages: 316665 nosy: isaiah priority: normal severity: normal status: open title: ast.Tuple has wrong col_offset type: behavior versions: Python 3.7 ___ Python tracker <https://bugs.python.org/issue33520> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33520] ast.Tuple has wrong col_offset
Isaiah Peng added the comment: Thanks for the reply, that's quite reasonable, especially take the generator expression case into consideration. However I found this is not consistent with empty tuple: >>> a = "()" >>> >>> >>> ast.parse(a).body[0].value.col_offset >>> >>> 0 It's true that the parenthesis is required to construct a tuple, but if the parenthesis is served as the starting point of the tuple, then the col_offset should be the opening parenthesis. i.e. in the following example, both should start from col 2: >>> ast.parse("c(i for i in range(10))").body[0].value.args[0].col_offset 2 >>> ast.parse("c((i for i in range(10)))").body[0].value.args[0].col_offset 3 -- ___ Python tracker <https://bugs.python.org/issue33520> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33520] ast.Tuple has wrong col_offset
Isaiah Peng added the comment: > It's true that the parenthesis is required to construct a tuple Sorry, I mean the parenthesis is *not* required. -- ___ Python tracker <https://bugs.python.org/issue33520> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33520] ast.Tuple has wrong col_offset
Isaiah Peng added the comment: Fair enough, thanks for clarification. -- ___ Python tracker <https://bugs.python.org/issue33520> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16737] Different behaviours in script run directly and via runpy.run_module
Isaiah Peng added the comment: Not sure if it's stated before, this difference of behavior also has other effects, e.g. $ python -m test.test_traceback # Ran 61 tests in 0.449s # FAILED (failures=5) This is because the loader associated with the module get confused, it loaded the original module as the proper module and then the module changed name to __main__ but the loader is still associated with the old module name, so call to `get_source` fails. $ cat > test_m.py print(__loader__.get_source(__name__)) $ python -m test_m # ImportError: loader for test_m cannot handle __main__ -- nosy: +isaiah ___ Python tracker <https://bugs.python.org/issue16737> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue32384] Generator tests is broken in non-CPython implementation
Change by Isaiah Peng : -- keywords: +patch pull_requests: +4831 stage: -> patch review ___ Python tracker <https://bugs.python.org/issue32384> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com