Skip to content

Commit

Permalink
fix(patch): Lib/tempfile: v1 destory non-var
Browse files Browse the repository at this point in the history
  • Loading branch information
litlighilit committed May 6, 2024
1 parent ef653eb commit 772fca5
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/pylib/Lib/tempfile.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()

0 comments on commit 772fca5

Please sign in to comment.