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
a8abe097
Kaydet (Commit)
a8abe097
authored
Nis 09, 2019
tarafından
Matthias Bussonnier
Kaydeden (comit)
Inada Naoki
Nis 09, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-33461: emit DeprecationWarning when json.loads(encoding=...) is used (GH-6762)
üst
5909ad12
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
4 deletions
+22
-4
json.rst
Doc/library/json.rst
+5
-2
__init__.py
Lib/json/__init__.py
+11
-2
test_decode.py
Lib/test/test_json/test_decode.py
+4
-0
2019-04-09-14-46-28.bpo-33461.SYJM-E.rst
...S.d/next/Library/2019-04-09-14-46-28.bpo-33461.SYJM-E.rst
+2
-0
No files found.
Doc/library/json.rst
Dosyayı görüntüle @
a8abe097
...
...
@@ -265,18 +265,21 @@ Basic Usage
*fp* can now be a :term:`binary file`. The input encoding should be
UTF-8, UTF-16 or UTF-32.
.. function:: loads(s, *,
encoding=None,
cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)
.. function:: loads(s, *, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)
Deserialize *s* (a :class:`str`, :class:`bytes` or :class:`bytearray`
instance containing a JSON document) to a Python object using this
:ref:`conversion table <json-to-py-table>`.
The other arguments have the same meaning as in :func:`load`, except
*encoding* which is ignored and deprecated.
*encoding* which is ignored and deprecated
since Python 3.1
.
If the data being deserialized is not a valid JSON document, a
:exc:`JSONDecodeError` will be raised.
.. deprecated-removed:: 3.1 3.9
*encoding* keyword argument.
.. versionchanged:: 3.6
*s* can now be of type :class:`bytes` or :class:`bytearray`. The
input encoding should be UTF-8, UTF-16 or UTF-32.
...
...
Lib/json/__init__.py
Dosyayı görüntüle @
a8abe097
...
...
@@ -296,7 +296,7 @@ def load(fp, *, cls=None, object_hook=None, parse_float=None,
parse_constant
=
parse_constant
,
object_pairs_hook
=
object_pairs_hook
,
**
kw
)
def
loads
(
s
,
*
,
encoding
=
None
,
cls
=
None
,
object_hook
=
None
,
parse_float
=
None
,
def
loads
(
s
,
*
,
cls
=
None
,
object_hook
=
None
,
parse_float
=
None
,
parse_int
=
None
,
parse_constant
=
None
,
object_pairs_hook
=
None
,
**
kw
):
"""Deserialize ``s`` (a ``str``, ``bytes`` or ``bytearray`` instance
containing a JSON document) to a Python object.
...
...
@@ -330,7 +330,7 @@ def loads(s, *, encoding=None, cls=None, object_hook=None, parse_float=None,
To use a custom ``JSONDecoder`` subclass, specify it with the ``cls``
kwarg; otherwise ``JSONDecoder`` is used.
The ``encoding`` argument is ignored and deprecated.
The ``encoding`` argument is ignored and deprecated
since Python 3.1
.
"""
if
isinstance
(
s
,
str
):
if
s
.
startswith
(
'
\ufeff
'
):
...
...
@@ -342,6 +342,15 @@ def loads(s, *, encoding=None, cls=None, object_hook=None, parse_float=None,
f
'not {s.__class__.__name__}'
)
s
=
s
.
decode
(
detect_encoding
(
s
),
'surrogatepass'
)
if
"encoding"
in
kw
:
import
warnings
warnings
.
warn
(
"'encoding' is ignored and deprecated. It will be removed in Python 3.9"
,
DeprecationWarning
,
stacklevel
=
2
)
del
kw
[
'encoding'
]
if
(
cls
is
None
and
object_hook
is
None
and
parse_int
is
None
and
parse_float
is
None
and
parse_constant
is
None
and
object_pairs_hook
is
None
and
not
kw
):
...
...
Lib/test/test_json/test_decode.py
Dosyayı görüntüle @
a8abe097
...
...
@@ -95,5 +95,9 @@ class TestDecode:
d
=
self
.
json
.
JSONDecoder
()
self
.
assertRaises
(
ValueError
,
d
.
raw_decode
,
'a'
*
42
,
-
50000
)
def
test_deprecated_encode
(
self
):
with
self
.
assertWarns
(
DeprecationWarning
):
self
.
loads
(
'{}'
,
encoding
=
'fake'
)
class
TestPyDecode
(
TestDecode
,
PyTest
):
pass
class
TestCDecode
(
TestDecode
,
CTest
):
pass
Misc/NEWS.d/next/Library/2019-04-09-14-46-28.bpo-33461.SYJM-E.rst
0 → 100644
Dosyayı görüntüle @
a8abe097
``json.loads`` now emits ``DeprecationWarning`` when ``encoding`` option is
specified. Patch by Matthias Bussonnier.
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