Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2to3 call for file in current directory yields error #75764

Closed
denis-osipov mannequin opened this issue Sep 26, 2017 · 9 comments
Closed

2to3 call for file in current directory yields error #75764

denis-osipov mannequin opened this issue Sep 26, 2017 · 9 comments
Labels
3.7 (EOL) end of life topic-2to3 type-bug An unexpected behavior, bug, or error

Comments

@denis-osipov
Copy link
Mannequin

denis-osipov mannequin commented Sep 26, 2017

BPO 31583
Nosy @benjaminp, @bitdancer, @ambv, @denis-osipov
PRs
  • bpo-31583: Fix 2to3 for using with --add-suffix option #3758
  • [3.7] bpo-31583: Fix 2to3 for using with --add-suffix option (GH-3758) #6528
  • [3.6] bpo-31583: Fix 2to3 for using with --add-suffix option (GH-3758) #6529
  • Files
  • 2to3bugpython.png
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2018-11-04.18:06:16.006>
    created_at = <Date 2017-09-26.04:58:01.484>
    labels = ['3.7', 'type-bug', 'expert-2to3']
    title = '2to3 call for file in current directory yields error'
    updated_at = <Date 2018-11-04.18:06:16.006>
    user = 'https://github.com/denis-osipov'

    bugs.python.org fields:

    activity = <Date 2018-11-04.18:06:16.006>
    actor = 'denis-osipov'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-11-04.18:06:16.006>
    closer = 'denis-osipov'
    components = ['2to3 (2.x to 3.x conversion tool)']
    creation = <Date 2017-09-26.04:58:01.484>
    creator = 'denis-osipov'
    dependencies = []
    files = ['47187']
    hgrepos = []
    issue_num = 31583
    keywords = ['patch']
    message_count = 9.0
    messages = ['303001', '303635', '303636', '303637', '303639', '303647', '315469', '315470', '315474']
    nosy_count = 5.0
    nosy_names = ['benjamin.peterson', 'r.david.murray', 'lukasz.langa', 'denis-osipov', 'jabdo']
    pr_nums = ['3758', '6528', '6529']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue31583'
    versions = ['Python 3.6', 'Python 3.7']

    @denis-osipov
    Copy link
    Mannequin Author

    denis-osipov mannequin commented Sep 26, 2017

    2to3 doesn't work if called for file in current directory with --add-suffix option.

    $ /d/repos/cpython/python.bat /d/repos/cpython/Tools/scripts/2to3 -n -W --add-suffix=3 test2to3.py
    Running Debug|x64 interpreter...
    WARNING: --write-unchanged-files/-W implies -w.
    RefactoringTool: Skipping optional fixer: buffer
    RefactoringTool: Skipping optional fixer: idioms
    RefactoringTool: Skipping optional fixer: set_literal
    RefactoringTool: Skipping optional fixer: ws_comma
    RefactoringTool: Refactored test2to3.py
    --- test2to3.py (original)
    +++ test2to3.py (refactored)

    --some changes--

    Traceback (most recent call last):
      File "D:/repos/cpython/Tools/scripts/2to3", line 5, in <module>
        sys.exit(main("lib2to3.fixes"))
      File "D:\repos\cpython\lib\lib2to3\main.py", line 259, in main
        options.processes)
      File "D:\repos\cpython\lib\lib2to3\refactor.py", line 687, in refactor
        items, write, doctests_only)
      File "D:\repos\cpython\lib\lib2to3\refactor.py", line 282, in refactor
        self.refactor_file(dir_or_file, write, doctests_only)
      File "D:\repos\cpython\lib\lib2to3\refactor.py", line 728, in refactor_file
        *args, **kwargs)
      File "D:\repos\cpython\lib\lib2to3\refactor.py", line 339, in refactor_file
        write=write, encoding=encoding)
      File "D:\repos\cpython\lib\lib2to3\refactor.py", line 505, in processed_file
        self.write_file(new_text, filename, old_text, encoding)
      File "D:\repos\cpython\lib\lib2to3\main.py", line 84, in write_file
        os.makedirs(output_dir)
      File "D:\repos\cpython\\lib\os.py", line 221, in makedirs
        mkdir(name, mode)
    FileNotFoundError: [WinError 3] The system cannot find the path specified: ''

    It works well if I use absolute path for target file or set -o:

    $ /d/repos/cpython/python.bat /d/repos/cpython/Tools/scripts/2to3 -n -W --add-suffix=3 /d/MyPythonScripts/test2to3.py
    
    $ /d/repos/cpython/python.bat /d/repos/cpython/Tools/scripts/2to3 -n -W --add-suffix=3 -o . test2to3.py

    @denis-osipov denis-osipov mannequin added 3.7 (EOL) end of life topic-2to3 type-bug An unexpected behavior, bug, or error labels Sep 26, 2017
    @jabdo
    Copy link
    Mannequin

    jabdo mannequin commented Oct 3, 2017

    Issue also effects 3.5

    @bitdancer
    Copy link
    Member

    3.5 is in security-fix-only mode, and we use versions to indicate which versions we plan to fix the bug in.

    @jabdo
    Copy link
    Mannequin

    jabdo mannequin commented Oct 3, 2017

    Gotcha, sorry about that. Active uses 3.5, so I guess I would take it up
    with them?

    On Oct 3, 2017 2:27 PM, "R. David Murray" <report@bugs.python.org> wrote:

    R. David Murray <rdmurray@bitdance.com> added the comment:

    3.5 is in security-fix-only mode, and we use versions to indicate which
    versions we plan to fix the bug in.

    ----------
    nosy: +r.david.murray
    versions: -Python 3.5


    Python tracker <report@bugs.python.org>
    <https://bugs.python.org/issue31583\>


    @bitdancer
    Copy link
    Member

    Yes, redistributors sometimes backport non-security fixes if they consider them important enough.

    Note that I haven't evaluated the merits of this issue, and there is a related issue about how 2to3 finds its fixers that this may overlap with.

    @jabdo
    Copy link
    Mannequin

    jabdo mannequin commented Oct 3, 2017

    Inserting (with 12 spaces)

                if not output_dir:
                    output_dir = "./"

    at lines 83 and 84 works as a temporary workaround. StdoutRefactoringTool is not receiving an output_dir from option, which seems to only be an issue when --add-sufix is used.

    @ambv
    Copy link
    Contributor

    ambv commented Apr 18, 2018

    New changeset e3a523a by Łukasz Langa (Denis Osipov) in branch 'master':
    bpo-31583: Fix 2to3 for using with --add-suffix option (GH-3758)
    e3a523a

    @ambv
    Copy link
    Contributor

    ambv commented Apr 19, 2018

    New changeset 67067d8 by Łukasz Langa (Miss Islington (bot)) in branch '3.7':
    bpo-31583: Fix 2to3 for using with --add-suffix option (GH-3758) (bpo-6528)
    67067d8

    @ambv
    Copy link
    Contributor

    ambv commented Apr 19, 2018

    New changeset 1957e7b by Łukasz Langa (Miss Islington (bot)) in branch '3.6':
    bpo-31583: Fix 2to3 for using with --add-suffix option (GH-3758) (GH-6529)
    1957e7b

    @denis-osipov denis-osipov mannequin closed this as completed Nov 4, 2018
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life topic-2to3 type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants