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
66c221e9
Kaydet (Commit)
66c221e9
authored
Eki 14, 2010
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#9418: first step of moving private string methods to _string module.
üst
268e4d4c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
47 additions
and
8 deletions
+47
-8
string.py
Lib/string.py
+6
-4
NEWS
Misc/NEWS
+3
-0
config.c.in
Modules/config.c.in
+4
-0
string_format.h
Objects/stringlib/string_format.h
+2
-2
unicodeobject.c
Objects/unicodeobject.c
+30
-2
config.c
PC/config.c
+2
-0
No files found.
Lib/string.py
Dosyayı görüntüle @
66c221e9
...
...
@@ -14,6 +14,8 @@ printable -- a string containing all ASCII characters considered printable
"""
import
_string
# Some strings for ctype-style character classification
whitespace
=
'
\t\n\r\v\f
'
ascii_lowercase
=
'abcdefghijklmnopqrstuvwxyz'
...
...
@@ -170,8 +172,8 @@ class Template(metaclass=_TemplateMetaclass):
# The hard parts are reused from the C implementation. They're exposed as "_"
# prefixed methods of str.
# The overall parser is implemented in
str._
formatter_parser.
# The field name parser is implemented in
str._
formatter_field_name_split
# The overall parser is implemented in
_string.
formatter_parser.
# The field name parser is implemented in
_string.
formatter_field_name_split
class
Formatter
:
def
format
(
self
,
format_string
,
*
args
,
**
kwargs
):
...
...
@@ -251,7 +253,7 @@ class Formatter:
# if field_name is not None, it is looked up, formatted
# with format_spec and conversion and then used
def
parse
(
self
,
format_string
):
return
format_string
.
_formatter_parser
(
)
return
_string
.
formatter_parser
(
format_string
)
# given a field_name, find the object it references.
...
...
@@ -260,7 +262,7 @@ class Formatter:
# used_args: a set of which args have been used
# args, kwargs: as passed in to vformat
def
get_field
(
self
,
field_name
,
args
,
kwargs
):
first
,
rest
=
field_name
.
_formatter_field_name_split
(
)
first
,
rest
=
_string
.
formatter_field_name_split
(
field_name
)
obj
=
self
.
get_value
(
first
,
args
,
kwargs
)
...
...
Misc/NEWS
Dosyayı görüntüle @
66c221e9
...
...
@@ -10,6 +10,9 @@ What's New in Python 3.2 Beta 1?
Core and Builtins
-----------------
- Issue #9418: Moved private string methods ``_formatter_parser`` and
``_formatter_field_name_split`` into a new ``_string`` module.
- Issue #9992: Remove PYTHONFSENCODING environment variable.
Library
...
...
Modules/config.c.in
Dosyayı görüntüle @
66c221e9
...
...
@@ -29,6 +29,7 @@ extern PyObject* PyInit_imp(void);
extern PyObject* PyInit_gc(void);
extern PyObject* PyInit__ast(void);
extern PyObject* _PyWarnings_Init(void);
extern PyObject* PyInit__string(void);
struct _inittab _PyImport_Inittab[] = {
...
...
@@ -54,6 +55,9 @@ struct _inittab _PyImport_Inittab[] = {
/* This lives in _warnings.c */
{"_warnings", _PyWarnings_Init},
/* This lives in Objects/unicodeobject.c */
{"_string", PyInit__string},
/* Sentinel */
{0, 0}
};
...
...
Objects/stringlib/string_format.h
Dosyayı görüntüle @
66c221e9
...
...
@@ -1180,7 +1180,7 @@ static PyTypeObject PyFormatterIter_Type = {
describing the parsed elements. It's a wrapper around
stringlib/string_format.h's MarkupIterator */
static
PyObject
*
formatter_parser
(
STRINGLIB_OBJECT
*
self
)
formatter_parser
(
PyObject
*
ignored
,
STRINGLIB_OBJECT
*
self
)
{
formatteriterobject
*
it
;
...
...
@@ -1315,7 +1315,7 @@ static PyTypeObject PyFieldNameIter_Type = {
field_name_split. The iterator it returns is a
FieldNameIterator */
static
PyObject
*
formatter_field_name_split
(
STRINGLIB_OBJECT
*
self
)
formatter_field_name_split
(
PyObject
*
ignored
,
STRINGLIB_OBJECT
*
self
)
{
SubString
first
;
Py_ssize_t
first_idx
;
...
...
Objects/unicodeobject.c
Dosyayı görüntüle @
66c221e9
...
...
@@ -8968,8 +8968,6 @@ static PyMethodDef unicode_methods[] = {
{
"zfill"
,
(
PyCFunction
)
unicode_zfill
,
METH_VARARGS
,
zfill__doc__
},
{
"format"
,
(
PyCFunction
)
do_string_format
,
METH_VARARGS
|
METH_KEYWORDS
,
format__doc__
},
{
"__format__"
,
(
PyCFunction
)
unicode__format__
,
METH_VARARGS
,
p_format__doc__
},
{"_formatter_field_name_split", (PyCFunction) formatter_field_name_split, METH_NOARGS},
{"_formatter_parser", (PyCFunction) formatter_parser, METH_NOARGS},
{
"maketrans"
,
(
PyCFunction
)
unicode_maketrans
,
METH_VARARGS
|
METH_STATIC
,
maketrans__doc__
},
{
"__sizeof__"
,
(
PyCFunction
)
unicode__sizeof__
,
METH_NOARGS
,
sizeof__doc__
},
...
...
@@ -10170,6 +10168,36 @@ PyUnicode_AsUnicodeCopy(PyObject *object)
return
copy
;
}
/* A _string module, to export formatter_parser and formatter_field_name_split
to the string.Formatter class implemented in Python. */
static
PyMethodDef
_string_methods
[]
=
{
{
"formatter_field_name_split"
,
(
PyCFunction
)
formatter_field_name_split
,
METH_O
,
PyDoc_STR
(
"split the argument as a field name"
)},
{
"formatter_parser"
,
(
PyCFunction
)
formatter_parser
,
METH_O
,
PyDoc_STR
(
"parse the argument as a format string"
)},
{
NULL
,
NULL
}
};
static
struct
PyModuleDef
_string_module
=
{
PyModuleDef_HEAD_INIT
,
"_string"
,
PyDoc_STR
(
"string helper module"
),
0
,
_string_methods
,
NULL
,
NULL
,
NULL
,
NULL
};
PyMODINIT_FUNC
PyInit__string
(
void
)
{
return
PyModule_Create
(
&
_string_module
);
}
#ifdef __cplusplus
}
#endif
PC/config.c
Dosyayı görüntüle @
66c221e9
...
...
@@ -62,6 +62,7 @@ extern PyObject* PyInit__io(void);
extern
PyObject
*
PyInit__pickle
(
void
);
extern
PyObject
*
PyInit_atexit
(
void
);
extern
PyObject
*
_PyWarnings_Init
(
void
);
extern
PyObject
*
PyInit__string
(
void
);
/* tools/freeze/makeconfig.py marker for additional "extern" */
/* -- ADDMODULE MARKER 1 -- */
...
...
@@ -147,6 +148,7 @@ struct _inittab _PyImport_Inittab[] = {
{
"builtins"
,
NULL
},
{
"sys"
,
NULL
},
{
"_warnings"
,
_PyWarnings_Init
},
{
"_string"
,
PyInit__string
},
{
"_io"
,
PyInit__io
},
{
"_pickle"
,
PyInit__pickle
},
...
...
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