mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-06-09 17:41:36 +00:00
Address code review: use PATH_MAX buffer and move os import to top
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/da8b4577-3de8-4784-afc0-c1967f605dec Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
This commit is contained in:
parent
634c078168
commit
05b288e754
2 changed files with 5 additions and 5 deletions
|
|
@ -2653,10 +2653,11 @@ dnd_test_probe_state(PyObject *self UNUSED, PyObject *args) {
|
|||
if (mi.is_uri_list && mi.remote_items && uri_idx < mi.num_remote_items) {
|
||||
const char *name = mi.remote_items[uri_idx].dir_entry_name;
|
||||
if (name) {
|
||||
char path[4096];
|
||||
snprintf(path, sizeof(path), "%s/%zu/%s",
|
||||
char path[PATH_MAX + 1];
|
||||
int n = snprintf(path, sizeof(path), "%s/%zu/%s",
|
||||
w->drag_source.base_dir_for_remote_items, uri_idx, name);
|
||||
return PyUnicode_FromString(path);
|
||||
if (n <= 0 || (size_t)n >= sizeof(path)) Py_RETURN_NONE;
|
||||
return PyUnicode_FromStringAndSize(path, (Py_ssize_t)n);
|
||||
}
|
||||
}
|
||||
#undef mi
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
# License: GPL v3 Copyright: 2026, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import errno
|
||||
import os
|
||||
import re
|
||||
from base64 import standard_b64encode
|
||||
from contextlib import contextmanager
|
||||
|
|
@ -2934,7 +2935,6 @@ class TestDnDProtocol(BaseTest):
|
|||
self._assert_no_output(cap)
|
||||
self.assert_drag_data_complete(cap)
|
||||
# Verify the empty file was actually created on disk
|
||||
import os
|
||||
path = dnd_test_probe_state(cap.window_id, 'drag_remote_item_path:0')
|
||||
self.assertIsNotNone(path, 'empty file path should be known')
|
||||
self.assertTrue(os.path.isfile(path), f'empty file must exist on disk: {path}')
|
||||
|
|
@ -2965,7 +2965,6 @@ class TestDnDProtocol(BaseTest):
|
|||
self._assert_no_output(cap)
|
||||
self.assert_drag_data_complete(cap)
|
||||
# Verify the empty child file was actually created on disk
|
||||
import os
|
||||
dir_path = dnd_test_probe_state(cap.window_id, 'drag_remote_item_path:0')
|
||||
self.assertIsNotNone(dir_path, 'dir path should be known')
|
||||
child_path = os.path.join(dir_path, 'empty_child.txt')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue