Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
a0fdd72f
Kaydet (Commit)
a0fdd72f
authored
Agu 17, 2008
tarafından
Hirokazu Yamamoto
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #2222: Fixed reference leak when occured os.rename()
fails unicode conversion on 2nd parameter. (windows only)
üst
047e4a91
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
28 deletions
+26
-28
posixmodule.c
Modules/posixmodule.c
+26
-28
No files found.
Modules/posixmodule.c
Dosyayı görüntüle @
a0fdd72f
...
...
@@ -478,24 +478,18 @@ static PyObject *_PyUnicode_FromFileSystemEncodedObject(register PyObject *obj)
{
}
/* Function suitable for O& conversion */
static int
convert_to_unicode
(
PyObject
*
arg
,
void
*
_
param
)
convert_to_unicode(PyObject *
*
param)
{
PyObject
**
param
=
(
PyObject
**
)
_param
;
if
(
PyUnicode_CheckExact
(
arg
))
{
Py_INCREF
(
arg
);
*
param
=
arg
;
}
else
if
(
PyUnicode_Check
(
arg
))
{
if (PyUnicode_CheckExact(*param))
Py_INCREF(*param);
else if (PyUnicode_Check(*param))
/* For a Unicode subtype that's not a Unicode object,
return a true Unicode object with the same data. */
*
param
=
PyUnicode_FromUnicode
(
PyUnicode_AS_UNICODE
(
arg
),
PyUnicode_GET_SIZE
(
arg
));
return
*
param
!=
NULL
;
}
*param = PyUnicode_FromUnicode(PyUnicode_AS_UNICODE(*param),
PyUnicode_GET_SIZE(*param));
else
*
param
=
PyUnicode_FromEncodedObject
(
arg
,
*param = PyUnicode_FromEncodedObject(
*param
,
Py_FileSystemDefaultEncoding,
"strict");
return (*param) != NULL;
...
...
@@ -2542,22 +2536,26 @@ posix_rename(PyObject *self, PyObject *args)
char *p1, *p2;
BOOL result;
if (unicode_file_names()) {
if
(
!
PyArg_ParseTuple
(
args
,
"O&O&:rename"
,
convert_to_unicode
,
&
o1
,
convert_to_unicode
,
&
o2
))
PyErr_Clear
();
else
{
Py_BEGIN_ALLOW_THREADS
result
=
MoveFileW
(
PyUnicode_AsUnicode
(
o1
),
PyUnicode_AsUnicode
(
o2
));
Py_END_ALLOW_THREADS
Py_DECREF
(
o1
);
Py_DECREF
(
o2
);
if
(
!
result
)
return
win32_error
(
"rename"
,
NULL
);
Py_INCREF
(
Py_None
);
return
Py_None
;
if (!PyArg_ParseTuple(args, "OO:rename", &o1, &o2))
goto error;
if (!convert_to_unicode(&o1))
goto error;
if (!convert_to_unicode(&o2)) {
Py_DECREF(o1);
goto error;
}
Py_BEGIN_ALLOW_THREADS
result = MoveFileW(PyUnicode_AsUnicode(o1),
PyUnicode_AsUnicode(o2));
Py_END_ALLOW_THREADS
Py_DECREF(o1);
Py_DECREF(o2);
if (!result)
return win32_error("rename", NULL);
Py_INCREF(Py_None);
return Py_None;
error:
PyErr_Clear();
}
if (!PyArg_ParseTuple(args, "ss:rename", &p1, &p2))
return NULL;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment