Skip to content

Commit

Permalink
Removing usage of deprecated Py_FileSystemDefaultEncoding
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavid committed Mar 29, 2024
1 parent 730414b commit ea97961
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ PyDoc_STRVAR(Object_type_str__doc__,
PyObject *
Object_type_str__get__(Object *self)
{
return to_path(git_object_type2string(Object__type(self)));
return PyUnicode_DecodeFSDefault(git_object_type2string(Object__type(self)));
}

PyDoc_STRVAR(Object__pointer__doc__, "Get the object's pointer. For internal use only.");
Expand All @@ -146,7 +146,7 @@ Object_name__get__(Object *self)
if (self->entry == NULL)
Py_RETURN_NONE;

return to_path(git_tree_entry_name(self->entry));
return PyUnicode_DecodeFSDefault(git_tree_entry_name(self->entry));
}

PyDoc_STRVAR(Object_raw_name__doc__, "Name (bytes).");
Expand Down
2 changes: 1 addition & 1 deletion src/pygit2.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ discover_repository(PyObject *self, PyObject *args)
if (err < 0)
return Error_set_str(err, path);

py_repo_path = to_path(repo_path.ptr);
py_repo_path = PyUnicode_DecodeFSDefault(repo_path.ptr);
git_buf_dispose(&repo_path);

return py_repo_path;
Expand Down
6 changes: 3 additions & 3 deletions src/reference.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ Reference_target__get__(Reference *self)
if (ret != NULL)
return ret;
if (c_name != NULL)
return to_path(c_name);
return PyUnicode_DecodeFSDefault(c_name);
return NULL;
}

Expand Down Expand Up @@ -392,7 +392,7 @@ PyObject *
Reference_name__get__(Reference *self)
{
CHECK_REFERENCE(self);
return to_path(git_reference_name(self->reference));
return PyUnicode_DecodeFSDefault(git_reference_name(self->reference));
}

PyDoc_STRVAR(Reference_raw_name__doc__, "The full name of the reference (Bytes).");
Expand All @@ -411,7 +411,7 @@ PyObject *
Reference_shorthand__get__(Reference *self)
{
CHECK_REFERENCE(self);
return to_path(git_reference_shorthand(self->reference));
return PyUnicode_DecodeFSDefault(git_reference_shorthand(self->reference));
}

PyDoc_STRVAR(Reference_raw_shorthand__doc__,
Expand Down
8 changes: 4 additions & 4 deletions src/repository.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ Repository_path__get__(Repository *self, void *closure)
if (c_path == NULL)
Py_RETURN_NONE;

return to_path(c_path);
return PyUnicode_DecodeFSDefault(c_path);
}


Expand All @@ -483,7 +483,7 @@ Repository_workdir__get__(Repository *self, void *closure)
if (c_path == NULL)
Py_RETURN_NONE;

return to_path(c_path);
return PyUnicode_DecodeFSDefault(c_path);
}

int
Expand Down Expand Up @@ -1274,7 +1274,7 @@ Repository_create_branch(Repository *self, PyObject *args)

static PyObject *
to_path_f(const char * x) {
return to_path(x);
return PyUnicode_DecodeFSDefault(x);
}

PyDoc_STRVAR(Repository_raw_listall_references__doc__,
Expand Down Expand Up @@ -2171,7 +2171,7 @@ Repository_list_worktrees(Repository *self, PyObject *args)

/* Fill it */
for (index=0; index < c_result.count; index++) {
py_string = to_path(c_result.strings[index]);
py_string = PyUnicode_DecodeFSDefault(c_result.strings[index]);
if (py_string == NULL) {
Py_CLEAR(py_result);
goto out;
Expand Down
1 change: 0 additions & 1 deletion src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#define Py_FileSystemDefaultEncodeErrors "surrogateescape"
#endif

#define to_path(x) to_unicode(x, Py_FileSystemDefaultEncoding, "strict")
#define to_encoding(x) PyUnicode_DecodeASCII(x, strlen(x), "strict")


Expand Down

0 comments on commit ea97961

Please sign in to comment.