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
150ea1a1
Kaydet (Commit)
150ea1a1
authored
Şub 24, 2016
tarafından
Martin Panter
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #22088: Merge base64 docs from 3.5
üst
3d2778c8
ee3074e1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
15 deletions
+34
-15
base64.rst
Doc/library/base64.rst
+16
-13
base64.py
Lib/base64.py
+0
-0
test_base64.py
Lib/test/test_base64.py
+18
-2
No files found.
Doc/library/base64.rst
Dosyayı görüntüle @
150ea1a1
...
@@ -24,8 +24,8 @@ POST request. The encoding algorithm is not the same as the
...
@@ -24,8 +24,8 @@ POST request. The encoding algorithm is not the same as the
There
are
two
interfaces
provided
by
this
module
.
The
modern
interface
There
are
two
interfaces
provided
by
this
module
.
The
modern
interface
supports
encoding
:
term
:`
bytes
-
like
objects
<
bytes
-
like
object
>`
to
ASCII
supports
encoding
:
term
:`
bytes
-
like
objects
<
bytes
-
like
object
>`
to
ASCII
:
class
:`
bytes
`,
and
decoding
:
term
:`
bytes
-
like
objects
<
bytes
-
like
object
>`
or
:
class
:`
bytes
`,
and
decoding
:
term
:`
bytes
-
like
objects
<
bytes
-
like
object
>`
or
strings
containing
ASCII
to
:
class
:`
bytes
`.
All
three
:
rfc
:`
3548
`
defined
strings
containing
ASCII
to
:
class
:`
bytes
`.
Both
base
-
64
alphabets
alphabets
(
normal
,
URL
-
safe
,
and
filesystem
-
safe
)
are
supported
.
defined
in
:
rfc
:`
3548
`
(
normal
,
and
URL
-
and
filesystem
-
safe
)
are
supported
.
The
legacy
interface
does
not
support
decoding
from
strings
,
but
it
does
The
legacy
interface
does
not
support
decoding
from
strings
,
but
it
does
provide
functions
for
encoding
and
decoding
to
and
from
:
term
:`
file
objects
provide
functions
for
encoding
and
decoding
to
and
from
:
term
:`
file
objects
...
@@ -69,9 +69,10 @@ The modern interface provides:
...
@@ -69,9 +69,10 @@ The modern interface provides:
A
:
exc
:`
binascii
.
Error
`
exception
is
raised
A
:
exc
:`
binascii
.
Error
`
exception
is
raised
if
*
s
*
is
incorrectly
padded
.
if
*
s
*
is
incorrectly
padded
.
If
*
validate
*
is
``
False
``
(
the
default
),
non
-
base64
-
alphabet
characters
are
If
*
validate
*
is
``
False
``
(
the
default
),
characters
that
are
neither
in
the
normal
base
-
64
alphabet
nor
the
alternative
alphabet
are
discarded
prior
to
the
padding
check
.
If
*
validate
*
is
``
True
``,
discarded
prior
to
the
padding
check
.
If
*
validate
*
is
``
True
``,
non
-
base64
-
alphabet
characters
in
the
input
result
in
a
these
non
-
alphabet
characters
in
the
input
result
in
a
:
exc
:`
binascii
.
Error
`.
:
exc
:`
binascii
.
Error
`.
...
@@ -89,7 +90,8 @@ The modern interface provides:
...
@@ -89,7 +90,8 @@ The modern interface provides:
..
function
::
urlsafe_b64encode
(
s
)
..
function
::
urlsafe_b64encode
(
s
)
Encode
:
term
:`
bytes
-
like
object
`
*
s
*
using
a
URL
-
safe
alphabet
,
which
Encode
:
term
:`
bytes
-
like
object
`
*
s
*
using
the
URL
-
and
filesystem
-
safe
alphabet
,
which
substitutes
``-``
instead
of
``+``
and
``
_
``
instead
of
``/``
in
the
substitutes
``-``
instead
of
``+``
and
``
_
``
instead
of
``/``
in
the
standard
Base64
alphabet
,
and
return
the
encoded
:
class
:`
bytes
`.
The
result
standard
Base64
alphabet
,
and
return
the
encoded
:
class
:`
bytes
`.
The
result
can
still
contain
``=``.
can
still
contain
``=``.
...
@@ -97,7 +99,8 @@ The modern interface provides:
...
@@ -97,7 +99,8 @@ The modern interface provides:
..
function
::
urlsafe_b64decode
(
s
)
..
function
::
urlsafe_b64decode
(
s
)
Decode
:
term
:`
bytes
-
like
object
`
or
ASCII
string
*
s
*
using
a
URL
-
safe
Decode
:
term
:`
bytes
-
like
object
`
or
ASCII
string
*
s
*
using
the
URL
-
and
filesystem
-
safe
alphabet
,
which
substitutes
``-``
instead
of
``+``
and
``
_
``
instead
of
alphabet
,
which
substitutes
``-``
instead
of
``+``
and
``
_
``
instead
of
``/``
in
the
standard
Base64
alphabet
,
and
return
the
decoded
``/``
in
the
standard
Base64
alphabet
,
and
return
the
decoded
:
class
:`
bytes
`.
:
class
:`
bytes
`.
...
@@ -145,14 +148,14 @@ The modern interface provides:
...
@@ -145,14 +148,14 @@ The modern interface provides:
lowercase
alphabet
is
acceptable
as
input
.
For
security
purposes
,
the
default
lowercase
alphabet
is
acceptable
as
input
.
For
security
purposes
,
the
default
is
``
False
``.
is
``
False
``.
A
:
exc
:`
Type
Error
`
is
raised
if
*
s
*
is
A
:
exc
:`
binascii
.
Error
`
is
raised
if
*
s
*
is
incorrectly
padded
or
if
there
are
non
-
alphabet
characters
present
in
the
incorrectly
padded
or
if
there
are
non
-
alphabet
characters
present
in
the
input
.
input
.
..
function
::
a85encode
(
s
,
*,
foldspaces
=
False
,
wrapcol
=
0
,
pad
=
False
,
adobe
=
False
)
..
function
::
a85encode
(
b
,
*,
foldspaces
=
False
,
wrapcol
=
0
,
pad
=
False
,
adobe
=
False
)
Encode
the
:
term
:`
bytes
-
like
object
`
*
s
*
using
Ascii85
and
return
the
Encode
the
:
term
:`
bytes
-
like
object
`
*
b
*
using
Ascii85
and
return
the
encoded
:
class
:`
bytes
`.
encoded
:
class
:`
bytes
`.
*
foldspaces
*
is
an
optional
flag
that
uses
the
special
short
sequence
'y'
*
foldspaces
*
is
an
optional
flag
that
uses
the
special
short
sequence
'y'
...
@@ -172,9 +175,9 @@ The modern interface provides:
...
@@ -172,9 +175,9 @@ The modern interface provides:
..
versionadded
::
3.4
..
versionadded
::
3.4
..
function
::
a85decode
(
s
,
*,
foldspaces
=
False
,
adobe
=
False
,
ignorechars
=
b
' \\t\\n\\r\\v'
)
..
function
::
a85decode
(
b
,
*,
foldspaces
=
False
,
adobe
=
False
,
ignorechars
=
b
' \\t\\n\\r\\v'
)
Decode
the
Ascii85
encoded
:
term
:`
bytes
-
like
object
`
or
ASCII
string
*
s
*
and
Decode
the
Ascii85
encoded
:
term
:`
bytes
-
like
object
`
or
ASCII
string
*
b
*
and
return
the
decoded
:
class
:`
bytes
`.
return
the
decoded
:
class
:`
bytes
`.
*
foldspaces
*
is
a
flag
that
specifies
whether
the
'y'
short
sequence
*
foldspaces
*
is
a
flag
that
specifies
whether
the
'y'
short
sequence
...
@@ -192,9 +195,9 @@ The modern interface provides:
...
@@ -192,9 +195,9 @@ The modern interface provides:
..
versionadded
::
3.4
..
versionadded
::
3.4
..
function
::
b85encode
(
s
,
pad
=
False
)
..
function
::
b85encode
(
b
,
pad
=
False
)
Encode
the
:
term
:`
bytes
-
like
object
`
*
s
*
using
base85
(
as
used
in
e
.
g
.
Encode
the
:
term
:`
bytes
-
like
object
`
*
b
*
using
base85
(
as
used
in
e
.
g
.
git
-
style
binary
diffs
)
and
return
the
encoded
:
class
:`
bytes
`.
git
-
style
binary
diffs
)
and
return
the
encoded
:
class
:`
bytes
`.
If
*
pad
*
is
true
,
the
input
is
padded
with
``
b
'\0'
``
so
its
length
is
a
If
*
pad
*
is
true
,
the
input
is
padded
with
``
b
'\0'
``
so
its
length
is
a
...
...
Lib/base64.py
Dosyayı görüntüle @
150ea1a1
This diff is collapsed.
Click to expand it.
Lib/test/test_base64.py
Dosyayı görüntüle @
150ea1a1
...
@@ -243,14 +243,26 @@ class BaseXYTestCase(unittest.TestCase):
...
@@ -243,14 +243,26 @@ class BaseXYTestCase(unittest.TestCase):
(
b
'@@'
,
b
''
),
(
b
'@@'
,
b
''
),
(
b
'!'
,
b
''
),
(
b
'!'
,
b
''
),
(
b
'YWJj
\n
YWI='
,
b
'abcab'
))
(
b
'YWJj
\n
YWI='
,
b
'abcab'
))
funcs
=
(
base64
.
b64decode
,
base64
.
standard_b64decode
,
base64
.
urlsafe_b64decode
,
)
for
bstr
,
res
in
tests
:
for
bstr
,
res
in
tests
:
self
.
assertEqual
(
base64
.
b64decode
(
bstr
),
res
)
for
func
in
funcs
:
self
.
assertEqual
(
base64
.
b64decode
(
bstr
.
decode
(
'ascii'
)),
res
)
with
self
.
subTest
(
bstr
=
bstr
,
func
=
func
):
self
.
assertEqual
(
func
(
bstr
),
res
)
self
.
assertEqual
(
func
(
bstr
.
decode
(
'ascii'
)),
res
)
with
self
.
assertRaises
(
binascii
.
Error
):
with
self
.
assertRaises
(
binascii
.
Error
):
base64
.
b64decode
(
bstr
,
validate
=
True
)
base64
.
b64decode
(
bstr
,
validate
=
True
)
with
self
.
assertRaises
(
binascii
.
Error
):
with
self
.
assertRaises
(
binascii
.
Error
):
base64
.
b64decode
(
bstr
.
decode
(
'ascii'
),
validate
=
True
)
base64
.
b64decode
(
bstr
.
decode
(
'ascii'
),
validate
=
True
)
# Normal alphabet characters not discarded when alternative given
res
=
b
'
\xFB\xEF\xBE\xFF\xFF\xFF
'
self
.
assertEqual
(
base64
.
b64decode
(
b
'++[[//]]'
,
b
'[]'
),
res
)
self
.
assertEqual
(
base64
.
urlsafe_b64decode
(
b
'++--//__'
),
res
)
def
test_b32encode
(
self
):
def
test_b32encode
(
self
):
eq
=
self
.
assertEqual
eq
=
self
.
assertEqual
eq
(
base64
.
b32encode
(
b
''
),
b
''
)
eq
(
base64
.
b32encode
(
b
''
),
b
''
)
...
@@ -360,6 +372,10 @@ class BaseXYTestCase(unittest.TestCase):
...
@@ -360,6 +372,10 @@ class BaseXYTestCase(unittest.TestCase):
b
'
\x01\x02\xab\xcd\xef
'
)
b
'
\x01\x02\xab\xcd\xef
'
)
eq
(
base64
.
b16decode
(
array
(
'B'
,
b
"0102abcdef"
),
True
),
eq
(
base64
.
b16decode
(
array
(
'B'
,
b
"0102abcdef"
),
True
),
b
'
\x01\x02\xab\xcd\xef
'
)
b
'
\x01\x02\xab\xcd\xef
'
)
# Non-alphabet characters
self
.
assertRaises
(
binascii
.
Error
,
base64
.
b16decode
,
'0102AG'
)
# Incorrect "padding"
self
.
assertRaises
(
binascii
.
Error
,
base64
.
b16decode
,
'010'
)
def
test_a85encode
(
self
):
def
test_a85encode
(
self
):
eq
=
self
.
assertEqual
eq
=
self
.
assertEqual
...
...
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