[New-bugs-announce] [issue18151] Idlelib: update to "with open ... except OSError" (in 2.7, leave IOError)

Terry J. Reedy report at bugs.python.org
Thu Jun 6 19:02:32 CEST 2013


New submission from Terry J. Reedy:

This issue is about uniformly updating the old idiom

try:
  f = open('file')
  <use f)
  f.close()  # omitted at least in GrepDialog
except IOError as msg:
  <ignore or display message>

to the current idiom

try:
  with open('file') as f:
    <use f
except OSError as msg:  # still use IOError in 2.7
    <ignore or display message>

#16715 changed 'IOError' to 'OSError' everywhere in Lib/* for 3.4 only.

I ran into this issue (again) because GrepDialog.Grepdialog.grep_it uses open without close. Consequently, with debug builds, 'Find in files' raises a ResourceWarning for each file opened. Because of the 3.4-only change, there will be a merge conflict.

To avoid this, now and in the future, I plan to backport the idlelib subset of the Svetlov's patch to 3.3 (it applied with only one fix).

Currently, all 3.x patches are being applied to both 3.3 and 3.4 and any 3.3 patch with 'IOError' will have a merge conflict. Any 3.4 patch with 'OSError' will not apply to 3.3. There is no longer an issue with breaking 3.2 to 3.3 merges. This change will break existing 3.3 patches with 'IOError', but they would break anyway on the merge.

----------
components: IDLE
files: idle33.io2os.diff
keywords: patch
messages: 190718
nosy: Todd.Rovito, roger.serwy, terry.reedy
priority: normal
severity: normal
stage: commit review
status: open
title: Idlelib: update to "with open ... except OSError"  (in 2.7, leave IOError)
type: behavior
versions: Python 2.7, Python 3.3, Python 3.4
Added file: http://bugs.python.org/file30485/idle33.io2os.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18151>
_______________________________________


More information about the New-bugs-announce mailing list