-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix improper method call mktemp #2195
Fix improper method call mktemp #2195
Conversation
Signed-off-by: fazledyn-or <[email protected]>
Signed-off-by: fazledyn-or <[email protected]>
Hi, Thanks a lot your contribution. changing the mktemp method makes sense. Can you elaborate on the problem with the file descriptor? |
Certainly! In Linux, each processes are allocated 1024 file descriptors by default. Among those, 0 to 2 are assigned to For example - from tempfile import mkstemp
def call_mkstemp():
fd, name = mkstemp()
for i in range(1100):
print(i, end=", ")
call_mkstemp() Executing this code will result in an error when the 1022nd file desciptor is asked to be opened. Since the |
Thanks @fazledyn-or |
Is it okay to be merged? |
It is fine by me, @samuelgarcia , anything you remember about why that descriptor is open? I don't know whether you or @alejoe91 ported that code. |
Hi. |
I'm afraid that there's no context manager available for
with tempfile.NamedTemporaryFile() as temp:
temp.write('Some data')
temp.flush()
from tempfile import mkstemp
fd, name = mkstemp()
with open(fd, "w") as f:
f.write("something")
References |
Let's merge this but change to context with |
Thanks for your contribution @fazledyn-or! |
Details
While triaging your project, our bug fixing tool generated the following message(s)-
Resources Related to
mktemp
Changes
mktemp()
method withmkstemp()
spikeinterface/src/spikeinterface/extractors/mdaextractors.py
Previously Found & Fixed
CLA Requirements
This section is only relevant if your project requires contributors to sign a Contributor License Agreement (CLA) for external contributions.
All contributed commits are already automatically signed off.
Sponsorship and Support
This work is done by the security researchers from OpenRefactory and is supported by the Open Source Security Foundation (OpenSSF): Project Alpha-Omega. Alpha-Omega is a project partnering with open source software project maintainers to systematically find new, as-yet-undiscovered vulnerabilities in open source code - and get them fixed – to improve global software supply chain security.
The bug is found by running the Intelligent Code Repair (iCR) tool by OpenRefactory and then manually triaging the results.