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
24d262af
Kaydet (Commit)
24d262af
authored
May 25, 2015
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
(Merge 3.5) Issue #23840: tokenize.open() now closes the temporary binary file
on error to fix a resource warning.
üst
e6efbdc9
387729e1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
6 deletions
+21
-6
test_tokenize.py
Lib/test/test_tokenize.py
+9
-1
tokenize.py
Lib/tokenize.py
+9
-5
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_tokenize.py
Dosyayı görüntüle @
24d262af
...
@@ -834,7 +834,7 @@ from tokenize import (tokenize, _tokenize, untokenize, NUMBER, NAME, OP,
...
@@ -834,7 +834,7 @@ from tokenize import (tokenize, _tokenize, untokenize, NUMBER, NAME, OP,
STRING
,
ENDMARKER
,
ENCODING
,
tok_name
,
detect_encoding
,
STRING
,
ENDMARKER
,
ENCODING
,
tok_name
,
detect_encoding
,
open
as
tokenize_open
,
Untokenizer
)
open
as
tokenize_open
,
Untokenizer
)
from
io
import
BytesIO
from
io
import
BytesIO
from
unittest
import
TestCase
from
unittest
import
TestCase
,
mock
import
os
,
sys
,
glob
import
os
,
sys
,
glob
import
token
import
token
...
@@ -1246,6 +1246,14 @@ class TestDetectEncoding(TestCase):
...
@@ -1246,6 +1246,14 @@ class TestDetectEncoding(TestCase):
ins
=
Bunk
(
lines
,
path
)
ins
=
Bunk
(
lines
,
path
)
detect_encoding
(
ins
.
readline
)
detect_encoding
(
ins
.
readline
)
def
test_open_error
(
self
):
# Issue #23840: open() must close the binary file on error
m
=
BytesIO
(
b
'#coding:xxx'
)
with
mock
.
patch
(
'tokenize._builtin_open'
,
return_value
=
m
):
self
.
assertRaises
(
SyntaxError
,
tokenize_open
,
'foobar'
)
self
.
assertTrue
(
m
.
closed
)
class
TestTokenize
(
TestCase
):
class
TestTokenize
(
TestCase
):
...
...
Lib/tokenize.py
Dosyayı görüntüle @
24d262af
...
@@ -435,11 +435,15 @@ def open(filename):
...
@@ -435,11 +435,15 @@ def open(filename):
detect_encoding().
detect_encoding().
"""
"""
buffer
=
_builtin_open
(
filename
,
'rb'
)
buffer
=
_builtin_open
(
filename
,
'rb'
)
encoding
,
lines
=
detect_encoding
(
buffer
.
readline
)
try
:
buffer
.
seek
(
0
)
encoding
,
lines
=
detect_encoding
(
buffer
.
readline
)
text
=
TextIOWrapper
(
buffer
,
encoding
,
line_buffering
=
True
)
buffer
.
seek
(
0
)
text
.
mode
=
'r'
text
=
TextIOWrapper
(
buffer
,
encoding
,
line_buffering
=
True
)
return
text
text
.
mode
=
'r'
return
text
except
:
buffer
.
close
()
raise
def
tokenize
(
readline
):
def
tokenize
(
readline
):
...
...
Misc/NEWS
Dosyayı görüntüle @
24d262af
...
@@ -323,6 +323,9 @@ Core and Builtins
...
@@ -323,6 +323,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #23840: tokenize.open() now closes the temporary binary file on error
to fix a resource warning.
- Issue #16914: new debuglevel 2 in smtplib adds timestamps to debug output.
- Issue #16914: new debuglevel 2 in smtplib adds timestamps to debug output.
- Issue #7159: urllib.request now supports sending auth credentials
- Issue #7159: urllib.request now supports sending auth credentials
...
...
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