Skip to content

Commit ea97961

Browse files
committed
Removing usage of deprecated Py_FileSystemDefaultEncoding
1 parent 730414b commit ea97961

File tree

5 files changed

+10
-11
lines changed

5 files changed

+10
-11
lines changed

src/object.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ PyDoc_STRVAR(Object_type_str__doc__,
126126
PyObject *
127127
Object_type_str__get__(Object *self)
128128
{
129-
return to_path(git_object_type2string(Object__type(self)));
129+
return PyUnicode_DecodeFSDefault(git_object_type2string(Object__type(self)));
130130
}
131131

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

149-
return to_path(git_tree_entry_name(self->entry));
149+
return PyUnicode_DecodeFSDefault(git_tree_entry_name(self->entry));
150150
}
151151

152152
PyDoc_STRVAR(Object_raw_name__doc__, "Name (bytes).");

src/pygit2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ discover_repository(PyObject *self, PyObject *args)
130130
if (err < 0)
131131
return Error_set_str(err, path);
132132

133-
py_repo_path = to_path(repo_path.ptr);
133+
py_repo_path = PyUnicode_DecodeFSDefault(repo_path.ptr);
134134
git_buf_dispose(&repo_path);
135135

136136
return py_repo_path;

src/reference.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ Reference_target__get__(Reference *self)
297297
if (ret != NULL)
298298
return ret;
299299
if (c_name != NULL)
300-
return to_path(c_name);
300+
return PyUnicode_DecodeFSDefault(c_name);
301301
return NULL;
302302
}
303303

@@ -392,7 +392,7 @@ PyObject *
392392
Reference_name__get__(Reference *self)
393393
{
394394
CHECK_REFERENCE(self);
395-
return to_path(git_reference_name(self->reference));
395+
return PyUnicode_DecodeFSDefault(git_reference_name(self->reference));
396396
}
397397

398398
PyDoc_STRVAR(Reference_raw_name__doc__, "The full name of the reference (Bytes).");
@@ -411,7 +411,7 @@ PyObject *
411411
Reference_shorthand__get__(Reference *self)
412412
{
413413
CHECK_REFERENCE(self);
414-
return to_path(git_reference_shorthand(self->reference));
414+
return PyUnicode_DecodeFSDefault(git_reference_shorthand(self->reference));
415415
}
416416

417417
PyDoc_STRVAR(Reference_raw_shorthand__doc__,

src/repository.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ Repository_path__get__(Repository *self, void *closure)
466466
if (c_path == NULL)
467467
Py_RETURN_NONE;
468468

469-
return to_path(c_path);
469+
return PyUnicode_DecodeFSDefault(c_path);
470470
}
471471

472472

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

486-
return to_path(c_path);
486+
return PyUnicode_DecodeFSDefault(c_path);
487487
}
488488

489489
int
@@ -1274,7 +1274,7 @@ Repository_create_branch(Repository *self, PyObject *args)
12741274

12751275
static PyObject *
12761276
to_path_f(const char * x) {
1277-
return to_path(x);
1277+
return PyUnicode_DecodeFSDefault(x);
12781278
}
12791279

12801280
PyDoc_STRVAR(Repository_raw_listall_references__doc__,
@@ -2171,7 +2171,7 @@ Repository_list_worktrees(Repository *self, PyObject *args)
21712171

21722172
/* Fill it */
21732173
for (index=0; index < c_result.count; index++) {
2174-
py_string = to_path(c_result.strings[index]);
2174+
py_string = PyUnicode_DecodeFSDefault(c_result.strings[index]);
21752175
if (py_string == NULL) {
21762176
Py_CLEAR(py_result);
21772177
goto out;

src/utils.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
#define Py_FileSystemDefaultEncodeErrors "surrogateescape"
4444
#endif
4545

46-
#define to_path(x) to_unicode(x, Py_FileSystemDefaultEncoding, "strict")
4746
#define to_encoding(x) PyUnicode_DecodeASCII(x, strlen(x), "strict")
4847

4948

0 commit comments

Comments
 (0)