Skip to content

Commit 9592833

Browse files
committed
Create separate warning type for tempdir
1 parent ac3e973 commit 9592833

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

devtools/browser.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
from .pipe import PipeClosedError
2222

23+
class TempDirWarning(UserWarning):
24+
pass
2325
class UnhandledMessageWarning(UserWarning):
2426
pass
2527

@@ -210,7 +212,10 @@ def finish_close(self):
210212
self.temp_dir.cleanup()
211213
clean=True
212214
except Exception as e:
213-
print(str(e))
215+
if platform.system() == "Windows" and not self.debug:\
216+
pass
217+
else:
218+
warnings.warn(str(e)), TempDirWarning)
214219

215220
# windows+old vers doesn't like python's default cleanup
216221

@@ -231,12 +236,12 @@ def remove_readonly(func, path, excinfo):
231236
except PermissionError:
232237
if not clean:
233238
warnings.warn(
234-
"The temporary directory could not be deleted, due to permission error, execution will continue."
239+
"The temporary directory could not be deleted, due to permission error, execution will continue.", TempDirWarning
235240
)
236241
except Exception as e:
237242
if not clean:
238243
warnings.warn(
239-
f"The temporary directory could not be deleted, execution will continue. {type(e)}: {e}"
244+
f"The temporary directory could not be deleted, execution will continue. {type(e)}: {e}", TempDirWarning
240245
)
241246

242247
def sync_process_close(self):

0 commit comments

Comments
 (0)