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
69492dab
Kaydet (Commit)
69492dab
authored
Eyl 02, 2013
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Factor-out the common code for setting a KeyError.
üst
7f5c22c0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
33 deletions
+20
-33
pyerrors.h
Include/pyerrors.h
+1
-0
dictobject.c
Objects/dictobject.c
+4
-18
setobject.c
Objects/setobject.c
+1
-15
errors.c
Python/errors.c
+14
-0
No files found.
Include/pyerrors.h
Dosyayı görüntüle @
69492dab
...
@@ -75,6 +75,7 @@ typedef PyOSErrorObject PyWindowsErrorObject;
...
@@ -75,6 +75,7 @@ typedef PyOSErrorObject PyWindowsErrorObject;
PyAPI_FUNC
(
void
)
PyErr_SetNone
(
PyObject
*
);
PyAPI_FUNC
(
void
)
PyErr_SetNone
(
PyObject
*
);
PyAPI_FUNC
(
void
)
PyErr_SetObject
(
PyObject
*
,
PyObject
*
);
PyAPI_FUNC
(
void
)
PyErr_SetObject
(
PyObject
*
,
PyObject
*
);
PyAPI_FUNC
(
void
)
_PyErr_SetKeyError
(
PyObject
*
);
PyAPI_FUNC
(
void
)
PyErr_SetString
(
PyAPI_FUNC
(
void
)
PyErr_SetString
(
PyObject
*
exception
,
PyObject
*
exception
,
const
char
*
string
/* decoded from utf-8 */
const
char
*
string
/* decoded from utf-8 */
...
...
Objects/dictobject.c
Dosyayı görüntüle @
69492dab
...
@@ -95,20 +95,6 @@ To avoid slowing down lookups on a near-full table, we resize the table when
...
@@ -95,20 +95,6 @@ To avoid slowing down lookups on a near-full table, we resize the table when
it's USABLE_FRACTION (currently two-thirds) full.
it's USABLE_FRACTION (currently two-thirds) full.
*/
*/
/* 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
);
Py_DECREF
(
tup
);
}
#define PERTURB_SHIFT 5
#define PERTURB_SHIFT 5
/*
/*
...
@@ -1241,7 +1227,7 @@ PyDict_DelItem(PyObject *op, PyObject *key)
...
@@ -1241,7 +1227,7 @@ PyDict_DelItem(PyObject *op, PyObject *key)
if
(
ep
==
NULL
)
if
(
ep
==
NULL
)
return
-
1
;
return
-
1
;
if
(
*
value_addr
==
NULL
)
{
if
(
*
value_addr
==
NULL
)
{
set_key_e
rror
(
key
);
_PyErr_SetKeyE
rror
(
key
);
return
-
1
;
return
-
1
;
}
}
old_value
=
*
value_addr
;
old_value
=
*
value_addr
;
...
@@ -1530,7 +1516,7 @@ dict_subscript(PyDictObject *mp, PyObject *key)
...
@@ -1530,7 +1516,7 @@ dict_subscript(PyDictObject *mp, PyObject *key)
else
if
(
PyErr_Occurred
())
else
if
(
PyErr_Occurred
())
return
NULL
;
return
NULL
;
}
}
set_key_e
rror
(
key
);
_PyErr_SetKeyE
rror
(
key
);
return
NULL
;
return
NULL
;
}
}
else
else
...
@@ -2302,7 +2288,7 @@ dict_pop(PyDictObject *mp, PyObject *args)
...
@@ -2302,7 +2288,7 @@ dict_pop(PyDictObject *mp, PyObject *args)
Py_INCREF
(
deflt
);
Py_INCREF
(
deflt
);
return
deflt
;
return
deflt
;
}
}
set_key_e
rror
(
key
);
_PyErr_SetKeyE
rror
(
key
);
return
NULL
;
return
NULL
;
}
}
if
(
!
PyUnicode_CheckExact
(
key
)
||
if
(
!
PyUnicode_CheckExact
(
key
)
||
...
@@ -2320,7 +2306,7 @@ dict_pop(PyDictObject *mp, PyObject *args)
...
@@ -2320,7 +2306,7 @@ dict_pop(PyDictObject *mp, PyObject *args)
Py_INCREF
(
deflt
);
Py_INCREF
(
deflt
);
return
deflt
;
return
deflt
;
}
}
set_key_e
rror
(
key
);
_PyErr_SetKeyE
rror
(
key
);
return
NULL
;
return
NULL
;
}
}
*
value_addr
=
NULL
;
*
value_addr
=
NULL
;
...
...
Objects/setobject.c
Dosyayı görüntüle @
69492dab
...
@@ -11,20 +11,6 @@
...
@@ -11,20 +11,6 @@
#include "structmember.h"
#include "structmember.h"
#include "stringlib/eq.h"
#include "stringlib/eq.h"
/* 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
);
Py_DECREF
(
tup
);
}
/* This must be >= 1. */
/* This must be >= 1. */
#define PERTURB_SHIFT 5
#define PERTURB_SHIFT 5
#define LINEAR_PROBES 9
#define LINEAR_PROBES 9
...
@@ -1948,7 +1934,7 @@ set_remove(PySetObject *so, PyObject *key)
...
@@ -1948,7 +1934,7 @@ set_remove(PySetObject *so, PyObject *key)
}
}
if
(
rv
==
DISCARD_NOTFOUND
)
{
if
(
rv
==
DISCARD_NOTFOUND
)
{
set_key_e
rror
(
key
);
_PyErr_SetKeyE
rror
(
key
);
return
NULL
;
return
NULL
;
}
}
Py_RETURN_NONE
;
Py_RETURN_NONE
;
...
...
Python/errors.c
Dosyayı görüntüle @
69492dab
...
@@ -117,6 +117,20 @@ PyErr_SetObject(PyObject *exception, PyObject *value)
...
@@ -117,6 +117,20 @@ PyErr_SetObject(PyObject *exception, PyObject *value)
PyErr_Restore
(
exception
,
value
,
tb
);
PyErr_Restore
(
exception
,
value
,
tb
);
}
}
/* 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. */
void
_PyErr_SetKeyError
(
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
);
Py_DECREF
(
tup
);
}
void
void
PyErr_SetNone
(
PyObject
*
exception
)
PyErr_SetNone
(
PyObject
*
exception
)
{
{
...
...
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