Issue 13286: PEP 3151 breaks backward compatibility: it should be documented (original) (raw)

Issue13286

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

This issue has been migrated to GitHub: https://github.com/python/cpython/issues/57495

classification

Title: PEP 3151 breaks backward compatibility: it should be documented
Type: behavior Stage: needs patch
Components: Documentation Versions: Python 3.3

process

Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, eric.araujo, flox, pitrou, vstinner
Priority: normal Keywords:

Created on 2011-10-28 14:18 by vstinner, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 13287 merged mbussonn,2019-05-13 16:08
Messages (4)
msg146562 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-10-28 14:18
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.
msg146563 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-10-28 14:24
Why would you catch IOError after os.mkdir()?
msg146565 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-10-28 14:32
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.
msg152821 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2012-02-07 23:44
The code was fixed in importlib. I don't think that this borderline case should be documented anywhere, so I close this issue.
History
Date User Action Args
2022-04-11 14:57:23 admin set github: 57495
2019-05-13 16:08:51 mbussonn set pull_requests: + <pull%5Frequest13197>
2019-05-13 15:39:15 vstinner set pull_requests: - <pull%5Frequest13194>
2019-05-13 15:36:14 mbussonn set pull_requests: + <pull%5Frequest13194>
2012-02-07 23:44:28 vstinner set status: open -> closedresolution: wont fixmessages: +
2011-11-12 13:48:19 eric.araujo set nosy: + eric.araujo
2011-10-28 20:55:48 flox set type: behaviorstage: needs patch
2011-10-28 14:32:52 vstinner set messages: +
2011-10-28 14:24:34 pitrou set messages: +
2011-10-28 14🔞50 vstinner create