Skip to content

Commit b3c8121

Browse files
committed
fix(js), bypass(NIM-BUG): nim 2.2.4/2.3.1 disallows NonVarDestructor when js
... though defined nimAllowNonVarDestructor
1 parent 2e76c43 commit b3c8121

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/pylib/Lib/n_tempfile.nim

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,13 @@ proc close*(self: TemporaryDirectoryWrapper) =
297297
try: self.cleanup()
298298
except Exception: discard
299299

300-
when (NimMajor, NimMinor, NimPatch) >= (2, 1, 1):
300+
template sinceNim(ma, mi, pa): bool =
301+
(NimMajor, NimMinor, NimPatch) >= (ma, mi, pa)
302+
const Js = defined(js)
303+
when not Js and sinceNim(2,1,1) or
304+
Js and sinceNim(2,3,2):
301305
## XXX: FIXED-NIM-BUG: though nimAllowNonVarDestructor is defined at least since 2.0.6,
302-
## it still cannot be compiled till abour 2.1.1
306+
## it still cannot be compiled till about 2.1.1
303307
proc `=destroy`*(self: TemporaryDirectoryWrapper) = self.close()
304308
else:
305309
proc `=destroy`*(self: var TemporaryDirectoryWrapper) = self.close()

src/pylib/Lib/sys_impl/auditImpl/yesImpl.nim

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,13 @@ proc PySys_ClearAuditHooks() =
106106
try: PySys_Audit(ClearAuditHooksName)
107107
except Exception: discard
108108

109-
when (NimMajor, NimMinor, NimPatch) >= (2, 1, 1):
109+
template sinceNim(ma, mi, pa): bool =
110+
(NimMajor, NimMinor, NimPatch) >= (ma, mi, pa)
111+
const Js = defined(js)
112+
when not Js and sinceNim(2,1,1) or
113+
Js and sinceNim(2,3,2):
110114
## XXX: FIXED-NIM-BUG: though nimAllowNonVarDestructor is defined at least since 2.0.6,
111-
## it still cannot be compiled till abour 2.1.1
115+
## it still cannot be compiled till about 2.1.1
112116
proc `=destroy`*(self: PyRuntimeState) = PySys_ClearAuditHooks()
113117
else:
114118
proc `=destroy`*(self: var PyRuntimeState) = PySys_ClearAuditHooks()

0 commit comments

Comments
 (0)