Skip to content

Commit 632544f

Browse files
Remove static pystr (#333)
oneliner to get rid of global state
2 parents 58e68f6 + 8828409 commit 632544f

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/duckdb_py/pyfilesystem.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,12 @@ void PythonFilesystem::CreateDirectory(const string &directory, optional_ptr<Fil
223223
}
224224
bool PythonFilesystem::ListFiles(const string &directory, const std::function<void(const string &, bool)> &callback,
225225
FileOpener *opener) {
226-
static py::str DIRECTORY("directory");
227-
228226
D_ASSERT(!py::gil_check());
229227
PythonGILWrapper gil;
230228
bool nonempty = false;
231229

232230
for (auto item : filesystem.attr("ls")(py::str(directory))) {
233-
bool is_dir = DIRECTORY.equal(item["type"]);
231+
bool is_dir = py::cast<std::string>(item["type"]) == "directory";
234232
callback(py::str(item["name"]), is_dir);
235233
nonempty = true;
236234
}

0 commit comments

Comments
 (0)