Skip to content

IDLE, configdialog: Factor out FontTab class from ConfigDialog #75187

Closed

Description

@terryjreedy
BPO 31004
Nosy @terryjreedy, @vstinner, @csabella
PRs
  • bpo-31004: IDLE: Factor out FontPage class from configdialog (step 1) #2905
  • [3.6] bpo-31004: IDLE: Factor out FontPage class from configdialog (s… #2950
  • Dependencies
  • bpo-30853: IDLE: configdialog -- factor out VarTrace class
  • 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/terryjreedy'
    closed_at = <Date 2017-07-30.19:35:34.203>
    created_at = <Date 2017-07-24.08:03:45.840>
    labels = ['expert-IDLE', 'type-feature', '3.7']
    title = 'IDLE, configdialog: Factor out FontTab class from ConfigDialog'
    updated_at = <Date 2017-08-07.15:26:32.282>
    user = 'https://github.com/terryjreedy'

    bugs.python.org fields:

    activity = <Date 2017-08-07.15:26:32.282>
    actor = 'terry.reedy'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2017-07-30.19:35:34.203>
    closer = 'terry.reedy'
    components = ['IDLE']
    creation = <Date 2017-07-24.08:03:45.840>
    creator = 'terry.reedy'
    dependencies = ['30853']
    files = []
    hgrepos = []
    issue_num = 31004
    keywords = []
    message_count = 15.0
    messages = ['298933', '299279', '299362', '299367', '299414', '299432', '299452', '299489', '299490', '299503', '299508', '299514', '299835', '299836', '299851']
    nosy_count = 3.0
    nosy_names = ['terry.reedy', 'vstinner', 'cheryl.sabella']
    pr_nums = ['2905', '2950']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue31004'
    versions = ['Python 3.6', 'Python 3.7']

    Activity

    1. terryjreedy commented on Jul 24, 2017

      @terryjreedy
      MemberAuthor

      I want to follow the safe way to refactor (from a blog post), rather than the hacker way of refactoring 'in place'.
      Step 0: Test code to be refactored. Finished in 30993.

      Step 1: Copy code to be refactored and modify as needed to isolate it from the working original. For configdialog, add 'class FontPage' below ConfigDialog and copy font/tab methods, now collected together, below that. For the test, copy class FontTest as FontPageTest and IndentTest as IndentOptionTest. The copies should pass as they will still be testing the original code. Commit.

      Step 2: Modify code as desired. Modify test copy to test code copy. For FontPage, this will require new tracer manager (bpo-30853) to attach (activate) callbacks so tests will pass. Commit.

      Step 3: Switch from using original code to using modified code. For this issue, calling FontPage instead of create_page_font_tab may be enough. Skip original test; modify new test as needed to pass. Commit.

      Step 4: Once we are sure that we do not need the original code that has been replaced, delete it. Rerun tests. Commit.

      The separate commits will make review easier. Create or update PRs as desired.

    2. self-assigned this
      on Jul 24, 2017
    3. added
      type-feature
      on Jul 24, 2017
    4. csabella commented on Jul 27, 2017

      @csabella
      Contributor

      PR is for step 1 since VarTrace is needed for step 2.

    5. terryjreedy commented on Jul 28, 2017

      @terryjreedy
      MemberAuthor

      I may have changed the Font group since the copy was made. So unless merges since are carefully checked, the configdialog part of Step 1 should be redone. I think the latter would be easier.

      Since bpo-30853 might be merged tomorrow, I will 'freeze' the font/indent code unless I hear otherwise, or there is an unexpected delay. When this is merged, I will do the same for the general part. And so on.

      In Step 2, delete 'Modify code as desired.' I must have forgotten the synchonization problem. We don't want to modify the copy until it can be htested. As soon as the copy *is* changed, the original is no longer a complete backup.

      I thought of saying that FontPage should subclass Frame, like we have done before. But TabbedPageSet creates a Frame for each page name. So ConfigDialog, the only user, is expected to pass names, then retrieve the blank frames to fill in. We could change that, but not now unless we really need to. It should be possible to replace the blank frame, but there are at least two references to replace.

    6. terryjreedy commented on Jul 28, 2017

      @terryjreedy
      MemberAuthor

      For steps 2 and 3, setUpClass will have to create or retrieve a reverence to the page class instance. For page functions, 'dialog' will have to be changed to 'self.page'. For hightlight and key pages, I will write the tests using 'self.page', which would start as a synonym for 'dialog' (set in setUpClass). I might convert GeneralTest before you copy it.

    7. csabella commented on Jul 28, 2017

      @csabella
      Contributor

      OK, once 30853 is merged, I'll recopy the font code into the class.

      On Fri, Jul 28, 2017 at 2:06 AM, Terry J. Reedy <report@bugs.python.org>
      wrote:

      Terry J. Reedy added the comment:

      For steps 2 and 3, setUpClass will have to create or retrieve a reverence
      to the page class instance. For page functions, 'dialog' will have to be
      changed to 'self.page'. For hightlight and key pages, I will write the
      tests using 'self.page', which would start as a synonym for 'dialog' (set
      in setUpClass). I might convert GeneralTest before you copy it.

      ----------


      Python tracker <report@bugs.python.org>
      <http://bugs.python.org/issue31004\>


    8. terryjreedy commented on Jul 28, 2017

      @terryjreedy
      MemberAuthor

      When replying by email, snip the quote.

    9. terryjreedy commented on Jul 29, 2017

      @terryjreedy
      MemberAuthor

      I will push Notebook when CI passes. We can then do Step 2 for class FontPage(Frame). Consider the font code frozen for now. Pass 'note', not the dialog, as the parent. This makes tab switching work better.

      Create the highlight frame first and pass it as a second argument to FontPage. Adding set_samples to load_font_config should solve the initial font problem.

    10. csabella commented on Jul 30, 2017

      @csabella
      Contributor

      I'm pushing step 2 with an error in the test. It's on the keydown in test_fontlist_key. I just didn't want to hold you up from looking at the rest of it because of one test.

      I did run into a bunch of other issues/questions while doing this. I didn't add tracers.attach() to the FontPage class. So, I had to call it in the FontPageTest. Well, I then also added a detach so it wouldn't carry to the other tests and of course all the other tests broke. So, I added setup/teardown of tracers in all the test classes. I don't know if that was the right way to go or if adding tracers.attach to FontPage and then just leaving everything attached would be ok.

      Also, I tried to minimize the change from d=dialog to d = self.page, so I kept the name d.

      Adding set_samples to load_font_cfg upped the called count to 4 in test_load_font_cfg because the tracers are attached when it's called. I think you mentioned that test needs to be changed with them detached, but I wasn't sure if you wanted that changed now or later.

      In FontPage, I tried not to change code yet, so I keep the name parent even though note will be passed in.

    11. terryjreedy commented on Jul 30, 2017

      @terryjreedy
      MemberAuthor

      I am going to work on this now. Tracers should be on for the duration of the test class except for the load test. d = self.page is what I planned initially.

      Argument note is bound to parameter parent and that will remain the name.

      The one error I see in PageFont before testing is adding or leaving "frame = Frame(self.parent)". Now that FontPage is a frame, 'frame = self' (we can later replace 'frame' with 'self' as the parent argument in calls that follow).

    12. terryjreedy commented on Jul 30, 2017

      @terryjreedy
      MemberAuthor

      New changeset 9397e2a by Terry Jan Reedy (csabella) in branch 'master':
      bpo-31004: IDLE: Factor out FontPage class from configdialog (step 1) (bpo-2905)
      9397e2a

    13. terryjreedy commented on Jul 30, 2017

      @terryjreedy
      MemberAuthor

      New changeset 7582226 by Terry Jan Reedy in branch '3.6':
      [3.6] bpo-31004: IDLE: Factor out FontPage class from configdialog (step 1) (GH-2905) (bpo-2950)
      7582226

    14. terryjreedy commented on Jul 30, 2017

      @terryjreedy
      MemberAuthor

      At last! On to the next one.

    15. vstinner commented on Aug 7, 2017

      @vstinner
      Member

      New changeset 9397e2a by Terry Jan Reedy (csabella) in branch 'master':
      bpo-31004: IDLE: Factor out FontPage class from configdialog (step 1) (bpo-2905)

      This change introduced reference leaks in test_idle: see bpo-31130.

    16. vstinner commented on Aug 7, 2017

      @vstinner
      Member

      By the way, I suggest to not backport refactoring changes to stable branches like Python 3.6. Any refactoring is a risk of regressions. Well, it's just an advice, Terry knows IDLE much better than me ;-) It's up to you to decide to backport or not such change.

    17. terryjreedy commented on Aug 7, 2017

      @terryjreedy
      MemberAuthor

      Idlelib is a bit exceptional: see PEP-434. Except for one test and the news files, I keep idlelib identical in 3.6 and 3.7. This makes all backports, *including new tests*, trivial and overall reduces the risk of regression (unless IDLE 3.6 were abandoned completely). The risk of regression is why I have only touched 3.6/7 since last Fall, why I am increasingly strict about testing, and why I will manually test everything at least a few days before the next release candidate.

    18. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    3.7 (EOL)topic-IDLEtype-feature

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions