[issue13286] PEP 3151 breaks backward compatibility: it should be documented

New submission from STINNER Victor <victor.stinner@haypocalc.com>: The following example works on Python 2.7 and 3.2, but fails on Python 3.3: ----------- import errno import os try: os.rmdir("testdir") except: pass os.mkdir("testdir") try: try: os.mkdir("testdir") except IOError as exc: # If can't get proper access, then just forget about writing # the data. if exc.errno == errno.EACCES: pass else: raise except OSError as exc: # Probably another Python process already created the dir. if exc.errno == errno.EEXIST: pass else: raise except Exception: print("PEP 3151 broke backward compatibility on such pattern!") ----------- I noticed the problem while reading the changeset e4d44c2e8e81. ---------- assignee: docs@python components: Documentation messages: 146562 nosy: docs@python, flox, haypo, pitrou priority: normal severity: normal status: open title: PEP 3151 breaks backward compatibility: it should be documented versions: Python 3.3 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13286> _______________________________________

Antoine Pitrou <pitrou@free.fr> added the comment: Why would you catch IOError after os.mkdir()? ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13286> _______________________________________

STINNER Victor <victor.stinner@haypocalc.com> added the comment: The first example was extracted from Lib/importlib/_bootstrap.py. The code was maybe wrong, I don't know. Another example: ---------------------- import errno import os try: os.rmdir("testdir") except: pass os.mkdir("testdir") try: try: #os.mkdir("testdir") open("NOT EXISTING FILENAME") except OSError as exc: if exc.errno == errno.EEXIST: pass else: raise except IOError as exc: if exc.errno == errno.ENOENT: pass else: raise except Exception: raise print("PEP 3151 broke backward compatibility on such pattern!") ---------------------- Uncomment mkdir() to test both paths. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13286> _______________________________________

Changes by Florent Xicluna <florent.xicluna@gmail.com>: ---------- stage: -> needs patch type: -> behavior _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13286> _______________________________________

Changes by Éric Araujo <merwok@netwok.org>: ---------- nosy: +eric.araujo _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13286> _______________________________________

STINNER Victor <victor.stinner@haypocalc.com> added the comment: The code was fixed in importlib. I don't think that this borderline case should be documented anywhere, so I close this issue. ---------- resolution: -> wont fix status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13286> _______________________________________

Change by Matthias Bussonnier <bussonniermatthias@gmail.com>: ---------- pull_requests: +13194 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue13286> _______________________________________

Change by STINNER Victor <vstinner@redhat.com>: ---------- pull_requests: -13194 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue13286> _______________________________________

Change by Matthias Bussonnier <bussonniermatthias@gmail.com>: ---------- pull_requests: +13197 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue13286> _______________________________________

Antoine Pitrou <pitrou@free.fr> added the comment: Why would you catch IOError after os.mkdir()? ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13286> _______________________________________

STINNER Victor <victor.stinner@haypocalc.com> added the comment: The first example was extracted from Lib/importlib/_bootstrap.py. The code was maybe wrong, I don't know. Another example: ---------------------- import errno import os try: os.rmdir("testdir") except: pass os.mkdir("testdir") try: try: #os.mkdir("testdir") open("NOT EXISTING FILENAME") except OSError as exc: if exc.errno == errno.EEXIST: pass else: raise except IOError as exc: if exc.errno == errno.ENOENT: pass else: raise except Exception: raise print("PEP 3151 broke backward compatibility on such pattern!") ---------------------- Uncomment mkdir() to test both paths. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13286> _______________________________________

Changes by Florent Xicluna <florent.xicluna@gmail.com>: ---------- stage: -> needs patch type: -> behavior _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13286> _______________________________________

Changes by Éric Araujo <merwok@netwok.org>: ---------- nosy: +eric.araujo _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13286> _______________________________________

STINNER Victor <victor.stinner@haypocalc.com> added the comment: The code was fixed in importlib. I don't think that this borderline case should be documented anywhere, so I close this issue. ---------- resolution: -> wont fix status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13286> _______________________________________

Change by Matthias Bussonnier <bussonniermatthias@gmail.com>: ---------- pull_requests: +13194 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue13286> _______________________________________

Change by STINNER Victor <vstinner@redhat.com>: ---------- pull_requests: -13194 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue13286> _______________________________________

Change by Matthias Bussonnier <bussonniermatthias@gmail.com>: ---------- pull_requests: +13197 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue13286> _______________________________________
participants (5)
-
Antoine Pitrou
-
Florent Xicluna
-
Matthias Bussonnier
-
STINNER Victor
-
Éric Araujo