8000 bpo-10379: deprecate locale.format in lieu of locale.format_string by plusminushalf · Pull Request #259 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-10379: deprecate locale.format in lieu of locale.format_string #259

8000
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Mar 28, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
bpo-10379: deprecate locale.format in lue of locale.format_string
  • Loading branch information
plusminushalf committed Feb 23, 2017
commit d0f986349378d8b71a46e5d16ab9bbb08f75cbf9
20 changes: 9 additions & 11 deletions Lib/locale.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import collections
from builtins import str as _builtin_str
import functools
import warnings

# Try importing the _locale module.
#
Expand Down Expand Up @@ -181,17 +182,14 @@ def _strip_padding(s, amount):
r'(?P<modifiers>[-#0-9 +*.hlL]*?)[eEfFgGdiouxXcrs%]')

def format(percent, value, grouping=False, monetary=False, *additional):
"""Returns the locale-aware substitution of a %? specifier
(percent).

additional is for format strings which contain one or more
'*' modifiers."""
# this is only for one-percent-specifier strings and this should be checked
match = _percent_re.match(percent)
if not match or len(match.group())!= len(percent):
raise ValueError(("format() must be given exactly one %%char "
"format specifier, %s not valid") % repr(percent))
return _format(percent, value, grouping, monetary, *additional)
"""Deprecated, use format_string instead."""
warnings.warn(
"This method will be removed in future versions. "
"Use 'locale.format_string()' instead.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should read "This method will be removed in a future version of Python."

DeprecationWarning, stacklevel=2
)

return format_string(percent, value, grouping)

def _format(percent, value, grouping=False, monetary=False, *additional):
if additional:
Expand Down
0