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
815b41b1
Kaydet (Commit)
815b41b1
authored
Şub 28, 2014
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #20731: Properly position in source code files even if they
are opened in text mode. Patch by Serhiy Storchaka.
üst
9db1ab82
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
3 deletions
+29
-3
.hgeol
.hgeol
+2
-0
coding20731.py
Lib/test/coding20731.py
+4
-0
test_coding.py
Lib/test/test_coding.py
+8
-1
NEWS
Misc/NEWS
+3
-0
tokenizer.c
Parser/tokenizer.c
+12
-2
No files found.
.hgeol
Dosyayı görüntüle @
815b41b1
...
...
@@ -37,6 +37,8 @@ Lib/test/xmltestdata/* = BIN
Lib/venv/scripts/nt/* = BIN
Lib/test/coding20731.py = BIN
# All other files (which presumably are human-editable) are "native".
# This must be the last rule!
...
...
Lib/test/coding20731.py
0 → 100644
Dosyayı görüntüle @
815b41b1
#coding:latin1
Lib/test/test_coding.py
Dosyayı görüntüle @
815b41b1
import
unittest
from
test.support
import
TESTFN
,
unlink
,
unload
import
importlib
,
os
,
sys
import
importlib
,
os
,
sys
,
subprocess
class
CodingTest
(
unittest
.
TestCase
):
def
test_bad_coding
(
self
):
...
...
@@ -58,6 +58,13 @@ class CodingTest(unittest.TestCase):
self
.
assertTrue
(
c
.
exception
.
args
[
0
]
.
startswith
(
expected
),
msg
=
c
.
exception
.
args
[
0
])
def
test_20731
(
self
):
sub
=
subprocess
.
Popen
([
sys
.
executable
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'coding20731.py'
)],
stderr
=
subprocess
.
PIPE
)
err
=
sub
.
communicate
()[
1
]
self
.
assertEquals
(
err
,
b
''
)
if
__name__
==
"__main__"
:
unittest
.
main
()
Misc/NEWS
Dosyayı görüntüle @
815b41b1
...
...
@@ -10,6 +10,9 @@ What's New in Python 3.3.5 release candidate 1?
Core and Builtins
-----------------
- Issue #20731: Properly position in source code files even if they
are opened in text mode. Patch by Serhiy Storchaka.
- Issue #19619: str.encode, bytes.decode and bytearray.decode now use an
internal API to throw LookupError for known non-text encodings, rather
than attempting the encoding or decoding operation and then throwing a
...
...
Parser/tokenizer.c
Dosyayı görüntüle @
815b41b1
...
...
@@ -498,9 +498,13 @@ fp_setreadl(struct tok_state *tok, const char* enc)
fd
=
fileno
(
tok
->
fp
);
/* Due to buffering the file offset for fd can be different from the file
* position of tok->fp. */
* position of tok->fp. If tok->fp was opened in text mode on Windows,
* its file position counts CRLF as one char and can't be directly mapped
* to the file offset for fd. Instead we step back one byte and read to
* the end of line.*/
pos
=
ftell
(
tok
->
fp
);
if
(
pos
==
-
1
||
lseek
(
fd
,
(
off_t
)
pos
,
SEEK_SET
)
==
(
off_t
)
-
1
)
{
if
(
pos
==
-
1
||
lseek
(
fd
,
(
off_t
)(
pos
>
0
?
pos
-
1
:
pos
),
SEEK_SET
)
==
(
off_t
)
-
1
)
{
PyErr_SetFromErrnoWithFilename
(
PyExc_OSError
,
NULL
);
goto
cleanup
;
}
...
...
@@ -513,6 +517,12 @@ fp_setreadl(struct tok_state *tok, const char* enc)
Py_XDECREF
(
tok
->
decoding_readline
);
readline
=
_PyObject_GetAttrId
(
stream
,
&
PyId_readline
);
tok
->
decoding_readline
=
readline
;
if
(
pos
>
0
)
{
if
(
PyObject_CallObject
(
readline
,
NULL
)
==
NULL
)
{
readline
=
NULL
;
goto
cleanup
;
}
}
cleanup:
Py_XDECREF
(
stream
);
...
...
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