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
b9f4ad3a
Kaydet (Commit)
b9f4ad3a
authored
Eki 29, 2006
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Bug #1576657: when setting a KeyError for a tuple key, make sure that
the tuple isn't used as the "exception arguments tuple".
üst
f733a013
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
3 deletions
+29
-3
test_dict.py
Lib/test/test_dict.py
+10
-0
NEWS
Misc/NEWS
+3
-0
dictobject.c
Objects/dictobject.c
+16
-3
No files found.
Lib/test/test_dict.py
Dosyayı görüntüle @
b9f4ad3a
...
@@ -444,6 +444,16 @@ class DictTest(unittest.TestCase):
...
@@ -444,6 +444,16 @@ class DictTest(unittest.TestCase):
else
:
else
:
self
.
fail_
(
"g[42] didn't raise KeyError"
)
self
.
fail_
(
"g[42] didn't raise KeyError"
)
def
test_tuple_keyerror
(
self
):
# SF #1576657
d
=
{}
try
:
d
[(
1
,)]
except
KeyError
,
e
:
self
.
assertEqual
(
e
.
args
,
((
1
,),))
else
:
self
.
fail
(
"missing KeyError"
)
from
test
import
mapping_tests
from
test
import
mapping_tests
...
...
Misc/NEWS
Dosyayı görüntüle @
b9f4ad3a
...
@@ -12,6 +12,9 @@ What's New in Python 2.6 alpha 1?
...
@@ -12,6 +12,9 @@ What's New in Python 2.6 alpha 1?
Core and builtins
Core and builtins
-----------------
-----------------
- Bug #1576657: when setting a KeyError for a tuple key, make sure that
the tuple isn'
t
used
as
the
"exception arguments tuple"
.
-
Bug
#
1565514
,
SystemError
not
raised
on
too
many
nested
blocks
.
-
Bug
#
1565514
,
SystemError
not
raised
on
too
many
nested
blocks
.
-
Bug
#
1576174
:
WindowsError
now
displays
the
windows
error
code
-
Bug
#
1576174
:
WindowsError
now
displays
the
windows
error
code
...
...
Objects/dictobject.c
Dosyayı görüntüle @
b9f4ad3a
...
@@ -12,6 +12,19 @@
...
@@ -12,6 +12,19 @@
typedef
PyDictEntry
dictentry
;
typedef
PyDictEntry
dictentry
;
typedef
PyDictObject
dictobject
;
typedef
PyDictObject
dictobject
;
/* Set a key error with the specified argument, wrapping it in a
* tuple automatically so that tuple keys are not unpacked as the
* exception arguments. */
static
void
set_key_error
(
PyObject
*
arg
)
{
PyObject
*
tup
;
tup
=
PyTuple_Pack
(
1
,
arg
);
if
(
!
tup
)
return
;
/* caller will expect error to be set anyway */
PyErr_SetObject
(
PyExc_KeyError
,
tup
);
}
/* Define this out if you don't want conversion statistics on exit. */
/* Define this out if you don't want conversion statistics on exit. */
#undef SHOW_CONVERSION_COUNTS
#undef SHOW_CONVERSION_COUNTS
...
@@ -665,7 +678,7 @@ PyDict_DelItem(PyObject *op, PyObject *key)
...
@@ -665,7 +678,7 @@ PyDict_DelItem(PyObject *op, PyObject *key)
if
(
ep
==
NULL
)
if
(
ep
==
NULL
)
return
-
1
;
return
-
1
;
if
(
ep
->
me_value
==
NULL
)
{
if
(
ep
->
me_value
==
NULL
)
{
PyErr_SetObject
(
PyExc_KeyError
,
key
);
set_key_error
(
key
);
return
-
1
;
return
-
1
;
}
}
old_key
=
ep
->
me_key
;
old_key
=
ep
->
me_key
;
...
@@ -974,7 +987,7 @@ dict_subscript(dictobject *mp, register PyObject *key)
...
@@ -974,7 +987,7 @@ dict_subscript(dictobject *mp, register PyObject *key)
return
PyObject_CallFunctionObjArgs
(
missing
,
return
PyObject_CallFunctionObjArgs
(
missing
,
(
PyObject
*
)
mp
,
key
,
NULL
);
(
PyObject
*
)
mp
,
key
,
NULL
);
}
}
PyErr_SetObject
(
PyExc_KeyError
,
key
);
set_key_error
(
key
);
return
NULL
;
return
NULL
;
}
}
else
else
...
@@ -1746,7 +1759,7 @@ dict_pop(dictobject *mp, PyObject *args)
...
@@ -1746,7 +1759,7 @@ dict_pop(dictobject *mp, PyObject *args)
Py_INCREF
(
deflt
);
Py_INCREF
(
deflt
);
return
deflt
;
return
deflt
;
}
}
PyErr_SetObject
(
PyExc_KeyError
,
key
);
set_key_error
(
key
);
return
NULL
;
return
NULL
;
}
}
old_key
=
ep
->
me_key
;
old_key
=
ep
->
me_key
;
...
...
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