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
6116d4a1
Kaydet (Commit)
6116d4a1
authored
May 17, 2011
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
stop using the old brain-dead interface for providing attributes/methods
This closes #12099.
üst
53b6a5f7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
122 additions
and
120 deletions
+122
-120
NEWS
Misc/NEWS
+4
-0
_sre.c
Modules/_sre.c
+118
-120
No files found.
Misc/NEWS
Dosyayı görüntüle @
6116d4a1
...
@@ -382,6 +382,10 @@ Library
...
@@ -382,6 +382,10 @@ Library
Extension
Modules
Extension
Modules
-----------------
-----------------
-
Stop
using
the
old
interface
for
providing
methods
and
attributes
in
the
_sre
module
.
Among
other
things
,
this
gives
these
classes
``
__class__
``
attributes
.
(
See
#
12099
)
-
Issue
#
10169
:
Fix
argument
parsing
in
socket
.
sendto
()
to
avoid
error
masking
.
-
Issue
#
10169
:
Fix
argument
parsing
in
socket
.
sendto
()
to
avoid
error
masking
.
-
Issue
#
12051
:
Fix
segfault
in
json
.
dumps
()
while
encoding
highly
-
nested
-
Issue
#
12051
:
Fix
segfault
in
json
.
dumps
()
while
encoding
highly
-
nested
...
...
Modules/_sre.c
Dosyayı görüntüle @
6116d4a1
...
@@ -2598,46 +2598,22 @@ static PyMethodDef pattern_methods[] = {
...
@@ -2598,46 +2598,22 @@ static PyMethodDef pattern_methods[] = {
{
NULL
,
NULL
}
{
NULL
,
NULL
}
};
};
static
PyObject
*
#define PAT_OFF(x) offsetof(PatternObject, x)
pattern_getattr
(
PatternObject
*
self
,
char
*
name
)
static
PyMemberDef
pattern_members
[]
=
{
{
{
"pattern"
,
T_OBJECT
,
PAT_OFF
(
pattern
),
READONLY
},
PyObject
*
res
;
{
"flags"
,
T_INT
,
PAT_OFF
(
flags
),
READONLY
},
{
"groups"
,
T_PYSSIZET
,
PAT_OFF
(
groups
),
READONLY
},
res
=
Py_FindMethod
(
pattern_methods
,
(
PyObject
*
)
self
,
name
);
{
"groupindex"
,
T_OBJECT
,
PAT_OFF
(
groupindex
),
READONLY
},
{
NULL
}
/* Sentinel */
if
(
res
)
};
return
res
;
PyErr_Clear
();
/* attributes */
if
(
!
strcmp
(
name
,
"pattern"
))
{
Py_INCREF
(
self
->
pattern
);
return
self
->
pattern
;
}
if
(
!
strcmp
(
name
,
"flags"
))
return
Py_BuildValue
(
"i"
,
self
->
flags
);
if
(
!
strcmp
(
name
,
"groups"
))
return
Py_BuildValue
(
"i"
,
self
->
groups
);
if
(
!
strcmp
(
name
,
"groupindex"
)
&&
self
->
groupindex
)
{
Py_INCREF
(
self
->
groupindex
);
return
self
->
groupindex
;
}
PyErr_SetString
(
PyExc_AttributeError
,
name
);
return
NULL
;
}
statichere
PyTypeObject
Pattern_Type
=
{
statichere
PyTypeObject
Pattern_Type
=
{
PyObject_HEAD_INIT
(
NULL
)
PyObject_HEAD_INIT
(
NULL
)
0
,
"_"
SRE_MODULE
".SRE_Pattern"
,
0
,
"_"
SRE_MODULE
".SRE_Pattern"
,
sizeof
(
PatternObject
),
sizeof
(
SRE_CODE
),
sizeof
(
PatternObject
),
sizeof
(
SRE_CODE
),
(
destructor
)
pattern_dealloc
,
/*tp_dealloc*/
(
destructor
)
pattern_dealloc
,
/*tp_dealloc*/
0
,
/*tp_print
*/
0
,
/* tp_print
*/
(
getattrfunc
)
pattern_getattr
,
/*tp_getattr
*/
0
,
/* tp_getattrn
*/
0
,
/* tp_setattr */
0
,
/* tp_setattr */
0
,
/* tp_compare */
0
,
/* tp_compare */
0
,
/* tp_repr */
0
,
/* tp_repr */
...
@@ -2650,12 +2626,16 @@ statichere PyTypeObject Pattern_Type = {
...
@@ -2650,12 +2626,16 @@ statichere PyTypeObject Pattern_Type = {
0
,
/* tp_getattro */
0
,
/* tp_getattro */
0
,
/* tp_setattro */
0
,
/* tp_setattro */
0
,
/* tp_as_buffer */
0
,
/* tp_as_buffer */
Py_TPFLAGS_
HAVE_WEAKREFS
,
/* tp_flags */
Py_TPFLAGS_
DEFAULT
,
/* tp_flags */
pattern_doc
,
/* tp_doc */
pattern_doc
,
/* tp_doc */
0
,
/* tp_traverse */
0
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_richcompare */
offsetof
(
PatternObject
,
weakreflist
),
/* tp_weaklistoffset */
offsetof
(
PatternObject
,
weakreflist
),
/* tp_weaklistoffset */
0
,
/* tp_iter */
0
,
/* tp_iternext */
pattern_methods
,
/* tp_methods */
pattern_members
,
/* tp_members */
};
};
static
int
_validate
(
PatternObject
*
self
);
/* Forward */
static
int
_validate
(
PatternObject
*
self
);
/* Forward */
...
@@ -3562,7 +3542,7 @@ match_deepcopy(MatchObject* self, PyObject* memo)
...
@@ -3562,7 +3542,7 @@ match_deepcopy(MatchObject* self, PyObject* memo)
#endif
#endif
}
}
static
PyMethodDef
match_methods
[]
=
{
static
struct
PyMethodDef
match_methods
[]
=
{
{
"group"
,
(
PyCFunction
)
match_group
,
METH_VARARGS
},
{
"group"
,
(
PyCFunction
)
match_group
,
METH_VARARGS
},
{
"start"
,
(
PyCFunction
)
match_start
,
METH_VARARGS
},
{
"start"
,
(
PyCFunction
)
match_start
,
METH_VARARGS
},
{
"end"
,
(
PyCFunction
)
match_end
,
METH_VARARGS
},
{
"end"
,
(
PyCFunction
)
match_end
,
METH_VARARGS
},
...
@@ -3575,80 +3555,90 @@ static PyMethodDef match_methods[] = {
...
@@ -3575,80 +3555,90 @@ static PyMethodDef match_methods[] = {
{
NULL
,
NULL
}
{
NULL
,
NULL
}
};
};
static
PyObject
*
static
PyObject
*
match_
getattr
(
MatchObject
*
self
,
char
*
name
)
match_
lastindex_get
(
MatchObject
*
self
)
{
{
PyObject
*
res
;
if
(
self
->
lastindex
>=
0
)
return
Py_BuildValue
(
"i"
,
self
->
lastindex
);
res
=
Py_FindMethod
(
match_methods
,
(
PyObject
*
)
self
,
name
);
Py_INCREF
(
Py_None
);
if
(
res
)
return
Py_None
;
return
res
;
}
PyErr_Clear
();
if
(
!
strcmp
(
name
,
"lastindex"
))
{
if
(
self
->
lastindex
>=
0
)
return
Py_BuildValue
(
"i"
,
self
->
lastindex
);
Py_INCREF
(
Py_None
);
return
Py_None
;
}
if
(
!
strcmp
(
name
,
"lastgroup"
))
{
if
(
self
->
pattern
->
indexgroup
&&
self
->
lastindex
>=
0
)
{
PyObject
*
result
=
PySequence_GetItem
(
self
->
pattern
->
indexgroup
,
self
->
lastindex
);
if
(
result
)
return
result
;
PyErr_Clear
();
}
Py_INCREF
(
Py_None
);
return
Py_None
;
}
if
(
!
strcmp
(
name
,
"string"
))
{
if
(
self
->
string
)
{
Py_INCREF
(
self
->
string
);
return
self
->
string
;
}
else
{
Py_INCREF
(
Py_None
);
return
Py_None
;
}
}
if
(
!
strcmp
(
name
,
"regs"
))
{
static
PyObject
*
if
(
self
->
regs
)
{
match_lastgroup_get
(
MatchObject
*
self
)
Py_INCREF
(
self
->
regs
);
{
return
self
->
regs
;
if
(
self
->
pattern
->
indexgroup
&&
self
->
lastindex
>=
0
)
{
}
else
PyObject
*
result
=
PySequence_GetItem
(
return
match_regs
(
self
);
self
->
pattern
->
indexgroup
,
self
->
lastindex
);
if
(
result
)
return
result
;
PyErr_Clear
();
}
}
Py_INCREF
(
Py_None
);
return
Py_None
;
}
if
(
!
strcmp
(
name
,
"re"
))
{
static
PyObject
*
Py_INCREF
(
self
->
pattern
);
match_regs_get
(
MatchObject
*
self
)
return
(
PyObject
*
)
self
->
pattern
;
{
}
if
(
self
->
regs
)
{
Py_INCREF
(
self
->
regs
);
return
self
->
regs
;
}
else
return
match_regs
(
self
);
}
if
(
!
strcmp
(
name
,
"pos"
))
static
PyGetSetDef
match_getset
[]
=
{
return
Py_BuildValue
(
"i"
,
self
->
pos
);
{
"lastindex"
,
(
getter
)
match_lastindex_get
,
(
setter
)
NULL
},
{
"lastgroup"
,
(
getter
)
match_lastgroup_get
,
(
setter
)
NULL
},
{
"regs"
,
(
getter
)
match_regs_get
,
(
setter
)
NULL
},
{
NULL
}
};
if
(
!
strcmp
(
name
,
"endpos"
))
#define MATCH_OFF(x) offsetof(MatchObject, x)
return
Py_BuildValue
(
"i"
,
self
->
endpos
);
static
PyMemberDef
match_members
[]
=
{
{
"string"
,
T_OBJECT
,
MATCH_OFF
(
string
),
READONLY
},
{
"re"
,
T_OBJECT
,
MATCH_OFF
(
pattern
),
READONLY
},
{
"pos"
,
T_PYSSIZET
,
MATCH_OFF
(
pos
),
READONLY
},
{
"endpos"
,
T_PYSSIZET
,
MATCH_OFF
(
endpos
),
READONLY
},
{
NULL
}
};
PyErr_SetString
(
PyExc_AttributeError
,
name
);
return
NULL
;
}
/* FIXME: implement setattr("string", None) as a special case (to
/* FIXME: implement setattr("string", None) as a special case (to
detach the associated string, if any */
detach the associated string, if any */
static
here
PyTypeObject
Match_Type
=
{
static
PyTypeObject
Match_Type
=
{
Py
Object_HEAD_INIT
(
NULL
)
Py
VarObject_HEAD_INIT
(
NULL
,
0
)
0
,
"_"
SRE_MODULE
".SRE_Match"
,
"_"
SRE_MODULE
".SRE_Match"
,
sizeof
(
MatchObject
),
sizeof
(
Py_ssize_t
),
sizeof
(
MatchObject
),
sizeof
(
Py_ssize_t
),
(
destructor
)
match_dealloc
,
/*tp_dealloc*/
(
destructor
)
match_dealloc
,
/* tp_dealloc */
0
,
/*tp_print*/
0
,
/* tp_print */
(
getattrfunc
)
match_getattr
/*tp_getattr*/
0
,
/* tp_getattr */
0
,
/* tp_setattr */
0
,
/* tp_compare */
0
,
/* tp_repr */
0
,
/* tp_as_number */
0
,
/* tp_as_sequence */
0
,
/* tp_as_mapping */
0
,
/* tp_hash */
0
,
/* tp_call */
0
,
/* tp_str */
0
,
/* tp_getattro */
0
,
/* tp_setattro */
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
,
0
,
/* tp_doc */
0
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_weaklistoffset */
0
,
/* tp_iter */
0
,
/* tp_iternext */
match_methods
,
/* tp_methods */
match_members
,
/* tp_members */
match_getset
,
/* tp_getset */
};
};
static
PyObject
*
static
PyObject
*
...
@@ -3797,34 +3787,42 @@ static PyMethodDef scanner_methods[] = {
...
@@ -3797,34 +3787,42 @@ static PyMethodDef scanner_methods[] = {
{
NULL
,
NULL
}
{
NULL
,
NULL
}
};
};
static
PyObject
*
#define SCAN_OFF(x) offsetof(ScannerObject, x)
scanner_getattr
(
ScannerObject
*
self
,
char
*
name
)
static
PyMemberDef
scanner_members
[]
=
{
{
{
"pattern"
,
T_OBJECT
,
SCAN_OFF
(
pattern
),
READONLY
},
PyObject
*
res
;
{
NULL
}
/* Sentinel */
};
res
=
Py_FindMethod
(
scanner_methods
,
(
PyObject
*
)
self
,
name
);
if
(
res
)
return
res
;
PyErr_Clear
();
/* attributes */
if
(
!
strcmp
(
name
,
"pattern"
))
{
Py_INCREF
(
self
->
pattern
);
return
self
->
pattern
;
}
PyErr_SetString
(
PyExc_AttributeError
,
name
);
return
NULL
;
}
statichere
PyTypeObject
Scanner_Type
=
{
statichere
PyTypeObject
Scanner_Type
=
{
PyObject_HEAD_INIT
(
NULL
)
PyObject_HEAD_INIT
(
NULL
)
0
,
"_"
SRE_MODULE
".SRE_Scanner"
,
0
,
"_"
SRE_MODULE
".SRE_Scanner"
,
sizeof
(
ScannerObject
),
0
,
sizeof
(
ScannerObject
),
0
,
(
destructor
)
scanner_dealloc
,
/*tp_dealloc*/
(
destructor
)
scanner_dealloc
,
/*tp_dealloc*/
0
,
/*tp_print*/
0
,
/* tp_print */
(
getattrfunc
)
scanner_getattr
,
/*tp_getattr*/
0
,
/* tp_getattr */
0
,
/* tp_setattr */
0
,
/* tp_reserved */
0
,
/* tp_repr */
0
,
/* tp_as_number */
0
,
/* tp_as_sequence */
0
,
/* tp_as_mapping */
0
,
/* tp_hash */
0
,
/* tp_call */
0
,
/* tp_str */
0
,
/* tp_getattro */
0
,
/* tp_setattro */
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
,
/* tp_flags */
0
,
/* tp_doc */
0
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_weaklistoffset */
0
,
/* tp_iter */
0
,
/* tp_iternext */
scanner_methods
,
/* tp_methods */
scanner_members
,
/* tp_members */
0
,
/* tp_getset */
};
};
static
PyObject
*
static
PyObject
*
...
...
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