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
288e89ac
Kaydet (Commit)
288e89ac
authored
Ock 18, 2008
tarafından
Christian Heimes
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added bytes and b'' as aliases for str and ''
üst
a9e073d1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
43 additions
and
4 deletions
+43
-4
test_string.py
Lib/test/test_string.py
+12
-1
tokenize.py
Lib/tokenize.py
+16
-3
NEWS
Misc/NEWS
+3
-0
tokenizer.c
Parser/tokenizer.c
+8
-0
ast.c
Python/ast.c
+3
-0
bltinmodule.c
Python/bltinmodule.c
+1
-0
No files found.
Lib/test/test_string.py
Dosyayı görüntüle @
288e89ac
...
...
@@ -106,8 +106,19 @@ class ModuleTest(unittest.TestCase):
self
.
assertEqual
(
string
.
capwords
(
'ABC-DEF-GHI'
,
'-'
),
'Abc-Def-Ghi'
)
self
.
assertEqual
(
string
.
capwords
(
'ABC-def DEF-ghi GHI'
),
'Abc-def Def-ghi Ghi'
)
class
BytesAliasTest
(
unittest
.
TestCase
):
def
test_builtin
(
self
):
self
.
assert_
(
str
is
bytes
)
def
test_syntax
(
self
):
self
.
assertEqual
(
b
"spam"
,
"spam"
)
self
.
assertEqual
(
br
"egg
\f
oo"
,
"egg
\\
foo"
)
self
.
assert_
(
type
(
b
""
),
str
)
self
.
assert_
(
type
(
br
""
),
str
)
def
test_main
():
test_support
.
run_unittest
(
StringTest
,
ModuleTest
)
test_support
.
run_unittest
(
StringTest
,
ModuleTest
,
BytesAliasTest
)
if
__name__
==
"__main__"
:
test_main
()
Lib/tokenize.py
Dosyayı görüntüle @
288e89ac
...
...
@@ -109,21 +109,34 @@ endprogs = {"'": re.compile(Single), '"': re.compile(Double),
"uR'''"
:
single3prog
,
'uR"""'
:
double3prog
,
"Ur'''"
:
single3prog
,
'Ur"""'
:
double3prog
,
"UR'''"
:
single3prog
,
'UR"""'
:
double3prog
,
'r'
:
None
,
'R'
:
None
,
'u'
:
None
,
'U'
:
None
}
"b'''"
:
single3prog
,
'b"""'
:
double3prog
,
"br'''"
:
single3prog
,
'br"""'
:
double3prog
,
"B'''"
:
single3prog
,
'B"""'
:
double3prog
,
"bR'''"
:
single3prog
,
'bR"""'
:
double3prog
,
"Br'''"
:
single3prog
,
'Br"""'
:
double3prog
,
"BR'''"
:
single3prog
,
'BR"""'
:
double3prog
,
'r'
:
None
,
'R'
:
None
,
'u'
:
None
,
'U'
:
None
,
'b'
:
None
,
'B'
:
None
}
triple_quoted
=
{}
for
t
in
(
"'''"
,
'"""'
,
"r'''"
,
'r"""'
,
"R'''"
,
'R"""'
,
"u'''"
,
'u"""'
,
"U'''"
,
'U"""'
,
"ur'''"
,
'ur"""'
,
"Ur'''"
,
'Ur"""'
,
"uR'''"
,
'uR"""'
,
"UR'''"
,
'UR"""'
):
"uR'''"
,
'uR"""'
,
"UR'''"
,
'UR"""'
,
"b'''"
,
'b"""'
,
"B'''"
,
'B"""'
,
"br'''"
,
'br"""'
,
"Br'''"
,
'Br"""'
,
"bR'''"
,
'bR"""'
,
"BR'''"
,
'BR"""'
):
triple_quoted
[
t
]
=
t
single_quoted
=
{}
for
t
in
(
"'"
,
'"'
,
"r'"
,
'r"'
,
"R'"
,
'R"'
,
"u'"
,
'u"'
,
"U'"
,
'U"'
,
"ur'"
,
'ur"'
,
"Ur'"
,
'Ur"'
,
"uR'"
,
'uR"'
,
"UR'"
,
'UR"'
):
"uR'"
,
'uR"'
,
"UR'"
,
'UR"'
,
"b'"
,
'b"'
,
"B'"
,
'B"'
,
"br'"
,
'br"'
,
"Br'"
,
'Br"'
,
"bR'"
,
'bR"'
,
"BR'"
,
'BR"'
):
single_quoted
[
t
]
=
t
tabsize
=
8
...
...
Misc/NEWS
Dosyayı görüntüle @
288e89ac
...
...
@@ -12,6 +12,9 @@ What's New in Python 2.6 alpha 1?
Core and builtins
-----------------
- Issue #1865: Bytes as an alias for str and b"" as an alias "" were
added.
- sys.float_info / PyFloat_GetInfo: The floating point information
object was converted from a dict to a specialized structseq object.
...
...
Parser/tokenizer.c
Dosyayı görüntüle @
288e89ac
...
...
@@ -1263,6 +1263,14 @@ tok_get(register struct tok_state *tok, char **p_start, char **p_end)
if
(
isalpha
(
c
)
||
c
==
'_'
)
{
/* Process r"", u"" and ur"" */
switch
(
c
)
{
case
'b'
:
case
'B'
:
c
=
tok_nextc
(
tok
);
if
(
c
==
'r'
||
c
==
'R'
)
c
=
tok_nextc
(
tok
);
if
(
c
==
'"'
||
c
==
'\''
)
goto
letter_quote
;
break
;
case
'r'
:
case
'R'
:
c
=
tok_nextc
(
tok
);
...
...
Python/ast.c
Dosyayı görüntüle @
288e89ac
...
...
@@ -3238,6 +3238,9 @@ parsestr(const char *s, const char *encoding)
quote
=
*++
s
;
unicode
=
1
;
}
if
(
quote
==
'b'
||
quote
==
'B'
)
{
quote
=
*++
s
;
}
if
(
quote
==
'r'
||
quote
==
'R'
)
{
quote
=
*++
s
;
rawmode
=
1
;
...
...
Python/bltinmodule.c
Dosyayı görüntüle @
288e89ac
...
...
@@ -2446,6 +2446,7 @@ _PyBuiltin_Init(void)
SETBUILTIN
(
"True"
,
Py_True
);
SETBUILTIN
(
"basestring"
,
&
PyBaseString_Type
);
SETBUILTIN
(
"bool"
,
&
PyBool_Type
);
SETBUILTIN
(
"bytes"
,
&
PyString_Type
);
SETBUILTIN
(
"buffer"
,
&
PyBuffer_Type
);
SETBUILTIN
(
"classmethod"
,
&
PyClassMethod_Type
);
#ifndef WITHOUT_COMPLEX
...
...
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