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
ba7bf49a
Kaydet (Commit)
ba7bf49a
authored
Şub 27, 2007
tarafından
Brett Cannon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Remove the ability to slice/index on exceptions per PEP 352.
üst
44c52617
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
16 additions
and
46 deletions
+16
-46
ConfigParser.py
Lib/ConfigParser.py
+1
-1
test_dbm.py
Lib/test/test_dbm.py
+1
-1
test_exceptions.py
Lib/test/test_exceptions.py
+0
-7
test_file.py
Lib/test/test_file.py
+1
-1
test_pep352.py
Lib/test/test_pep352.py
+9
-7
traceback.py
Lib/traceback.py
+1
-1
NEWS
Misc/NEWS
+2
-0
exceptions.c
Objects/exceptions.c
+1
-28
No files found.
Lib/ConfigParser.py
Dosyayı görüntüle @
ba7bf49a
...
@@ -569,7 +569,7 @@ class ConfigParser(RawConfigParser):
...
@@ -569,7 +569,7 @@ class ConfigParser(RawConfigParser):
value
=
value
%
vars
value
=
value
%
vars
except
KeyError
as
e
:
except
KeyError
as
e
:
raise
InterpolationMissingOptionError
(
raise
InterpolationMissingOptionError
(
option
,
section
,
rawval
,
e
[
0
]
)
option
,
section
,
rawval
,
e
.
message
)
else
:
else
:
break
break
if
"
%
("
in
value
:
if
"
%
("
in
value
:
...
...
Lib/test/test_dbm.py
Dosyayı görüntüle @
ba7bf49a
...
@@ -17,7 +17,7 @@ def cleanup():
...
@@ -17,7 +17,7 @@ def cleanup():
try
:
try
:
os
.
unlink
(
filename
+
suffix
)
os
.
unlink
(
filename
+
suffix
)
except
OSError
as
e
:
except
OSError
as
e
:
(
errno
,
strerror
)
=
e
(
errno
,
strerror
)
=
e
.
errno
,
e
.
strerror
# if we can't delete the file because of permissions,
# if we can't delete the file because of permissions,
# nothing will work, so skip the test
# nothing will work, so skip the test
if
errno
==
1
:
if
errno
==
1
:
...
...
Lib/test/test_exceptions.py
Dosyayı görüntüle @
ba7bf49a
...
@@ -302,13 +302,6 @@ class ExceptionTests(unittest.TestCase):
...
@@ -302,13 +302,6 @@ class ExceptionTests(unittest.TestCase):
'pickled "
%
r", attribute "
%
s'
%
'pickled "
%
r", attribute "
%
s'
%
(
e
,
checkArgName
))
(
e
,
checkArgName
))
def
testSlicing
(
self
):
# Test that you can slice an exception directly instead of requiring
# going through the 'args' attribute.
args
=
(
1
,
2
,
3
)
exc
=
BaseException
(
*
args
)
self
.
failUnlessEqual
(
exc
[:],
args
)
def
testKeywordArgs
(
self
):
def
testKeywordArgs
(
self
):
# test that builtin exception don't take keyword args,
# test that builtin exception don't take keyword args,
# but user-defined subclasses can if they want
# but user-defined subclasses can if they want
...
...
Lib/test/test_file.py
Dosyayı görüntüle @
ba7bf49a
...
@@ -156,7 +156,7 @@ class OtherFileTests(unittest.TestCase):
...
@@ -156,7 +156,7 @@ class OtherFileTests(unittest.TestCase):
try
:
try
:
f
=
open
(
TESTFN
,
bad_mode
)
f
=
open
(
TESTFN
,
bad_mode
)
except
ValueError
as
msg
:
except
ValueError
as
msg
:
if
msg
[
0
]
!=
0
:
if
msg
.
message
!=
0
:
s
=
str
(
msg
)
s
=
str
(
msg
)
if
s
.
find
(
TESTFN
)
!=
-
1
or
s
.
find
(
bad_mode
)
==
-
1
:
if
s
.
find
(
TESTFN
)
!=
-
1
or
s
.
find
(
bad_mode
)
==
-
1
:
self
.
fail
(
"bad error message for invalid mode:
%
s"
%
s
)
self
.
fail
(
"bad error message for invalid mode:
%
s"
%
s
)
...
...
Lib/test/test_pep352.py
Dosyayı görüntüle @
ba7bf49a
...
@@ -15,7 +15,7 @@ class ExceptionClassTests(unittest.TestCase):
...
@@ -15,7 +15,7 @@ class ExceptionClassTests(unittest.TestCase):
self
.
failUnless
(
issubclass
(
Exception
,
object
))
self
.
failUnless
(
issubclass
(
Exception
,
object
))
def
verify_instance_interface
(
self
,
ins
):
def
verify_instance_interface
(
self
,
ins
):
for
attr
in
(
"args"
,
"message"
,
"__str__"
,
"__repr__"
,
"__getitem__"
):
for
attr
in
(
"args"
,
"message"
,
"__str__"
,
"__repr__"
):
self
.
failUnless
(
hasattr
(
ins
,
attr
),
"
%
s missing
%
s attribute"
%
self
.
failUnless
(
hasattr
(
ins
,
attr
),
"
%
s missing
%
s attribute"
%
(
ins
.
__class__
.
__name__
,
attr
))
(
ins
.
__class__
.
__name__
,
attr
))
...
@@ -72,8 +72,7 @@ class ExceptionClassTests(unittest.TestCase):
...
@@ -72,8 +72,7 @@ class ExceptionClassTests(unittest.TestCase):
inheritance_tree
.
close
()
inheritance_tree
.
close
()
self
.
failUnlessEqual
(
len
(
exc_set
),
0
,
"
%
s not accounted for"
%
exc_set
)
self
.
failUnlessEqual
(
len
(
exc_set
),
0
,
"
%
s not accounted for"
%
exc_set
)
interface_tests
=
(
"length"
,
"args"
,
"message"
,
"str"
,
"unicode"
,
"repr"
,
interface_tests
=
(
"length"
,
"args"
,
"message"
,
"str"
,
"unicode"
,
"repr"
)
"indexing"
)
def
interface_test_driver
(
self
,
results
):
def
interface_test_driver
(
self
,
results
):
for
test_name
,
(
given
,
expected
)
in
zip
(
self
.
interface_tests
,
results
):
for
test_name
,
(
given
,
expected
)
in
zip
(
self
.
interface_tests
,
results
):
...
@@ -86,7 +85,7 @@ class ExceptionClassTests(unittest.TestCase):
...
@@ -86,7 +85,7 @@ class ExceptionClassTests(unittest.TestCase):
exc
=
Exception
(
arg
)
exc
=
Exception
(
arg
)
results
=
([
len
(
exc
.
args
),
1
],
[
exc
.
args
[
0
],
arg
],
[
exc
.
message
,
arg
],
results
=
([
len
(
exc
.
args
),
1
],
[
exc
.
args
[
0
],
arg
],
[
exc
.
message
,
arg
],
[
str
(
exc
),
str
(
arg
)],
[
unicode
(
exc
),
unicode
(
arg
)],
[
str
(
exc
),
str
(
arg
)],
[
unicode
(
exc
),
unicode
(
arg
)],
[
repr
(
exc
),
exc
.
__class__
.
__name__
+
repr
(
exc
.
args
)]
,
[
exc
[
0
],
arg
]
)
[
repr
(
exc
),
exc
.
__class__
.
__name__
+
repr
(
exc
.
args
)])
self
.
interface_test_driver
(
results
)
self
.
interface_test_driver
(
results
)
def
test_interface_multi_arg
(
self
):
def
test_interface_multi_arg
(
self
):
...
@@ -97,8 +96,7 @@ class ExceptionClassTests(unittest.TestCase):
...
@@ -97,8 +96,7 @@ class ExceptionClassTests(unittest.TestCase):
results
=
([
len
(
exc
.
args
),
arg_count
],
[
exc
.
args
,
args
],
results
=
([
len
(
exc
.
args
),
arg_count
],
[
exc
.
args
,
args
],
[
exc
.
message
,
''
],
[
str
(
exc
),
str
(
args
)],
[
exc
.
message
,
''
],
[
str
(
exc
),
str
(
args
)],
[
unicode
(
exc
),
unicode
(
args
)],
[
unicode
(
exc
),
unicode
(
args
)],
[
repr
(
exc
),
exc
.
__class__
.
__name__
+
repr
(
exc
.
args
)],
[
repr
(
exc
),
exc
.
__class__
.
__name__
+
repr
(
exc
.
args
)])
[
exc
[
-
1
],
args
[
-
1
]])
self
.
interface_test_driver
(
results
)
self
.
interface_test_driver
(
results
)
def
test_interface_no_arg
(
self
):
def
test_interface_no_arg
(
self
):
...
@@ -106,7 +104,7 @@ class ExceptionClassTests(unittest.TestCase):
...
@@ -106,7 +104,7 @@ class ExceptionClassTests(unittest.TestCase):
exc
=
Exception
()
exc
=
Exception
()
results
=
([
len
(
exc
.
args
),
0
],
[
exc
.
args
,
tuple
()],
[
exc
.
message
,
''
],
results
=
([
len
(
exc
.
args
),
0
],
[
exc
.
args
,
tuple
()],
[
exc
.
message
,
''
],
[
str
(
exc
),
''
],
[
unicode
(
exc
),
u''
],
[
str
(
exc
),
''
],
[
unicode
(
exc
),
u''
],
[
repr
(
exc
),
exc
.
__class__
.
__name__
+
'()'
]
,
[
True
,
True
]
)
[
repr
(
exc
),
exc
.
__class__
.
__name__
+
'()'
])
self
.
interface_test_driver
(
results
)
self
.
interface_test_driver
(
results
)
class
UsageTests
(
unittest
.
TestCase
):
class
UsageTests
(
unittest
.
TestCase
):
...
@@ -166,6 +164,10 @@ class UsageTests(unittest.TestCase):
...
@@ -166,6 +164,10 @@ class UsageTests(unittest.TestCase):
self
.
catch_fails
(
NonBaseException
)
self
.
catch_fails
(
NonBaseException
)
self
.
catch_fails
(
NonBaseException
())
self
.
catch_fails
(
NonBaseException
())
def
test_catch_BaseException_instance
(
self
):
# Catching an instance of a BaseException subclass won't work.
self
.
catch_fails
(
BaseException
())
def
test_catch_string
(
self
):
def
test_catch_string
(
self
):
# Catching a string is bad.
# Catching a string is bad.
self
.
catch_fails
(
"spam"
)
self
.
catch_fails
(
"spam"
)
...
...
Lib/traceback.py
Dosyayı görüntüle @
ba7bf49a
...
@@ -178,7 +178,7 @@ def format_exception_only(etype, value):
...
@@ -178,7 +178,7 @@ def format_exception_only(etype, value):
# It was a syntax error; show exactly where the problem was found.
# It was a syntax error; show exactly where the problem was found.
lines
=
[]
lines
=
[]
try
:
try
:
msg
,
(
filename
,
lineno
,
offset
,
badline
)
=
value
msg
,
(
filename
,
lineno
,
offset
,
badline
)
=
value
.
args
except
Exception
:
except
Exception
:
pass
pass
else
:
else
:
...
...
Misc/NEWS
Dosyayı görüntüle @
ba7bf49a
...
@@ -28,6 +28,8 @@ TO DO
...
@@ -28,6 +28,8 @@ TO DO
Core and Builtins
Core and Builtins
-----------------
-----------------
- Removing indexing/slicing on BaseException.
- Remove the exceptions module, all the exceptions are already builtin.
- Remove the exceptions module, all the exceptions are already builtin.
- input() becomes raw_input(): the name input() now implements the
- input() becomes raw_input(): the name input() now implements the
...
...
Objects/exceptions.c
Dosyayı görüntüle @
ba7bf49a
...
@@ -174,33 +174,6 @@ static PyMethodDef BaseException_methods[] = {
...
@@ -174,33 +174,6 @@ static PyMethodDef BaseException_methods[] = {
};
};
static
PyObject
*
BaseException_getitem
(
PyBaseExceptionObject
*
self
,
Py_ssize_t
index
)
{
return
PySequence_GetItem
(
self
->
args
,
index
);
}
static
PyObject
*
BaseException_getslice
(
PyBaseExceptionObject
*
self
,
Py_ssize_t
start
,
Py_ssize_t
stop
)
{
return
PySequence_GetSlice
(
self
->
args
,
start
,
stop
);
}
static
PySequenceMethods
BaseException_as_sequence
=
{
0
,
/* sq_length; */
0
,
/* sq_concat; */
0
,
/* sq_repeat; */
(
ssizeargfunc
)
BaseException_getitem
,
/* sq_item; */
(
ssizessizeargfunc
)
BaseException_getslice
,
/* sq_slice; */
0
,
/* sq_ass_item; */
0
,
/* sq_ass_slice; */
0
,
/* sq_contains; */
0
,
/* sq_inplace_concat; */
0
/* sq_inplace_repeat; */
};
static
PyMemberDef
BaseException_members
[]
=
{
static
PyMemberDef
BaseException_members
[]
=
{
{
"message"
,
T_OBJECT
,
offsetof
(
PyBaseExceptionObject
,
message
),
0
,
{
"message"
,
T_OBJECT
,
offsetof
(
PyBaseExceptionObject
,
message
),
0
,
PyDoc_STR
(
"exception message"
)},
PyDoc_STR
(
"exception message"
)},
...
@@ -283,7 +256,7 @@ static PyTypeObject _PyExc_BaseException = {
...
@@ -283,7 +256,7 @@ static PyTypeObject _PyExc_BaseException = {
0
,
/* tp_compare; */
0
,
/* tp_compare; */
(
reprfunc
)
BaseException_repr
,
/*tp_repr*/
(
reprfunc
)
BaseException_repr
,
/*tp_repr*/
0
,
/*tp_as_number*/
0
,
/*tp_as_number*/
&
BaseException_as_sequence
,
/*tp_as_sequence*/
0
,
/*tp_as_sequence*/
0
,
/*tp_as_mapping*/
0
,
/*tp_as_mapping*/
0
,
/*tp_hash */
0
,
/*tp_hash */
0
,
/*tp_call*/
0
,
/*tp_call*/
...
...
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