jenkins-bot submitted this change.

View Change

Approvals: Chico Venancio: Looks good to me, but someone else must approve Xqt: Looks good to me, approved jenkins-bot: Verified
[bugfix] Only ignore FileExistsError when creating the api cache

Bug: T295924
Change-Id: Ib2e83060857e748ddf56a019d9fd615c6ed9a229
---
M pywikibot/data/api.py
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 2cf5144..acde07e 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -12,8 +12,8 @@
import pprint
import re
import traceback
+
from collections.abc import Container, MutableMapping, Sized
-from contextlib import suppress
from email.generator import BytesGenerator
from email.mime.multipart import MIMEMultipart as MIMEMultipartOrig
from email.mime.nonmultipart import MIMENonMultipart
@@ -1933,13 +1933,14 @@
def _make_dir(dir_name: str) -> str:
"""Create directory if it does not exist already.

- The directory name (dir_name) is returned unmodified.
+ .. versionchanged:: 7.0
+ Only `FileExistsError` is ignored but other OS exceptions can
+ be still raised

:param dir_name: directory path
- :return: directory name
+ :return: unmodified directory name for test purpose
"""
- with suppress(OSError): # directory already exists
- os.makedirs(dir_name)
+ os.makedirs(dir_name, exist_ok=True)
return dir_name

def _uniquedescriptionstr(self) -> str:

To view, visit change 740297. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ib2e83060857e748ddf56a019d9fd615c6ed9a229
Gerrit-Change-Number: 740297
Gerrit-PatchSet: 6
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Chico Venancio <chicocvenancio@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999@gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged