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
7c587bf5
Kaydet (Commit)
7c587bf5
authored
Nis 19, 2010
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #8438: Remove reference to the missing "surrogateescape" encoding
error handler from the new IO library.
üst
35b76027
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
6 deletions
+30
-6
script_helper.py
Lib/test/script_helper.py
+6
-5
test_fileio.py
Lib/test/test_fileio.py
+20
-0
NEWS
Misc/NEWS
+3
-0
fileio.c
Modules/_io/fileio.c
+1
-1
No files found.
Lib/test/script_helper.py
Dosyayı görüntüle @
7c587bf5
...
...
@@ -19,11 +19,12 @@ def python_exit_code(*args):
return
subprocess
.
call
(
cmd_line
,
stdout
=
devnull
,
stderr
=
subprocess
.
STDOUT
)
def
spawn_python
(
*
args
):
def
spawn_python
(
*
args
,
**
kwargs
):
cmd_line
=
[
sys
.
executable
,
'-E'
]
cmd_line
.
extend
(
args
)
return
subprocess
.
Popen
(
cmd_line
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
,
**
kwargs
)
def
kill_python
(
p
):
p
.
stdin
.
close
()
...
...
@@ -35,11 +36,11 @@ def kill_python(p):
subprocess
.
_cleanup
()
return
data
def
run_python
(
*
args
):
def
run_python
(
*
args
,
**
kwargs
):
if
__debug__
:
p
=
spawn_python
(
*
args
)
p
=
spawn_python
(
*
args
,
**
kwargs
)
else
:
p
=
spawn_python
(
'-O'
,
*
args
)
p
=
spawn_python
(
'-O'
,
*
args
,
**
kwargs
)
stdout_data
=
kill_python
(
p
)
return
p
.
wait
(),
stdout_data
...
...
Lib/test/test_fileio.py
Dosyayı görüntüle @
7c587bf5
...
...
@@ -12,6 +12,7 @@ from functools import wraps
from
test.test_support
import
TESTFN
,
check_warnings
,
run_unittest
,
make_bad_fd
from
test.test_support
import
py3k_bytes
as
bytes
from
test.script_helper
import
run_python
from
_io
import
FileIO
as
_FileIO
...
...
@@ -397,6 +398,25 @@ class OtherFileTests(unittest.TestCase):
self
.
assertRaises
(
ValueError
,
_FileIO
,
"/some/invalid/name"
,
"rt"
)
self
.
assertEqual
(
w
.
warnings
,
[])
def
test_surrogates
(
self
):
# Issue #8438: try to open a filename containing surrogates.
# It should either fail because the file doesn't exist or the filename
# can't be represented using the filesystem encoding, but not because
# of a LookupError for the error handler "surrogateescape".
filename
=
u'
\udc80
.txt'
try
:
with
_FileIO
(
filename
):
pass
except
(
UnicodeEncodeError
,
IOError
):
pass
# Spawn a separate Python process with a different "file system
# default encoding", to exercise this further.
env
=
dict
(
os
.
environ
)
env
[
b
'LC_CTYPE'
]
=
b
'C'
_
,
out
=
run_python
(
'-c'
,
'import _io; _io.FileIO(
%
r)'
%
filename
,
env
=
env
)
if
(
'UnicodeEncodeError'
not
in
out
and
'IOError: [Errno 2] No such file or directory'
not
in
out
):
self
.
fail
(
'Bad output:
%
r'
%
out
)
def
test_main
():
# Historically, these tests have been sloppy about removing TESTFN.
...
...
Misc/NEWS
Dosyayı görüntüle @
7c587bf5
...
...
@@ -20,6 +20,9 @@ Core and Builtins
Library
-------
- Issue #8438: Remove reference to the missing "surrogateescape" encoding
error handler from the new IO library.
- Issue #3817: ftplib.FTP.abort() method now considers 225 a valid response
code as stated in RFC-959 at chapter 5.4.
...
...
Modules/_io/fileio.c
Dosyayı görüntüle @
7c587bf5
...
...
@@ -248,7 +248,7 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
return
-
1
;
stringobj
=
PyUnicode_AsEncodedString
(
u
,
Py_FileSystemDefaultEncoding
,
"surrogateescape"
);
u
,
Py_FileSystemDefaultEncoding
,
NULL
);
Py_DECREF
(
u
);
if
(
stringobj
==
NULL
)
return
-
1
;
...
...
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