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

"Print window" menu on IDLE aborts whole application #56483

Closed
ggenellina mannequin opened this issue Jun 7, 2011 · 7 comments
Closed

"Print window" menu on IDLE aborts whole application #56483

ggenellina mannequin opened this issue Jun 7, 2011 · 7 comments
Labels
topic-IDLE type-bug An unexpected behavior, bug, or error

Comments

@ggenellina
Copy link
Mannequin

ggenellina mannequin commented Jun 7, 2011

BPO 12274
Nosy @terryjreedy, @kbkaiser, @ambv
Dependencies
  • bpo-15392: Create a unittest framework for IDLE
  • 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 2016-10-05.10:26:41.982>
    created_at = <Date 2011-06-07.06:16:07.104>
    labels = ['expert-IDLE', 'type-bug']
    title = '"Print window" menu on IDLE aborts whole application'
    updated_at = <Date 2016-10-05.10:26:41.981>
    user = 'https://bugs.python.org/ggenellina'

    bugs.python.org fields:

    activity = <Date 2016-10-05.10:26:41.981>
    actor = 'berker.peksag'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-10-05.10:26:41.982>
    closer = 'berker.peksag'
    components = ['IDLE']
    creation = <Date 2011-06-07.06:16:07.104>
    creator = 'ggenellina'
    dependencies = ['15392']
    files = []
    hgrepos = []
    issue_num = 12274
    keywords = []
    message_count = 7.0
    messages = ['137789', '137790', '137823', '137825', '220036', '220054', '228257']
    nosy_count = 6.0
    nosy_names = ['terry.reedy', 'kbk', 'ggenellina', 'BreamoreBoy', 'lukasz.langa', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue12274'
    versions = ['Python 3.2', 'Python 3.3']

    @ggenellina
    Copy link
    Mannequin Author

    ggenellina mannequin commented Jun 7, 2011

    On Windows, IDLE closes all open windows and exits completely, without any error message, when selecting the "Print window" menu command.

    Starting IDLE from inside a console, one can see the error message:

    Exception in Tkinter callback
    Traceback (most recent call last):
      File "D:\apps\python32\lib\tkinter\__init__.py", line 1399, in __call__
        return self.func(*args)
      File "D:\apps\python32\lib\idlelib\IOBinding.py", line 453, in print_window
        command = idleConf.GetOption('main','General','print-command-win')
      File "D:\apps\python32\lib\idlelib\configHandler.py", line 245, in GetOption
        type=type, raw=raw)
      File "D:\apps\python32\lib\idlelib\configHandler.py", line 54, in Get
        return self.get(section, option, raw=raw)
      File "D:\apps\python32\lib\configparser.py", line 789, in get
        d)
      File "D:\apps\python32\lib\configparser.py", line 391, in before_get
        self._interpolate_some(parser, option, L, value, section, defaults, 1)
      File "D:\apps\python32\lib\configparser.py", line 440, in _interpolate_some
        "found: %r" % (rest,))
    configparser.InterpolationSyntaxError: '%' must be followed by '%' or '(', found
    : '%s'

    It is trying to read this entry from the config-main.def file:

    [General]
    print-command-posix=lpr %s
    print-command-win=start /min notepad /p %s

    For a ConfigParser file, those %s should be %%s instead. Previous IDLE versions (2.7 and 3.1) read the same entry without problem; I suspect they were using a RawConfigParser or processing the entry in a different way.

    As a workaround, replacing %s with %%s in config-main.def is enough, until the code gets fixed.

    @ggenellina ggenellina mannequin added topic-IDLE type-bug An unexpected behavior, bug, or error labels Jun 7, 2011
    @ggenellina
    Copy link
    Mannequin Author

    ggenellina mannequin commented Jun 7, 2011

    Note: There is a much bigger problem here: IDLE should not abort abruptly in such cases, without any error indication.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jun 7, 2011

    New changeset 0aa3064d1cef by Łukasz Langa in branch '3.2':
    bpo-12274: use proper escaping for % in IDLE config.
    http://hg.python.org/cpython/rev/0aa3064d1cef

    New changeset b410d013e7a8 by Łukasz Langa in branch 'default':
    bpo-12274: use proper escaping for % in IDLE config (merged from 3.2).
    http://hg.python.org/cpython/rev/b410d013e7a8

    @ambv
    Copy link
    Contributor

    ambv commented Jun 7, 2011

    In 3.2 configparser started validating syntax in interpolation-aware parsers by default. I fixed the configuration.

    It's unfortunate this configuration error hasn't been caught before in testing. We need a unit test for broken configuration and a change in IDLE so that it doesn't silently crash when configuration is invalid.

    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jun 8, 2014

    Can this be closed as a patch has been committed and the unittest framework was created on bpo-15392 ?

    @terryjreedy
    Copy link
    Member

    This issue needs a unittest test added within the framework. I opened bpo-21696 as a dependency. Since configx.def files can be edited, and, I believe, at least one is intended to be edited, configHandler should perhaps catch exceptions and display in a messagebox. But unless Idle could continue after that, that might wait for the general fix, which is another issue.

    @terryjreedy
    Copy link
    Member

    Closing since the immediate problem has been fixed and there is a reference to this in bpo-21696

    @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
    topic-IDLE type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants