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
b8142c3e
Kaydet (Commit)
b8142c3e
authored
May 08, 2007
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Got test_exceptions.py working.
üst
74302dbd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
18 deletions
+21
-18
pickle.py
Lib/pickle.py
+3
-3
test_exceptions.py
Lib/test/test_exceptions.py
+18
-15
No files found.
Lib/pickle.py
Dosyayı görüntüle @
b8142c3e
...
...
@@ -929,12 +929,12 @@ class Unpickler:
break
else
:
raise
ValueError
,
"insecure string pickle"
self
.
append
(
rep
.
decode
(
"string-escape"
))
self
.
append
(
str8
(
rep
.
decode
(
"string-escape"
)
))
dispatch
[
STRING
[
0
]]
=
load_string
def
load_binstring
(
self
):
len
=
mloads
(
b
'i'
+
self
.
read
(
4
))
self
.
append
(
s
elf
.
read
(
len
))
self
.
append
(
s
tr8
(
self
.
read
(
len
)
))
dispatch
[
BINSTRING
[
0
]]
=
load_binstring
def
load_unicode
(
self
):
...
...
@@ -948,7 +948,7 @@ class Unpickler:
def
load_short_binstring
(
self
):
len
=
ord
(
self
.
read
(
1
))
self
.
append
(
s
elf
.
read
(
len
))
self
.
append
(
s
tr8
(
self
.
read
(
len
)
))
dispatch
[
SHORT_BINSTRING
[
0
]]
=
load_short_binstring
def
load_tuple
(
self
):
...
...
Lib/test/test_exceptions.py
Dosyayı görüntüle @
b8142c3e
...
...
@@ -251,17 +251,19 @@ class ExceptionTests(unittest.TestCase):
'print_file_and_line'
:
None
,
'msg'
:
'msgStr'
,
'filename'
:
None
,
'lineno'
:
None
,
'offset'
:
None
}),
(
UnicodeError
,
(),
{
'message'
:
''
,
'args'
:
(),}),
(
UnicodeEncodeError
,
(
str8
(
'ascii'
),
'a'
,
0
,
1
,
str8
(
'ordinal not in range'
)),
(
UnicodeEncodeError
,
(
str8
(
'ascii'
),
'a'
,
0
,
1
,
str8
(
'ordinal not in range'
)),
{
'message'
:
''
,
'args'
:
(
'ascii'
,
'a'
,
0
,
1
,
'ordinal not in range'
),
'encoding'
:
'ascii'
,
'object'
:
'a'
,
'start'
:
0
,
'reason'
:
'ordinal not in range'
}),
(
UnicodeDecodeError
,
(
str8
(
'ascii'
),
b
'
\xff
'
,
0
,
1
,
str8
(
'ordinal not in range'
)),
{
'message'
:
''
,
'args'
:
(
'ascii'
,
'
\xff
'
,
0
,
1
,
(
UnicodeDecodeError
,
(
str8
(
'ascii'
),
b
'
\xff
'
,
0
,
1
,
str8
(
'ordinal not in range'
)),
{
'message'
:
''
,
'args'
:
(
'ascii'
,
b
'
\xff
'
,
0
,
1
,
'ordinal not in range'
),
'encoding'
:
'ascii'
,
'object'
:
'
\xff
'
,
'encoding'
:
'ascii'
,
'object'
:
b
'
\xff
'
,
'start'
:
0
,
'reason'
:
'ordinal not in range'
}),
(
UnicodeTranslateError
,
(
"
\u3042
"
,
0
,
1
,
"ouch"
),
(
UnicodeTranslateError
,
(
"
\u3042
"
,
0
,
1
,
str8
(
"ouch"
)
),
{
'message'
:
''
,
'args'
:
(
'
\u3042
'
,
0
,
1
,
'ouch'
),
'object'
:
'
\u3042
'
,
'reason'
:
'ouch'
,
'start'
:
0
,
'end'
:
1
}),
...
...
@@ -278,27 +280,28 @@ class ExceptionTests(unittest.TestCase):
for
exc
,
args
,
expected
in
exceptionList
:
try
:
print
(
"exc=
%
r, args=
%
r"
%
(
exc
,
args
)
)
raise
exc
(
*
args
)
except
BaseException
as
e
:
if
type
(
e
)
is
not
exc
:
raise
e
=
exc
(
*
args
)
except
:
print
(
"
\n
exc=
%
r, args=
%
r"
%
(
exc
,
args
))
raise
else
:
# Verify module name
self
.
assertEquals
(
type
(
e
)
.
__module__
,
'__builtin__'
)
# Verify no ref leaks in Exc_str()
s
=
str
(
e
)
for
checkArgName
in
expected
:
self
.
assertEquals
(
repr
(
getattr
(
e
,
checkArgName
)),
value
=
getattr
(
e
,
checkArgName
)
self
.
assertEquals
(
repr
(
value
),
repr
(
expected
[
checkArgName
]),
'exception "
%
s", attribute "
%
s"'
%
(
repr
(
e
),
checkArgName
))
'
%
r.
%
s ==
%
r, expected
%
r'
%
(
e
,
checkArgName
,
value
,
expected
[
checkArgName
]))
# test for pickling support
for
p
in
pickle
,
cPickle
:
if
p
is
None
:
continue
# cPickle not found -- skip it
for
protocol
in
range
(
p
.
HIGHEST_PROTOCOL
+
1
):
##print("p=%s, protocol=%s, e=%r" % (p.__name__, protocol, e))
s
=
p
.
dumps
(
e
,
protocol
)
new
=
p
.
loads
(
s
)
for
checkArgName
in
expected
:
...
...
@@ -356,4 +359,4 @@ def test_main():
run_unittest
(
ExceptionTests
)
if
__name__
==
'__main__'
:
test_
main
()
unittest
.
main
()
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