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

Lib/ftplib.py Netrc class should be removed. #50872

Closed
vincele mannequin opened this issue Aug 1, 2009 · 13 comments
Closed

Lib/ftplib.py Netrc class should be removed. #50872

vincele mannequin opened this issue Aug 1, 2009 · 13 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@vincele
Copy link
Mannequin

vincele mannequin commented Aug 1, 2009

BPO 6623
Nosy @bitdancer, @berkerpeksag
Files
  • py3k-ftplib.py-use-before-assignment.patch: fix for the macro parsing in ftplib
  • remove_Netrc_class.patch
  • remove_Netrc_class2.patch: Fix to remove deprecated Netrc class.
  • issue6623.diff
  • 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 = 'https://github.com/berkerpeksag'
    closed_at = <Date 2014-11-01.08:52:37.284>
    created_at = <Date 2009-08-01.22:25:35.480>
    labels = ['type-feature', 'library']
    title = 'Lib/ftplib.py Netrc class should be removed.'
    updated_at = <Date 2014-11-01.08:52:37.282>
    user = 'https://bugs.python.org/vincele'

    bugs.python.org fields:

    activity = <Date 2014-11-01.08:52:37.282>
    actor = 'berker.peksag'
    assignee = 'berker.peksag'
    closed = True
    closed_date = <Date 2014-11-01.08:52:37.284>
    closer = 'berker.peksag'
    components = ['Library (Lib)']
    creation = <Date 2009-08-01.22:25:35.480>
    creator = 'vincele'
    dependencies = []
    files = ['14625', '34806', '34818', '36807']
    hgrepos = []
    issue_num = 6623
    keywords = ['patch']
    message_count = 13.0
    messages = ['91176', '91278', '182453', '182454', '216037', '216042', '216092', '216223', '227705', '227708', '228531', '230437', '230438']
    nosy_count = 6.0
    nosy_names = ['r.david.murray', 'vincele', 'python-dev', 'francismb', 'berker.peksag', 'maatt']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue6623'
    versions = ['Python 3.5']

    @vincele vincele mannequin added the stdlib Python modules in the Lib dir label Aug 1, 2009
    @vincele
    Copy link
    Mannequin Author

    vincele mannequin commented Aug 1, 2009

    The 'macro_lines' list should probably be emptied upon leaving macro
    parsing mode.

    Simplify code by using the 'macro_name' variable as the boolean for
    macro parsing mode.

    Deprecated code probably should be fixed until completely removed

    @vincele vincele mannequin changed the title Lib/ftplib.py Lib/ftplib.py netrc class parsing problem Aug 1, 2009
    @vincele
    Copy link
    Mannequin Author

    vincele mannequin commented Aug 4, 2009

    If the macro_lines is not emptied upon end of parsing a macro
    definition, if there's another macro definiton it will 'inherit' the
    lines from the previous one, which could very well be uncool.

    The use before definition should also be fixed.

    Please advise if a better fix would be to completely remove the Netrc
    class from ftplib, or replace it with a compatibility wrapper that use
    the netrc module.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Feb 19, 2013

    New changeset acf247d25f17 by R David Murray in branch 'default':
    bpo-6623: Add explicit deprecation warning for ftplib.Netrc.
    http://hg.python.org/cpython/rev/acf247d25f17

    @bitdancer
    Copy link
    Member

    bitdancer commented Feb 19, 2013

    Thanks for the report.

    ftplib.Netrc has been deprecated (via its doc string) since at least Python 2.4, and is no longer documented in the library reference. I've added an explicit DeprecationWarning in Python 3.4, and have altered this issue to call for its complete removal in Python 3.5.

    I am not planning to fix the existing code, because IMO with deprecated code this old the chance of breaking something exceeds the chance that the bad code will do harm.

    @bitdancer bitdancer changed the title Lib/ftplib.py netrc class parsing problem Lib/ftplib.py Netrc class should be removed. Feb 19, 2013
    @bitdancer bitdancer added the type-feature A feature request or enhancement label Feb 19, 2013
    @maatt
    Copy link
    Mannequin

    maatt mannequin commented Apr 13, 2014

    Created patch to remove the Netrc class and its unit tests (for Python 3.5).

    @bitdancer
    Copy link
    Member

    bitdancer commented Apr 14, 2014

    This looks good, except that if we are not going to delete that test routine (and we aren't because we didn't deprecate it :) I think we should instead replace the usage of Netrc with the netrc module.

    @maatt
    Copy link
    Mannequin

    maatt mannequin commented Apr 14, 2014

    This patch is the same as my previous one, except instead of removing Netrc usage from the ftplib.test() function, it replaces it with the netrc.netrc object. Note that there are no existing tests for the ftplib.test() function.

    Also did some very minor cleanups (bare raise is no longer valid) to get rid of warnings/errors in static analyzer.

    @bitdancer
    Copy link
    Member

    bitdancer commented Apr 14, 2014

    Did you hand test it? Also, you could open a new issue to add tests for the ftplib cli, and probably improve and document it? It was designed as a test, but some people may be using it and it might even be actually useful :)

    @francismb
    Copy link
    Mannequin

    francismb mannequin commented Sep 27, 2014

    I've downloaded 'remove_Netrc_class2.patch' and passes the test suite, the examples on the documentation run ok and manually from the command line:

    $hg tip
    changeset: 92597:e29866cb6b98
    tag: tip
    parent: 92594:d43d4d4ebf2c
    parent: 92596:54987723de99
    ...
    $ hg status
    M Lib/ftplib.py
    M Lib/test/test_ftplib.py
    ? Modules/_testembed
    $ ./python -m ftplib -d ftp.debian.org -ddebian
    *cmd* 'USER anonymous'
    *resp* '331 Please specify the password.'
    *cmd* 'PASS ****'
    *resp
    '230 Login successful.'
    *cmd
    'CWD debian'
    *resp
    '250 Directory successfully changed.'
    *cmd
    'QUIT'
    *resp
    '221 Goodbye.'

    My test '.netrc' file was:
    $ cat ~/.netrc
    machine ftp.debian.org
    login anonymous
    password anonymous

    The patch also looks good for me.

    @bitdancer
    Copy link
    Member

    bitdancer commented Sep 27, 2014

    Great. The patch looks good to me, too.

    Can someone add a What's New removal entry to the patch? (See the 3.4 What's New for a model of what removals look like in What's New.) (It would also be nice if the patch were in hg format so that we get a 'review' link, but that's not critical as I don't think we need a line-by-line review here).

    @berkerpeksag
    Copy link
    Member

    berkerpeksag commented Oct 5, 2014

    Here's a patch with a whatsnew entry.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Nov 1, 2014

    New changeset ec196a99af8d by Berker Peksag in branch 'default':
    Issue bpo-6623: Remove deprecated Netrc class in the ftplib module.
    https://hg.python.org/cpython/rev/ec196a99af8d

    @berkerpeksag
    Copy link
    Member

    berkerpeksag commented Nov 1, 2014

    Thanks for the patch, Matt. Have you signed a contributor's agreement? You can find it at https://www.python.org/psf/contrib/contrib-form/

    @berkerpeksag berkerpeksag self-assigned this Nov 1, 2014
    @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
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants