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
7c82a3e0
Kaydet (Commit)
7c82a3e0
authored
Eyl 05, 2001
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Patch #449815: Set filesystemencoding based on CODESET.
üst
044d95e9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
3 deletions
+40
-3
api.tex
Doc/api/api.tex
+5
-1
test_unicode_file.py
Lib/test/test_unicode_file.py
+15
-1
_localemodule.c
Modules/_localemodule.c
+20
-1
No files found.
Doc/api/api.tex
Dosyayı görüntüle @
7c82a3e0
...
...
@@ -3020,7 +3020,11 @@ errors. These parameters encoding and errors have the same semantics
as the ones of the builtin unicode() Unicode object constructor.
Setting encoding to NULL causes the default encoding to be used which
is UTF-8.
is
\ASCII
{}
. The file system calls should use
\var
{
Py
_
FileSystemDefaultEncoding
}
as the encoding for file
names. This variable should be treated as read-only: On some systems,
it will be a pointer to a static string, on others, it will change at
run-time, e.g. when the application invokes setlocale.
Error handling is set by errors which may also be set to NULL meaning
to use the default handling defined for the codec. Default error
...
...
Lib/test/test_unicode_file.py
Dosyayı görüntüle @
7c82a3e0
...
...
@@ -6,8 +6,20 @@ import os
from
test_support
import
verify
,
TestSkipped
,
TESTFN_UNICODE
try
:
from
test_support
import
TESTFN_ENCODING
oldlocale
=
None
except
ImportError
:
raise
TestSkipped
(
"No Unicode filesystem semantics on this platform."
)
import
locale
# try to run the test in an UTF-8 locale. If this locale is not
# available, avoid running the test since the locale's encoding
# might not support TESTFN_UNICODE. Likewise, if the system does
# not support locale.CODESET, Unicode file semantics is not
# available, either.
oldlocale
=
locale
.
setlocale
(
locale
.
LC_CTYPE
)
try
:
locale
.
setlocale
(
locale
.
LC_CTYPE
,
"en_US.UTF-8"
)
TESTFN_ENCODING
=
locale
.
nl_langinfo
(
locale
.
CODESET
)
except
(
locale
.
Error
,
AttributeError
):
raise
TestSkipped
(
"No Unicode filesystem semantics on this platform."
)
TESTFN_ENCODED
=
TESTFN_UNICODE
.
encode
(
TESTFN_ENCODING
)
...
...
@@ -79,3 +91,5 @@ finally:
os
.
chdir
(
cwd
)
os
.
rmdir
(
abs_encoded
)
print
"All the Unicode tests appeared to work"
if
oldlocale
:
locale
.
setlocale
(
locale
.
LC_CTYPE
,
oldlocale
)
Modules/_localemodule.c
Dosyayı görüntüle @
7c82a3e0
...
...
@@ -153,7 +153,10 @@ fixup_ulcase(void)
PyDict_SetItemString
(
string
,
"letters"
,
ulo
);
Py_DECREF
(
ulo
);
}
#if defined(HAVE_LANGINFO_H) && defined(CODESET)
static
int
fileencoding_uses_locale
=
0
;
#endif
static
PyObject
*
PyLocale_setlocale
(
PyObject
*
self
,
PyObject
*
args
)
...
...
@@ -203,6 +206,22 @@ PyLocale_setlocale(PyObject* self, PyObject* args)
fixup_ulcase
();
/* things that got wrong up to here are ignored */
PyErr_Clear
();
#if defined(HAVE_LANGINFO_H) && defined(CODESET)
if
(
Py_FileSystemDefaultEncoding
==
NULL
)
fileencoding_uses_locale
=
1
;
if
(
fileencoding_uses_locale
)
{
char
*
codeset
=
nl_langinfo
(
CODESET
);
PyObject
*
enc
=
NULL
;
if
(
*
codeset
&&
(
enc
=
PyCodec_Encoder
(
codeset
)))
{
/* Release previous file encoding */
if
(
Py_FileSystemDefaultEncoding
)
free
(
Py_FileSystemDefaultEncoding
);
Py_FileSystemDefaultEncoding
=
strdup
(
codeset
);
Py_DECREF
(
enc
);
}
else
PyErr_Clear
();
}
#endif
}
else
{
/* get locale */
/* restore LC_NUMERIC first, if appropriate */
...
...
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