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
32a3fb5e
Kaydet (Commit)
32a3fb5e
authored
Ock 21, 2008
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Patch #1720595: add T_BOOL to the range of structmember types.
Patch by Angelo Mottola, reviewed by MvL, tests by me.
üst
f00b38e0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
3 deletions
+32
-3
structmember.h
Include/structmember.h
+3
-0
test_structmembers.py
Lib/test/test_structmembers.py
+7
-1
NEWS
Misc/NEWS
+2
-0
_testcapimodule.c
Modules/_testcapimodule.c
+5
-2
structmember.c
Python/structmember.c
+15
-0
No files found.
Include/structmember.h
Dosyayı görüntüle @
32a3fb5e
...
...
@@ -62,6 +62,9 @@ typedef struct PyMemberDef {
/* Added by Jack: strings contained in the structure */
#define T_STRING_INPLACE 13
/* Added by Lillo: bools contained in the structure (assumed char) */
#define T_BOOL 14
#define T_OBJECT_EX 16
/* Like T_OBJECT, but raises AttributeError
when the value is NULL, instead of
converting to None. */
...
...
Lib/test/test_structmembers.py
Dosyayı görüntüle @
32a3fb5e
...
...
@@ -8,10 +8,16 @@ from _testcapi import test_structmembersType, \
import
warnings
,
exceptions
,
unittest
,
sys
from
test
import
test_support
ts
=
test_structmembersType
(
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9.99999
,
10.1010101010
)
ts
=
test_structmembersType
(
False
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9.99999
,
10.1010101010
)
class
ReadWriteTests
(
unittest
.
TestCase
):
def
test_types
(
self
):
ts
.
T_BOOL
=
True
self
.
assertEquals
(
ts
.
T_BOOL
,
True
)
ts
.
T_BOOL
=
False
self
.
assertEquals
(
ts
.
T_BOOL
,
False
)
self
.
assertRaises
(
TypeError
,
setattr
,
ts
,
'T_BOOL'
,
1
)
ts
.
T_BYTE
=
CHAR_MAX
self
.
assertEquals
(
ts
.
T_BYTE
,
CHAR_MAX
)
ts
.
T_BYTE
=
CHAR_MIN
...
...
Misc/NEWS
Dosyayı görüntüle @
32a3fb5e
...
...
@@ -12,6 +12,8 @@ What's New in Python 2.6 alpha 1?
Core and builtins
-----------------
- Patch #1720595: add T_BOOL to the range of structmember types.
- Issue #1882: when compiling code from a string, encoding cookies in the
second line of code were not always recognized correctly.
...
...
Modules/_testcapimodule.c
Dosyayı görüntüle @
32a3fb5e
...
...
@@ -762,6 +762,7 @@ static PyMethodDef TestMethods[] = {
#define AddSym(d, n, f, v) {PyObject *o = f(v); PyDict_SetItemString(d, n, o); Py_DECREF(o);}
typedef
struct
{
char
bool_member
;
char
byte_member
;
unsigned
char
ubyte_member
;
short
short_member
;
...
...
@@ -784,6 +785,7 @@ typedef struct {
}
test_structmembers
;
static
struct
PyMemberDef
test_members
[]
=
{
{
"T_BOOL"
,
T_BOOL
,
offsetof
(
test_structmembers
,
structmembers
.
bool_member
),
0
,
NULL
},
{
"T_BYTE"
,
T_BYTE
,
offsetof
(
test_structmembers
,
structmembers
.
byte_member
),
0
,
NULL
},
{
"T_UBYTE"
,
T_UBYTE
,
offsetof
(
test_structmembers
,
structmembers
.
ubyte_member
),
0
,
NULL
},
{
"T_SHORT"
,
T_SHORT
,
offsetof
(
test_structmembers
,
structmembers
.
short_member
),
0
,
NULL
},
...
...
@@ -803,13 +805,13 @@ static struct PyMemberDef test_members[] = {
static
PyObject
*
test_structmembers_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwargs
){
static
char
*
keywords
[]
=
{
"T_BYTE"
,
"T_UBYTE"
,
"T_SHORT"
,
"T_USHORT"
,
"T_INT"
,
"T_UINT"
,
static
char
*
keywords
[]
=
{
"T_B
OOL"
,
"T_B
YTE"
,
"T_UBYTE"
,
"T_SHORT"
,
"T_USHORT"
,
"T_INT"
,
"T_UINT"
,
"T_LONG"
,
"T_ULONG"
,
"T_FLOAT"
,
"T_DOUBLE"
,
#ifdef HAVE_LONG_LONG
"T_LONGLONG"
,
"T_ULONGLONG"
,
#endif
NULL
};
static
char
*
fmt
=
"|bBhHiIlkfd"
static
char
*
fmt
=
"|b
b
BhHiIlkfd"
#ifdef HAVE_LONG_LONG
"LK"
#endif
...
...
@@ -819,6 +821,7 @@ static PyObject *test_structmembers_new(PyTypeObject *type, PyObject *args, PyOb
return
NULL
;
memset
(
&
ob
->
structmembers
,
0
,
sizeof
(
all_structmembers
));
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwargs
,
fmt
,
keywords
,
&
ob
->
structmembers
.
bool_member
,
&
ob
->
structmembers
.
byte_member
,
&
ob
->
structmembers
.
ubyte_member
,
&
ob
->
structmembers
.
short_member
,
&
ob
->
structmembers
.
ushort_member
,
&
ob
->
structmembers
.
int_member
,
&
ob
->
structmembers
.
uint_member
,
...
...
Python/structmember.c
Dosyayı görüntüle @
32a3fb5e
...
...
@@ -61,6 +61,9 @@ PyMember_GetOne(const char *addr, PyMemberDef *l)
}
addr
+=
l
->
offset
;
switch
(
l
->
type
)
{
case
T_BOOL
:
v
=
PyBool_FromLong
(
*
(
char
*
)
addr
);
break
;
case
T_BYTE
:
v
=
PyInt_FromLong
(
*
(
char
*
)
addr
);
break
;
...
...
@@ -183,6 +186,18 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v)
}
addr
+=
l
->
offset
;
switch
(
l
->
type
)
{
case
T_BOOL
:{
if
(
!
PyBool_Check
(
v
))
{
PyErr_SetString
(
PyExc_TypeError
,
"attribute value type must be bool"
);
return
-
1
;
}
if
(
v
==
Py_True
)
*
(
char
*
)
addr
=
(
char
)
1
;
else
*
(
char
*
)
addr
=
(
char
)
0
;
break
;
}
case
T_BYTE
:{
long
long_val
=
PyInt_AsLong
(
v
);
if
((
long_val
==
-
1
)
&&
PyErr_Occurred
())
...
...
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