Skip to content

Commit

Permalink
Fix: NULL-terminating path
Browse files Browse the repository at this point in the history
  • Loading branch information
ashvardanian committed Mar 18, 2024
1 parent f35793a commit 7c910bf
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ The `Str` class has `write_to` to write the string to a file, and `offset_within
web_archieve = Str("<html>...</html><html>...</html>")
_, end_tag, next_doc = web_archieve.partition("</html>") # or use `find`
next_doc_offset = next_doc.offset_within(web_archieve)
web_archieve.write_to("next_doc.html")
web_archieve.write_to("next_doc.html") # no GIL, no copies, just a view
```

#### PyArrow
Expand Down
1 change: 1 addition & 0 deletions python/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,7 @@ static PyObject *Str_write_to(PyObject *self, PyObject *args, PyObject *kwargs)
return NULL;
}
memcpy(path_buffer, path.start, path.length);
path_buffer[path.length] = '\0';

// Unlock the Global Interpreter Lock (GIL) to allow other threads to run
// while the current thread is waiting for the file to be written.
Expand Down
2 changes: 1 addition & 1 deletion scripts/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_unit_buffer_protocol():

def test_str_write_to():
native = "line1\nline2\nline3"
big = Str(native) # Assuming Str is your custom class
big = Str(native)

# Create a temporary file
with tempfile.NamedTemporaryFile(delete=False) as tmpfile:
Expand Down

0 comments on commit 7c910bf

Please sign in to comment.