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
b1a1619b
Kaydet (Commit)
b1a1619b
authored
Ara 17, 2016
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #29000: Fixed bytes formatting of octals with zero padding in alternate
form.
üst
af56e0e7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
11 deletions
+31
-11
test_format.py
Lib/test/test_format.py
+26
-8
NEWS
Misc/NEWS
+3
-0
bytesobject.c
Objects/bytesobject.c
+2
-3
No files found.
Lib/test/test_format.py
Dosyayı görüntüle @
b1a1619b
...
...
@@ -114,6 +114,7 @@ class FormatTest(unittest.TestCase):
testcommon
(
"
%
o"
,
100000000000
,
"1351035564000"
)
testcommon
(
"
%
d"
,
10
,
"10"
)
testcommon
(
"
%
d"
,
100000000000
,
"100000000000"
)
big
=
123456789012345678901234567890
testcommon
(
"
%
d"
,
big
,
"123456789012345678901234567890"
)
testcommon
(
"
%
d"
,
-
big
,
"-123456789012345678901234567890"
)
...
...
@@ -133,6 +134,7 @@ class FormatTest(unittest.TestCase):
testcommon
(
"
%.31
d"
,
big
,
"0123456789012345678901234567890"
)
testcommon
(
"
%32.31
d"
,
big
,
" 0123456789012345678901234567890"
)
testcommon
(
"
%
d"
,
float
(
big
),
"123456________________________"
,
6
)
big
=
0x1234567890abcdef12345
# 21 hex digits
testcommon
(
"
%
x"
,
big
,
"1234567890abcdef12345"
)
testcommon
(
"
%
x"
,
-
big
,
"-1234567890abcdef12345"
)
...
...
@@ -156,19 +158,26 @@ class FormatTest(unittest.TestCase):
testcommon
(
"
%#
X"
,
big
,
"0X1234567890ABCDEF12345"
)
testcommon
(
"
%#
x"
,
big
,
"0x1234567890abcdef12345"
)
testcommon
(
"
%#
x"
,
-
big
,
"-0x1234567890abcdef12345"
)
testcommon
(
"
%#27
x"
,
big
,
" 0x1234567890abcdef12345"
)
testcommon
(
"
%#-27
x"
,
big
,
"0x1234567890abcdef12345 "
)
testcommon
(
"
%#027
x"
,
big
,
"0x00001234567890abcdef12345"
)
testcommon
(
"
%#.23
x"
,
big
,
"0x001234567890abcdef12345"
)
testcommon
(
"
%#.23
x"
,
-
big
,
"-0x001234567890abcdef12345"
)
testcommon
(
"
%#27.23
x"
,
big
,
" 0x001234567890abcdef12345"
)
testcommon
(
"
%#-27.23
x"
,
big
,
"0x001234567890abcdef12345 "
)
testcommon
(
"
%#027.23
x"
,
big
,
"0x00001234567890abcdef12345"
)
testcommon
(
"
%#+.23
x"
,
big
,
"+0x001234567890abcdef12345"
)
testcommon
(
"
%# .23
x"
,
big
,
" 0x001234567890abcdef12345"
)
testcommon
(
"
%#+.23
X"
,
big
,
"+0X001234567890ABCDEF12345"
)
testcommon
(
"
%#-+.23
X"
,
big
,
"+0X001234567890ABCDEF12345"
)
testcommon
(
"
%#-+26.23
X"
,
big
,
"+0X001234567890ABCDEF12345"
)
testcommon
(
"
%#-+27.23
X"
,
big
,
"+0X001234567890ABCDEF12345 "
)
testcommon
(
"
%#+27.23
X"
,
big
,
" +0X001234567890ABCDEF12345"
)
# next one gets two leading zeroes from precision, and another from the
# 0 flag and the width
testcommon
(
"
%#+027.23
X"
,
big
,
"+0X0001234567890ABCDEF12345"
)
testcommon
(
"
%# 027.23
X"
,
big
,
" 0X0001234567890ABCDEF12345"
)
# same, except no 0 flag
testcommon
(
"
%#+27.23
X"
,
big
,
" +0X001234567890ABCDEF12345"
)
testcommon
(
"
%#-+27.23
x"
,
big
,
"+0x001234567890abcdef12345 "
)
testcommon
(
"
%#- 27.23
x"
,
big
,
" 0x001234567890abcdef12345 "
)
big
=
0
o12345670123456701234567012345670
# 32 octal digits
testcommon
(
"
%
o"
,
big
,
"12345670123456701234567012345670"
)
testcommon
(
"
%
o"
,
-
big
,
"-12345670123456701234567012345670"
)
...
...
@@ -191,13 +200,21 @@ class FormatTest(unittest.TestCase):
testcommon
(
"
%
o"
,
big
,
"12345670123456701234567012345670"
)
testcommon
(
"
%#
o"
,
big
,
"0o12345670123456701234567012345670"
)
testcommon
(
"
%#
o"
,
-
big
,
"-0o12345670123456701234567012345670"
)
testcommon
(
"
%#38
o"
,
big
,
" 0o12345670123456701234567012345670"
)
testcommon
(
"
%#-38
o"
,
big
,
"0o12345670123456701234567012345670 "
)
testcommon
(
"
%#038
o"
,
big
,
"0o000012345670123456701234567012345670"
)
testcommon
(
"
%#.34
o"
,
big
,
"0o0012345670123456701234567012345670"
)
testcommon
(
"
%#.34
o"
,
-
big
,
"-0o0012345670123456701234567012345670"
)
testcommon
(
"
%#38.34
o"
,
big
,
" 0o0012345670123456701234567012345670"
)
testcommon
(
"
%#-38.34
o"
,
big
,
"0o0012345670123456701234567012345670 "
)
testcommon
(
"
%#038.34
o"
,
big
,
"0o000012345670123456701234567012345670"
)
testcommon
(
"
%#+.34
o"
,
big
,
"+0o0012345670123456701234567012345670"
)
testcommon
(
"
%# .34
o"
,
big
,
" 0o0012345670123456701234567012345670"
)
testcommon
(
"
%#+.34
o"
,
big
,
"+0o0012345670123456701234567012345670"
)
testcommon
(
"
%#-+.34
o"
,
big
,
"+0o0012345670123456701234567012345670"
)
testcommon
(
"
%#-+37.34
o"
,
big
,
"+0o0012345670123456701234567012345670"
)
testcommon
(
"
%#+37.34
o"
,
big
,
"+0o0012345670123456701234567012345670"
)
testcommon
(
"
%#+38.34
o"
,
big
,
" +0o0012345670123456701234567012345670"
)
testcommon
(
"
%#-+38.34
o"
,
big
,
"+0o0012345670123456701234567012345670 "
)
testcommon
(
"
%#- 38.34
o"
,
big
,
" 0o0012345670123456701234567012345670 "
)
testcommon
(
"
%#+038.34
o"
,
big
,
"+0o00012345670123456701234567012345670"
)
testcommon
(
"
%# 038.34
o"
,
big
,
" 0o00012345670123456701234567012345670"
)
# next one gets one leading zero from precision
testcommon
(
"
%.33
o"
,
big
,
"012345670123456701234567012345670"
)
# base marker added in spite of leading zero (different to Python 2)
...
...
@@ -208,6 +225,7 @@ class FormatTest(unittest.TestCase):
testcommon
(
"
%035.33
o"
,
big
,
"00012345670123456701234567012345670"
)
# base marker shouldn't change the size
testcommon
(
"
%0#35.33
o"
,
big
,
"0o012345670123456701234567012345670"
)
# Some small ints, in both Python int and flavors).
testcommon
(
"
%
d"
,
42
,
"42"
)
testcommon
(
"
%
d"
,
-
42
,
"-42"
)
...
...
Misc/NEWS
Dosyayı görüntüle @
b1a1619b
...
...
@@ -10,6 +10,9 @@ Release date: TBA
Core and Builtins
-----------------
- Issue #29000: Fixed bytes formatting of octals with zero padding in alternate
form.
- Issue #28512: Fixed setting the offset attribute of SyntaxError by
PyErr_SyntaxLocationEx() and PyErr_SyntaxLocationObject().
...
...
Objects/bytesobject.c
Dosyayı görüntüle @
b1a1619b
...
...
@@ -882,7 +882,7 @@ _PyBytes_Format(PyObject *format, PyObject *args)
if
(
width
>
len
)
width
--
;
}
if
((
flags
&
F_ALT
)
&&
(
c
==
'x'
||
c
==
'X'
))
{
if
((
flags
&
F_ALT
)
&&
(
c
==
'
o'
||
c
==
'
x'
||
c
==
'X'
))
{
assert
(
pbuf
[
0
]
==
'0'
);
assert
(
pbuf
[
1
]
==
c
);
if
(
fill
!=
' '
)
{
...
...
@@ -904,8 +904,7 @@ _PyBytes_Format(PyObject *format, PyObject *args)
if
(
fill
==
' '
)
{
if
(
sign
)
*
res
++
=
sign
;
if
((
flags
&
F_ALT
)
&&
(
c
==
'x'
||
c
==
'X'
))
{
if
((
flags
&
F_ALT
)
&&
(
c
==
'o'
||
c
==
'x'
||
c
==
'X'
))
{
assert
(
pbuf
[
0
]
==
'0'
);
assert
(
pbuf
[
1
]
==
c
);
*
res
++
=
*
pbuf
++
;
...
...
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