{"action":"created","issue":{"url":"https://api.github.com/repos/xonsh/xonsh/issues/1673","repository_url":"https://api.github.com/repos/xonsh/xonsh","labels_url":"https://api.github.com/repos/xonsh/xonsh/issues/1673/labels{/name}","comments_url":"https://api.github.com/repos/xonsh/xonsh/issues/1673/comments","events_url":"https://api.github.com/repos/xonsh/xonsh/issues/1673/events","html_url":"https://github.com/xonsh/xonsh/issues/1673","id":174899476,"number":1673,"title":"Generator expressions sometimes not properly recognized","user":{"login":"cryzed","id":1429103,"avatar_url":"https://avatars.githubusercontent.com/u/1429103?v=3","gravatar_id":"","url":"https://api.github.com/users/cryzed","html_url":"https://github.com/cryzed","followers_url":"https://api.github.com/users/cryzed/followers","following_url":"https://api.github.com/users/cryzed/following{/other_user}","gists_url":"https://api.github.com/users/cryzed/gists{/gist_id}","starred_url":"https://api.github.com/users/cryzed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cryzed/subscriptions","organizations_url":"https://api.github.com/users/cryzed/orgs","repos_url":"https://api.github.com/users/cryzed/repos","events_url":"https://api.github.com/users/cryzed/events{/privacy}","received_events_url":"https://api.github.com/users/cryzed/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-09-03T14:29:16Z","updated_at":"2016-09-09T21:34:12Z","closed_at":null,"body":"This code snippet executes successfully using Python 3.5.2...\r\n\r\n```python\r\nimport os\r\n\r\nHOME_BIN = os.path.expanduser('~/.bin')\r\n\r\n\r\ndef get_all_paths(path):\r\n    paths = [path]\r\n    for root, dirs, files in os.walk(path):\r\n        paths.extend(os.path.join(root, d) for d in dirs)\r\n        paths.extend(os.path.join(root, f) for f in files)\r\n\r\n    return paths\r\n\r\n\r\nprint(len(get_all_paths(HOME_BIN)))\r\n```\r\n\r\n ...but fails when using xonsh/0.4.6.dev43:\r\n\r\n```\r\ncryzed@arch ~ $ python test.py\r\n8\r\ncryzed@arch ~ $ xonsh test.py\r\nTraceback (most recent call last):\r\n  File \"/usr/lib/python3.5/site-packages/xonsh/__amalgam__.py\", line 16319, in run_subproc\r\n    **subproc_kwargs)\r\n  File \"/usr/lib/python3.5/subprocess.py\", line 947, in __init__\r\n    restore_signals, start_new_session)\r\n  File \"/usr/lib/python3.5/subprocess.py\", line 1551, in _execute_child\r\n    raise child_exception_type(errno_num, err_msg)\r\nFileNotFoundError: [Errno 2] No such file or directory: 'for'\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n  File \"/usr/bin/xonsh\", line 3, in <module>\r\n    main()\r\n  File \"/usr/lib/python3.5/site-packages/xonsh/__amalgam__.py\", line 17534, in main\r\n    loc=None, mode='exec')\r\n  File \"/usr/lib/python3.5/site-packages/xonsh/__amalgam__.py\", line 2041, in run_script_with_cache\r\n    run_compiled_code(ccode, glb, loc, mode)\r\n  File \"/usr/lib/python3.5/site-packages/xonsh/__amalgam__.py\", line 1961, in run_compiled_code\r\n    func(code, glb, loc)\r\n  File \"test.py\", line 15, in <module>\r\n    print(len(get_all_paths(HOME_BIN)))\r\n  File \"test.py\", line 9, in get_all_paths\r\n    paths.extend(os.path.join(root, d) for d in dirs)\r\n  File \"/usr/lib/python3.5/site-packages/xonsh/__amalgam__.py\", line 16456, in subproc_captured_hiddenobject\r\n    return run_subproc(cmds, captured='hiddenobject')\r\n  File \"/usr/lib/python3.5/site-packages/xonsh/__amalgam__.py\", line 16329, in run_subproc\r\n    raise XonshError(e)\r\nxonsh.__amalgam__.XonshError: xonsh: subprocess mode: command not found: for\r\nDid you mean one of the following?\r\n    pr:   Command (/usr/bin/pr)\r\n    EOF:  Alias\r\n    tr:   Command (/usr/bin/tr)\r\n    od:   Command (/usr/bin/od)\r\n    fg:   Alias\r\n```\r\n\r\nI didn't manage to simplify the code snippet much more, because this works:\r\n\r\n```python\r\nimport os\r\n\r\na = []\r\na.extend(os.path.join('/', str(b)) for b in range(10))\r\nprint(repr(a))\r\n```\r\n\r\nSo I'm not exactly sure what's going on. The issue can be worked around by adding additional parenthesis to the `paths.extend` argument:\r\n\r\n```python\r\npaths.extend((os.path.join(root, d) for d in dirs))\r\npaths.extend((os.path.join(root, f) for f in files))\r\n```\r\n\r\nI mentioned this in IRC and Gitter, but it seems to have been missed completely."},"comment":{"url":"https://api.github.com/repos/xonsh/xonsh/issues/comments/246046667","html_url":"https://github.com/xonsh/xonsh/issues/1673#issuecomment-246046667","issue_url":"https://api.github.com/repos/xonsh/xonsh/issues/1673","id":246046667,"user":{"login":"scopatz","id":320553,"avatar_url":"https://avatars.githubusercontent.com/u/320553?v=3","gravatar_id":"","url":"https://api.github.com/users/scopatz","html_url":"https://github.com/scopatz","followers_url":"https://api.github.com/users/scopatz/followers","following_url":"https://api.github.com/users/scopatz/following{/other_user}","gists_url":"https://api.github.com/users/scopatz/gists{/gist_id}","starred_url":"https://api.github.com/users/scopatz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scopatz/subscriptions","organizations_url":"https://api.github.com/users/scopatz/orgs","repos_url":"https://api.github.com/users/scopatz/repos","events_url":"https://api.github.com/users/scopatz/events{/privacy}","received_events_url":"https://api.github.com/users/scopatz/received_events","type":"User","site_admin":false},"created_at":"2016-09-09T21:34:12Z","updated_at":"2016-09-09T21:34:12Z","body":"That is strange.  I doubt it is that, because PATH is never checked when transforming the AST.  If anything it is that the multiple targets in the for-loop are not being added to the context."}}
{"actor":{"display_login":"scopatz"}}