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
932ff836
Kaydet (Commit)
932ff836
authored
Agu 01, 2013
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #18608: Avoid keeping a strong reference to the locale module inside the _io module.
üst
2d350fd8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
27 deletions
+51
-27
NEWS
Misc/NEWS
+3
-0
_iomodule.c
Modules/_io/_iomodule.c
+25
-0
_iomodule.h
Modules/_io/_iomodule.h
+2
-0
textio.c
Modules/_io/textio.c
+21
-27
No files found.
Misc/NEWS
Dosyayı görüntüle @
932ff836
...
@@ -179,6 +179,9 @@ Core and Builtins
...
@@ -179,6 +179,9 @@ Core and Builtins
Library
Library
-------
-------
-
Issue
#
18608
:
Avoid
keeping
a
strong
reference
to
the
locale
module
inside
the
_io
module
.
-
Issue
#
18619
:
Fix
atexit
leaking
callbacks
registered
from
sub
-
interpreters
,
-
Issue
#
18619
:
Fix
atexit
leaking
callbacks
registered
from
sub
-
interpreters
,
and
make
it
GC
-
aware
.
and
make
it
GC
-
aware
.
...
...
Modules/_io/_iomodule.c
Dosyayı görüntüle @
932ff836
...
@@ -533,6 +533,31 @@ _PyIO_ConvertSsize_t(PyObject *obj, void *result) {
...
@@ -533,6 +533,31 @@ _PyIO_ConvertSsize_t(PyObject *obj, void *result) {
}
}
PyObject
*
_PyIO_get_locale_module
(
_PyIO_State
*
state
)
{
PyObject
*
mod
;
if
(
state
->
locale_module
!=
NULL
)
{
assert
(
PyWeakref_CheckRef
(
state
->
locale_module
));
mod
=
PyWeakref_GET_OBJECT
(
state
->
locale_module
);
if
(
mod
!=
Py_None
)
{
Py_INCREF
(
mod
);
return
mod
;
}
Py_CLEAR
(
state
->
locale_module
);
}
mod
=
PyImport_ImportModule
(
"locale"
);
if
(
mod
==
NULL
)
return
NULL
;
state
->
locale_module
=
PyWeakref_NewRef
(
mod
,
NULL
);
if
(
state
->
locale_module
==
NULL
)
{
Py_DECREF
(
mod
);
return
NULL
;
}
return
mod
;
}
static
int
static
int
iomodule_traverse
(
PyObject
*
mod
,
visitproc
visit
,
void
*
arg
)
{
iomodule_traverse
(
PyObject
*
mod
,
visitproc
visit
,
void
*
arg
)
{
_PyIO_State
*
state
=
IO_MOD_STATE
(
mod
);
_PyIO_State
*
state
=
IO_MOD_STATE
(
mod
);
...
...
Modules/_io/_iomodule.h
Dosyayı görüntüle @
932ff836
...
@@ -137,6 +137,8 @@ typedef struct {
...
@@ -137,6 +137,8 @@ typedef struct {
#define IO_MOD_STATE(mod) ((_PyIO_State *)PyModule_GetState(mod))
#define IO_MOD_STATE(mod) ((_PyIO_State *)PyModule_GetState(mod))
#define IO_STATE IO_MOD_STATE(PyState_FindModule(&_PyIO_Module))
#define IO_STATE IO_MOD_STATE(PyState_FindModule(&_PyIO_Module))
extern
PyObject
*
_PyIO_get_locale_module
(
_PyIO_State
*
);
extern
PyObject
*
_PyIO_str_close
;
extern
PyObject
*
_PyIO_str_close
;
extern
PyObject
*
_PyIO_str_closed
;
extern
PyObject
*
_PyIO_str_closed
;
extern
PyObject
*
_PyIO_str_decode
;
extern
PyObject
*
_PyIO_str_decode
;
...
...
Modules/_io/textio.c
Dosyayı görüntüle @
932ff836
...
@@ -917,35 +917,29 @@ textiowrapper_init(textio *self, PyObject *args, PyObject *kwds)
...
@@ -917,35 +917,29 @@ textiowrapper_init(textio *self, PyObject *args, PyObject *kwds)
}
}
}
}
if
(
encoding
==
NULL
&&
self
->
encoding
==
NULL
)
{
if
(
encoding
==
NULL
&&
self
->
encoding
==
NULL
)
{
if
(
state
->
locale_module
==
NULL
)
{
PyObject
*
locale_module
=
_PyIO_get_locale_module
(
state
);
state
->
locale_module
=
PyImport_ImportModule
(
"locale"
);
if
(
locale_module
==
NULL
)
if
(
state
->
locale_module
==
NULL
)
goto
catch_ImportError
;
goto
catch_ImportError
;
self
->
encoding
=
_PyObject_CallMethodId
(
else
locale_module
,
&
PyId_getpreferredencoding
,
"O"
,
Py_False
);
goto
use_locale
;
Py_DECREF
(
locale_module
);
}
if
(
self
->
encoding
==
NULL
)
{
else
{
catch_ImportError:
use_locale:
/*
self
->
encoding
=
_PyObject_CallMethodId
(
Importing locale can raise a ImportError because of
state
->
locale_module
,
&
PyId_getpreferredencoding
,
"O"
,
Py_False
);
_functools, and locale.getpreferredencoding can raise a
if
(
self
->
encoding
==
NULL
)
{
ImportError if _locale is not available. These will happen
catch_ImportError:
during module building.
/*
*/
Importing locale can raise a ImportError because of
if
(
PyErr_ExceptionMatches
(
PyExc_ImportError
))
{
_functools, and locale.getpreferredencoding can raise a
PyErr_Clear
();
ImportError if _locale is not available. These will happen
self
->
encoding
=
PyUnicode_FromString
(
"ascii"
);
during module building.
*/
if
(
PyErr_ExceptionMatches
(
PyExc_ImportError
))
{
PyErr_Clear
();
self
->
encoding
=
PyUnicode_FromString
(
"ascii"
);
}
else
goto
error
;
}
}
else
if
(
!
PyUnicode_Check
(
self
->
encoding
))
else
Py_CLEAR
(
self
->
encoding
)
;
goto
error
;
}
}
else
if
(
!
PyUnicode_Check
(
self
->
encoding
))
Py_CLEAR
(
self
->
encoding
);
}
}
if
(
self
->
encoding
!=
NULL
)
{
if
(
self
->
encoding
!=
NULL
)
{
encoding
=
_PyUnicode_AsString
(
self
->
encoding
);
encoding
=
_PyUnicode_AsString
(
self
->
encoding
);
...
...
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