diff options
author | Andrew Svetlov <andrew.svetlov@gmail.com> | 2012-12-24 11:15:43 (GMT) |
---|---|---|
committer | Andrew Svetlov <andrew.svetlov@gmail.com> | 2012-12-24 11:15:43 (GMT) |
commit | 8a495a48a53369120e7ca3b57efe9a07745ea067 (patch) | |
tree | eb0f056072f7b3890c7deaf2237eed1e2f8ea6b4 /Lib/idlelib/FormatParagraph.py | |
parent | 159bb53765c895abb701d20881f13468484a9dba (diff) | |
download | cpython-8a495a48a53369120e7ca3b57efe9a07745ea067.zip cpython-8a495a48a53369120e7ca3b57efe9a07745ea067.tar.gz cpython-8a495a48a53369120e7ca3b57efe9a07745ea067.tar.bz2 |
Issue #16511: Use default IDLE width and height if config param is not valid.
Patch Serhiy Storchaka.
Diffstat (limited to 'Lib/idlelib/FormatParagraph.py')
-rw-r--r-- | Lib/idlelib/FormatParagraph.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/idlelib/FormatParagraph.py b/Lib/idlelib/FormatParagraph.py index 6a5f9b5..e3ca7b9 100644 --- a/Lib/idlelib/FormatParagraph.py +++ b/Lib/idlelib/FormatParagraph.py @@ -32,7 +32,8 @@ class FormatParagraph: self.editwin = None def format_paragraph_event(self, event): - maxformatwidth = int(idleConf.GetOption('main','FormatParagraph','paragraph')) + maxformatwidth = int(idleConf.GetOption('main', 'FormatParagraph', + 'paragraph', type='int')) text = self.editwin.text first, last = self.editwin.get_selection_indices() if first and last: @@ -46,7 +47,8 @@ class FormatParagraph: lines = data.split("\n") lines = map(lambda st, l=len(comment_header): st[l:], lines) data = "\n".join(lines) - # Reformat to maxformatwidth chars or a 20 char width, whichever is greater. + # Reformat to maxformatwidth chars or a 20 char width, + # whichever is greater. format_width = max(maxformatwidth - len(comment_header), 20) newdata = reformat_paragraph(data, format_width) # re-split and re-insert the comment header. |