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
1dd49824
Kaydet (Commit)
1dd49824
authored
Mar 20, 2015
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #23681: The -b option now affects comparisons of bytes with int.
üst
ee4c0b9d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
22 deletions
+53
-22
cmdline.rst
Doc/using/cmdline.rst
+4
-1
3.5.rst
Doc/whatsnew/3.5.rst
+2
-0
test_bytes.py
Lib/test/test_bytes.py
+28
-13
NEWS
Misc/NEWS
+2
-0
bytesobject.c
Objects/bytesobject.c
+17
-8
No files found.
Doc/using/cmdline.rst
Dosyayı görüntüle @
1dd49824
...
@@ -190,9 +190,12 @@ Miscellaneous options
...
@@ -190,9 +190,12 @@ Miscellaneous options
..
cmdoption
::
-
b
..
cmdoption
::
-
b
Issue
a
warning
when
comparing
str
and
bytes
.
Issue
an
error
when
the
Issue
a
warning
when
comparing
:
class
:`
bytes
`
or
:
class
:`
bytearray
`
with
:
class
:`
str
`
or
:
class
:`
bytes
`
with
:
class
:`
int
`.
Issue
an
error
when
the
option
is
given
twice
(:
option
:`-
bb
`).
option
is
given
twice
(:
option
:`-
bb
`).
..
versionchanged
:
3.5
Affects
comparisons
of
:
class
:`
bytes
`
with
:
class
:`
int
`.
..
cmdoption
::
-
B
..
cmdoption
::
-
B
...
...
Doc/whatsnew/3.5.rst
Dosyayı görüntüle @
1dd49824
...
@@ -162,6 +162,8 @@ Some smaller changes made to the core Python language are:
...
@@ -162,6 +162,8 @@ Some smaller changes made to the core Python language are:
error handlers now works with decoding and translating.
error handlers now works with decoding and translating.
(Contributed by Serhiy Storchaka in :issue:`19676` and :issue:`22286`.)
(Contributed by Serhiy Storchaka in :issue:`19676` and :issue:`22286`.)
* The :option:`-b` option now affects comparisons of :class:`bytes` with
:class:`int`. (Contributed by Serhiy Storchaka in :issue:`23681`)
New Modules
New Modules
...
...
Lib/test/test_bytes.py
Dosyayı görüntüle @
1dd49824
...
@@ -1338,20 +1338,35 @@ class AssortedBytesTest(unittest.TestCase):
...
@@ -1338,20 +1338,35 @@ class AssortedBytesTest(unittest.TestCase):
b
=
bytearray
()
b
=
bytearray
()
self
.
assertFalse
(
b
.
replace
(
b
''
,
b
''
)
is
b
)
self
.
assertFalse
(
b
.
replace
(
b
''
,
b
''
)
is
b
)
@unittest.skipUnless
(
sys
.
flags
.
bytes_warning
,
"BytesWarning is needed for this test: use -bb option"
)
def
test_compare
(
self
):
def
test_compare
(
self
):
if
sys
.
flags
.
bytes_warning
:
def
bytes_warning
():
def
bytes_warning
():
return
test
.
support
.
check_warnings
((
''
,
BytesWarning
))
return
test
.
support
.
check_warnings
((
''
,
BytesWarning
))
with
bytes_warning
():
with
bytes_warning
():
b
''
==
''
b
''
==
''
with
bytes_warning
():
with
bytes_warning
():
''
==
b
''
b
''
!=
''
with
bytes_warning
():
with
bytes_warning
():
b
''
!=
''
bytearray
(
b
''
)
==
''
with
bytes_warning
():
with
bytes_warning
():
''
!=
b
''
bytearray
(
b
''
)
!=
''
with
bytes_warning
():
else
:
bytearray
(
b
''
)
==
''
self
.
skipTest
(
"BytesWarning is needed for this test: use -bb option"
)
with
bytes_warning
():
''
==
bytearray
(
b
''
)
with
bytes_warning
():
bytearray
(
b
''
)
!=
''
with
bytes_warning
():
''
!=
bytearray
(
b
''
)
with
bytes_warning
():
b
'
\0
'
==
0
with
bytes_warning
():
0
==
b
'
\0
'
with
bytes_warning
():
b
'
\0
'
!=
0
with
bytes_warning
():
0
!=
b
'
\0
'
# Optimizations:
# Optimizations:
# __iter__? (optimization)
# __iter__? (optimization)
...
...
Misc/NEWS
Dosyayı görüntüle @
1dd49824
...
@@ -10,6 +10,8 @@ Release date: 2015-03-28
...
@@ -10,6 +10,8 @@ Release date: 2015-03-28
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #23681: The -b option now affects comparisons of bytes with int.
- Issue #23632: Memoryviews now allow tuple indexing (including for
- Issue #23632: Memoryviews now allow tuple indexing (including for
multi-dimensional memoryviews).
multi-dimensional memoryviews).
...
...
Objects/bytesobject.c
Dosyayı görüntüle @
1dd49824
...
@@ -1385,14 +1385,23 @@ bytes_richcompare(PyBytesObject *a, PyBytesObject *b, int op)
...
@@ -1385,14 +1385,23 @@ bytes_richcompare(PyBytesObject *a, PyBytesObject *b, int op)
/* Make sure both arguments are strings. */
/* Make sure both arguments are strings. */
if
(
!
(
PyBytes_Check
(
a
)
&&
PyBytes_Check
(
b
)))
{
if
(
!
(
PyBytes_Check
(
a
)
&&
PyBytes_Check
(
b
)))
{
if
(
Py_BytesWarningFlag
&&
(
op
==
Py_EQ
||
op
==
Py_NE
)
&&
if
(
Py_BytesWarningFlag
&&
(
op
==
Py_EQ
||
op
==
Py_NE
))
{
(
PyObject_IsInstance
((
PyObject
*
)
a
,
if
(
PyObject_IsInstance
((
PyObject
*
)
a
,
(
PyObject
*
)
&
PyUnicode_Type
)
||
(
PyObject
*
)
&
PyUnicode_Type
)
||
PyObject_IsInstance
((
PyObject
*
)
b
,
PyObject_IsInstance
((
PyObject
*
)
b
,
(
PyObject
*
)
&
PyUnicode_Type
)))
{
(
PyObject
*
)
&
PyUnicode_Type
))
{
if
(
PyErr_WarnEx
(
PyExc_BytesWarning
,
if
(
PyErr_WarnEx
(
PyExc_BytesWarning
,
"Comparison between bytes and string"
,
1
))
"Comparison between bytes and string"
,
1
))
return
NULL
;
return
NULL
;
}
else
if
(
PyObject_IsInstance
((
PyObject
*
)
a
,
(
PyObject
*
)
&
PyLong_Type
)
||
PyObject_IsInstance
((
PyObject
*
)
b
,
(
PyObject
*
)
&
PyLong_Type
))
{
if
(
PyErr_WarnEx
(
PyExc_BytesWarning
,
"Comparison between bytes and int"
,
1
))
return
NULL
;
}
}
}
result
=
Py_NotImplemented
;
result
=
Py_NotImplemented
;
}
}
...
...
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