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

Allow dircmp.subdirs to behave well under subclassing #59655

Closed
cjerdonek opened this issue Jul 26, 2012 · 7 comments
Closed

Allow dircmp.subdirs to behave well under subclassing #59655

cjerdonek opened this issue Jul 26, 2012 · 7 comments
Labels
3.10 only security fixes easy stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@cjerdonek
Copy link
Member

BPO 15450
Nosy @asvetlov, @mitar, @cjerdonek, @hynek, @NickCrews
PRs
  • bpo-15450: Allow subclassing of dircmp #5088
  • bpo-15450: Allow subclassing of filecmp.dircmp #23424
  • Files
  • issue-15450-failing-test.patch
  • issue-15450-1.patch
  • issue-15450-2.patch
  • 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 2020-11-23.16:31:26.651>
    created_at = <Date 2012-07-26.00:00:03.204>
    labels = ['easy', 'type-feature', 'library', '3.10']
    title = 'Allow dircmp.subdirs to behave well under subclassing'
    updated_at = <Date 2020-11-23.16:31:26.650>
    user = 'https://github.com/cjerdonek'

    bugs.python.org fields:

    activity = <Date 2020-11-23.16:31:26.650>
    actor = 'asvetlov'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-11-23.16:31:26.651>
    closer = 'asvetlov'
    components = ['Library (Lib)']
    creation = <Date 2012-07-26.00:00:03.204>
    creator = 'chris.jerdonek'
    dependencies = []
    files = ['26531', '26532', '26551']
    hgrepos = []
    issue_num = 15450
    keywords = ['patch', 'easy']
    message_count = 7.0
    messages = ['166443', '166503', '166505', '166507', '166618', '381490', '381677']
    nosy_count = 7.0
    nosy_names = ['eli.bendersky', 'asvetlov', 'mitar', 'chris.jerdonek', 'hynek', 'cbc', 'NickCrews']
    pr_nums = ['5088', '23424']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue15450'
    versions = ['Python 3.10']

    @cjerdonek
    Copy link
    Member Author

    Currently, the subdirs attribute of filecmp.dircmp does not respect subclassing:

    >>> from filecmp import dircmp
    >>> class MyDirCmp(dircmp):
    ...   pass
    ... 
    >>> my_dcmp = MyDirCmp('dir1', 'dir2')
    >>> for item in my_dcmp.subdirs.values():
    ...   print(type(item))
    ...   break
    ... 
    <class 'filecmp.dircmp'>

    This is the only place where dircmp does not respect subclassing. It can be corrected here:

    def phase4(self): # Find out differences between common subdirectories
        ...
            ...
            self.subdirs[x]  = dircmp(a_x, b_x, self.ignore, self.hide)

    This would let one do things like override dircmp.report() and have dircmp.report_full_closure() behave as expected.

    @cjerdonek cjerdonek added stdlib Python modules in the Lib dir easy type-feature A feature request or enhancement labels Jul 26, 2012
    @cjerdonek
    Copy link
    Member Author

    Adding a patch with a failing test for the issue.

    @cjerdonek
    Copy link
    Member Author

    Attaching full patch (though Misc/NEWS would need to be moved a new section is created for pre-alpha).

    @cjerdonek
    Copy link
    Member Author

    Actually, this should also be documented.

    @cjerdonek
    Copy link
    Member Author

    Updating patch to include documentation changes.

    @NickCrews
    Copy link
    Mannequin

    NickCrews mannequin commented Nov 20, 2020

    I re-did this at #23424, let me know what you think. This is my first PR here, so I may have pooched something.

    @asvetlov
    Copy link
    Contributor

    New changeset 2f2f9d0 by Nick Crews in branch 'master':
    bpo-15450: Allow subclassing of dircmp (GH-23424) (bpo-23424)
    2f2f9d0

    @asvetlov asvetlov added the 3.10 only security fixes label Nov 23, 2020
    @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.10 only security fixes easy 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