Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e226b55

Browse files
committed
PEP 3101: Removed _formatter_xxx routines from sysmodule, and made them unicode methods instead (per GvR suggestion).
1 parent 8cef8a8 commit e226b55

4 files changed

Lines changed: 1351 additions & 1400 deletions

File tree

Include/unicodeobject.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,9 +1437,6 @@ PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strchr(
14371437
const Py_UNICODE *s, Py_UNICODE c
14381438
);
14391439

1440-
PyObject *_PyUnicode_FormatterIterator(PyObject *str);
1441-
PyObject *_PyUnicode_FormatterFieldNameSplit(PyObject *field_name);
1442-
14431440
#ifdef __cplusplus
14441441
}
14451442
#endif

Lib/string.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,8 @@ def convert(mo):
200200
# exposed here via the sys module. sys was chosen because it's always
201201
# available and doesn't have to be dynamically loaded.
202202

203-
# The overall parser is implemented in sys._formatter_parser.
204-
# The field name parser is implemented in sys._formatter_field_name_split
205-
206-
from sys import _formatter_parser, _formatter_field_name_split
203+
# The overall parser is implemented in str._formatter_parser.
204+
# The field name parser is implemented in str._formatter_field_name_split
207205

208206
class Formatter:
209207
def format(self, format_string, *args, **kwargs):
@@ -213,13 +211,13 @@ def vformat(self, format_string, args, kwargs):
213211
used_args = set()
214212
result = []
215213
for (is_markup, literal, field_name, format_spec, conversion) in \
216-
_formatter_parser(format_string):
214+
format_string._formatter_parser():
217215
if is_markup:
218216
# given the field_name, find the object it references
219217

220218
# split it into the first part, and and iterator that
221219
# looks over the rest
222-
first, rest = _formatter_field_name_split(field_name)
220+
first, rest = field_name._formatter_field_name_split()
223221

224222
used_args.add(first)
225223
obj = self.get_value(first, args, kwargs)

0 commit comments

Comments
 (0)