mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-03-24 07:20:12 +01:00
Override the __close
metamethod of FILE*
objects
This enables the use of a Lua 5.4 feature where you can have Lua auto-close a file when exiting a block. For example: ``` do local f <close> = kobold.get_config_file() end ``` If we exit from the `do` block under any circumstances, including via an error or return statement, the `FILE*` `f` automatically closes right before that happens.
This commit is contained in:
parent
796c71b7f7
commit
a580f18a14
@ -279,6 +279,7 @@ return function(_python, _bridged)
|
||||
end
|
||||
end
|
||||
debug.getmetatable(io.stdout).__index.close = _new_close(io.stdout.close)
|
||||
debug.getmetatable(io.stdout).__close = _new_close(io.stdout.close)
|
||||
|
||||
---@param filename string
|
||||
---@return boolean
|
||||
|
Loading…
x
Reference in New Issue
Block a user