Closed jeremyevans closed 10 months ago
@hsbt Can you please review and merge this (or let me know who would be better to review)?
@nobu Looks like I don't have commit access to the tempfile repository. Could you review and merge?
@jeremyevans Sorry that. I added write access to you for this repository.
@hsbt Thank you!
Instead of storing the delegate in @tmpfile, use getobj, since delegate library already handles dup/clone for that. Copy the unlinked, mode, and opts instance variables to the returned object when using dup/clone.
Split the close/unlink finalizer into two finalizers. The close finalizer always closes when any Tempfile instance is GCed, since each Tempfile instance uses a separate file descriptor. The unlink finalizer unlinks only when the original and all duped/cloned Tempfiles are GCed, since all share the same path.
For Tempfile#open, undefine the close finalizer after closing the current file, the redefine the close finalizer with the new file.
Fixes [Bug #19441]