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
009b0a1f
Kaydet (Commit)
009b0a1f
authored
Ock 13, 2017
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #29193: A format string argument for string.Formatter.format()
is now positional-only.
üst
b37f3f6e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
14 deletions
+16
-14
string.rst
Doc/library/string.rst
+3
-3
3.7.rst
Doc/whatsnew/3.7.rst
+6
-0
string.py
Lib/string.py
+2
-8
test_string.py
Lib/test/test_string.py
+2
-3
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/string.rst
Dosyayı görüntüle @
009b0a1f
...
@@ -95,9 +95,9 @@ implementation as the built-in :meth:`~str.format` method.
...
@@ -95,9 +95,9 @@ implementation as the built-in :meth:`~str.format` method.
an arbitrary set of positional and keyword arguments.
an arbitrary set of positional and keyword arguments.
It is just a wrapper that calls :meth:`vformat`.
It is just a wrapper that calls :meth:`vformat`.
..
deprecated:: 3.5
..
versionchanged:: 3.7
Passing a format string as keyword argument *format_string* has been
A format string argument is now :ref:`positional-only
deprecated
.
<positional-only_parameter>`
.
.. method:: vformat(format_string, args, kwargs)
.. method:: vformat(format_string, args, kwargs)
...
...
Doc/whatsnew/3.7.rst
Dosyayı görüntüle @
009b0a1f
...
@@ -147,3 +147,9 @@ This section lists previously described changes and other bugfixes
...
@@ -147,3 +147,9 @@ This section lists previously described changes and other bugfixes
that may require changes to your code.
that may require changes to your code.
Changes in the Python API
-------------------------
* A format string argument for :meth:`string.Formatter.format`
is now :ref:`positional-only <positional-only_parameter>`.
(Contributed by Serhiy Storchaka in :issue:`29193`.)
Lib/string.py
Dosyayı görüntüle @
009b0a1f
...
@@ -175,14 +175,8 @@ class Formatter:
...
@@ -175,14 +175,8 @@ class Formatter:
try
:
try
:
format_string
,
*
args
=
args
# allow the "format_string" keyword be passed
format_string
,
*
args
=
args
# allow the "format_string" keyword be passed
except
ValueError
:
except
ValueError
:
if
'format_string'
in
kwargs
:
raise
TypeError
(
"format() missing 1 required positional "
format_string
=
kwargs
.
pop
(
'format_string'
)
"argument: 'format_string'"
)
from
None
import
warnings
warnings
.
warn
(
"Passing 'format_string' as keyword argument is "
"deprecated"
,
DeprecationWarning
,
stacklevel
=
2
)
else
:
raise
TypeError
(
"format() missing 1 required positional "
"argument: 'format_string'"
)
from
None
return
self
.
vformat
(
format_string
,
args
,
kwargs
)
return
self
.
vformat
(
format_string
,
args
,
kwargs
)
def
vformat
(
self
,
format_string
,
args
,
kwargs
):
def
vformat
(
self
,
format_string
,
args
,
kwargs
):
...
...
Lib/test/test_string.py
Dosyayı görüntüle @
009b0a1f
...
@@ -48,9 +48,8 @@ class ModuleTest(unittest.TestCase):
...
@@ -48,9 +48,8 @@ class ModuleTest(unittest.TestCase):
self
.
assertEqual
(
fmt
.
format
(
"-{format_string}-"
,
format_string
=
'test'
),
self
.
assertEqual
(
fmt
.
format
(
"-{format_string}-"
,
format_string
=
'test'
),
'-test-'
)
'-test-'
)
self
.
assertRaises
(
KeyError
,
fmt
.
format
,
"-{format_string}-"
)
self
.
assertRaises
(
KeyError
,
fmt
.
format
,
"-{format_string}-"
)
with
self
.
assertWarnsRegex
(
DeprecationWarning
,
"format_string"
):
with
self
.
assertRaisesRegex
(
TypeError
,
"format_string"
):
self
.
assertEqual
(
fmt
.
format
(
arg
=
'test'
,
format_string
=
"-{arg}-"
),
fmt
.
format
(
format_string
=
"-{arg}-"
,
arg
=
'test'
)
'-test-'
)
def
test_auto_numbering
(
self
):
def
test_auto_numbering
(
self
):
fmt
=
string
.
Formatter
()
fmt
=
string
.
Formatter
()
...
...
Misc/NEWS
Dosyayı görüntüle @
009b0a1f
...
@@ -212,6 +212,9 @@ Core and Builtins
...
@@ -212,6 +212,9 @@ Core and Builtins
Library
Library
-------
-------
-
Issue
#
29193
:
A
format
string
argument
for
string
.
Formatter
.
format
()
is
now
positional
-
only
.
-
Issue
#
29195
:
Removed
support
of
deprecated
undocumented
keyword
arguments
-
Issue
#
29195
:
Removed
support
of
deprecated
undocumented
keyword
arguments
in
methods
of
regular
expression
objects
.
in
methods
of
regular
expression
objects
.
...
...
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