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
cc32a119
Kaydet (Commit)
cc32a119
authored
Nis 26, 2009
tarafından
Eric Smith
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #5835: Deprecate PyOS_ascii_formatd.
üst
886b40aa
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
3 deletions
+58
-3
conversion.rst
Doc/c-api/conversion.rst
+37
-0
NEWS
Misc/NEWS
+2
-0
pystrtod.c
Python/pystrtod.c
+19
-3
No files found.
Doc/c-api/conversion.rst
Dosyayı görüntüle @
cc32a119
...
...
@@ -73,6 +73,43 @@ The following functions provide locale-independent string to number conversions.
The return value is a pointer to *buffer* with the converted string or NULL if
the conversion failed.
.. deprecated:: 3.1
Use :cfunc:`PyOS_double_to_string` instead.
.. cfunction:: char* PyOS_double_to_string(double val, char format_code, int precision, int flags, int *ptype)
Convert a :ctype:`double` *val* to a string using supplied
*format_code*, *precision*, and *flags*.
*format_code* must be one of ``'e'``, ``'E'``, ``'f'``, ``'F'``, ``'g'``,
``'G'``, ``'s'``, or ``'r'``. For ``'s'`` and ``'r'``, the supplied
*precision* must be 0 and is ignored. These specify the standard
:func:`str` and :func:`repr` formats, respectively.
*flags* can be zero or more of the values *Py_DTSF_SIGN*,
*Py_DTSF_ADD_DOT_0*, or *Py_DTSF_ALT*, or-ed together:
* *Py_DTSF_SIGN* means to always precede the returned string with a sign
character, even if *val* is non-negative.
* *Py_DTSF_ADD_DOT_0* means to ensure that the returned string will not look
like an integer.
* *Py_DTSF_ALT* means to apply "alternate" formatting rules. See the
documentation for the :cfunc:`PyOS_snprintf` ``'#'`` specifier for
details.
If *ptype* is non-NULL, then the value it points to will be set to one of
*Py_DTST_FINITE*, *Py_DTST_INFINITE*, or *Py_DTST_NAN*, signifying that
*val* is a finite number, an infinite number, or not a number, respectively.
The return value is a pointer to *buffer* with the converted string or
*NULL* if the conversion failed. The caller is responsible for freeing the
returned string by calling :cfunc:`PyMem_Free`.
.. versionadded:: 3.1
.. cfunction:: double PyOS_ascii_atof(const char *nptr)
...
...
Misc/NEWS
Dosyayı görüntüle @
cc32a119
...
...
@@ -12,6 +12,8 @@ What's New in Python 3.1 beta 1?
Core and Builtins
-----------------
- Issue #5835: Deprecate PyOS_ascii_formatd.
- Issue #4971: Fix titlecase for characters that are their own
titlecase, but not their own uppercase.
...
...
Python/pystrtod.c
Dosyayı görüntüle @
cc32a119
...
...
@@ -433,7 +433,7 @@ ensure_decimal_point(char* buffer, size_t buf_size)
* Return value: The pointer to the buffer with the converted string.
**/
char
*
PyOS_ascii_formatd
(
char
*
buffer
,
_
PyOS_ascii_formatd
(
char
*
buffer
,
size_t
buf_size
,
const
char
*
format
,
double
d
)
...
...
@@ -508,6 +508,20 @@ PyOS_ascii_formatd(char *buffer,
return
buffer
;
}
char
*
PyOS_ascii_formatd
(
char
*
buffer
,
size_t
buf_size
,
const
char
*
format
,
double
d
)
{
if
(
PyErr_WarnEx
(
PyExc_DeprecationWarning
,
"PyOS_ascii_formatd is deprecated, "
"use PyOS_double_to_string instead"
,
1
)
<
0
)
return
NULL
;
return
_PyOS_ascii_formatd
(
buffer
,
buf_size
,
format
,
d
);
}
#ifdef PY_NO_SHORT_FLOAT_REPR
/* The fallback code to use if _Py_dg_dtoa is not available. */
...
...
@@ -638,8 +652,10 @@ PyAPI_FUNC(char *) PyOS_double_to_string(double val,
if
((
flags
&
Py_DTSF_ADD_DOT_0
)
&&
(
format_code
!=
'e'
))
format_code
=
'Z'
;
PyOS_snprintf
(
format
,
32
,
"%%%s.%i%c"
,
(
flags
&
Py_DTSF_ALT
?
"#"
:
""
),
precision
,
format_code
);
PyOS_ascii_formatd
(
buf
,
sizeof
(
buf
),
format
,
val
);
PyOS_snprintf
(
format
,
sizeof
(
format
),
"%%%s.%i%c"
,
(
flags
&
Py_DTSF_ALT
?
"#"
:
""
),
precision
,
format_code
);
_PyOS_ascii_formatd
(
buf
,
sizeof
(
buf
),
format
,
val
);
/* remove trailing zeros if necessary */
if
(
strip_trailing_zeros
)
remove_trailing_zeros
(
buf
);
...
...
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