From 772fca56c4d727c8394d7d564b9b3b7008771488 Mon Sep 17 00:00:00 2001 From: litlighilit Date: Mon, 6 May 2024 10:11:02 +0800 Subject: [PATCH] fix(patch): Lib/tempfile: v1 destory non-var --- src/pylib/Lib/tempfile.nim | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/pylib/Lib/tempfile.nim b/src/pylib/Lib/tempfile.nim index d5b6a3555..03c27692f 100644 --- a/src/pylib/Lib/tempfile.nim +++ b/src/pylib/Lib/tempfile.nim @@ -107,9 +107,14 @@ proc newTemporaryFileCloser(file: IOBase, name: string, delete=True): TemporaryF result.close_called = false -proc `=destroy`*(self: TemporaryFileCloser) = + +template destoryImpl = try: self.close() except Exception: discard +when NimMajor == 1: + proc `=destroy`*(self: var TemporaryFileCloser) = destoryImpl +else: + proc `=destroy`*(self: TemporaryFileCloser) = destoryImpl proc NamedTemporaryFile*(mode="w+b", buffering = -1, encoding=DefEncoding, newline=DefNewLine, suffix=sNone, prefix=sNone, @@ -174,5 +179,7 @@ proc close*(self: TemporaryDirectoryWrapper) = try: self.cleanup() except Exception: discard -proc `=destroy`*(self: TemporaryDirectoryWrapper) = - self.close() +when NimMajor == 1: + proc `=destroy`*(self: var TemporaryDirectoryWrapper) = self.close() +else: + proc `=destroy`*(self: TemporaryDirectoryWrapper) = self.close()