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
7fe98535
Kaydet (Commit)
7fe98535
authored
Nis 02, 2009
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
make 'c' only accept bytes and 'C' only unicode #5499
üst
605b9d9f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
14 deletions
+15
-14
arg.rst
Doc/c-api/arg.rst
+5
-1
buffer_tests.py
Lib/test/buffer_tests.py
+3
-3
NEWS
Misc/NEWS
+3
-0
getargs.c
Python/getargs.c
+4
-10
No files found.
Doc/c-api/arg.rst
Dosyayı görüntüle @
7fe98535
...
@@ -208,9 +208,13 @@ variable(s) whose address should be passed.
...
@@ -208,9 +208,13 @@ variable(s) whose address should be passed.
Convert a Python integer to a C :ctype:`Py_ssize_t`.
Convert a Python integer to a C :ctype:`Py_ssize_t`.
``c`` (string of length 1) [char]
``c`` (string of length 1) [char]
Convert a Python character, represented as a string of length 1, to a C
Convert a Python character, represented as a
byte
string of length 1, to a C
:ctype:`char`.
:ctype:`char`.
``C`` (string of length 1) [int]
Covert a Python character, represented as a unicode string of length 1, to a
C :ctype:`int`.
``f`` (float) [float]
``f`` (float) [float]
Convert a Python floating point number to a C :ctype:`float`.
Convert a Python floating point number to a C :ctype:`float`.
...
...
Lib/test/buffer_tests.py
Dosyayı görüntüle @
7fe98535
...
@@ -112,7 +112,7 @@ class MixinBytesBufferCommonTests(object):
...
@@ -112,7 +112,7 @@ class MixinBytesBufferCommonTests(object):
self
.
assertEqual
(
b
'abc '
,
self
.
marshal
(
b
'abc'
)
.
ljust
(
6
))
self
.
assertEqual
(
b
'abc '
,
self
.
marshal
(
b
'abc'
)
.
ljust
(
6
))
self
.
assertEqual
(
b
'abc'
,
self
.
marshal
(
b
'abc'
)
.
ljust
(
3
))
self
.
assertEqual
(
b
'abc'
,
self
.
marshal
(
b
'abc'
)
.
ljust
(
3
))
self
.
assertEqual
(
b
'abc'
,
self
.
marshal
(
b
'abc'
)
.
ljust
(
2
))
self
.
assertEqual
(
b
'abc'
,
self
.
marshal
(
b
'abc'
)
.
ljust
(
2
))
self
.
assertEqual
(
b
'abc*******'
,
self
.
marshal
(
b
'abc'
)
.
ljust
(
10
,
'*'
))
self
.
assertEqual
(
b
'abc*******'
,
self
.
marshal
(
b
'abc'
)
.
ljust
(
10
,
b
'*'
))
self
.
assertRaises
(
TypeError
,
self
.
marshal
(
b
'abc'
)
.
ljust
)
self
.
assertRaises
(
TypeError
,
self
.
marshal
(
b
'abc'
)
.
ljust
)
def
test_rjust
(
self
):
def
test_rjust
(
self
):
...
@@ -120,7 +120,7 @@ class MixinBytesBufferCommonTests(object):
...
@@ -120,7 +120,7 @@ class MixinBytesBufferCommonTests(object):
self
.
assertEqual
(
b
' abc'
,
self
.
marshal
(
b
'abc'
)
.
rjust
(
6
))
self
.
assertEqual
(
b
' abc'
,
self
.
marshal
(
b
'abc'
)
.
rjust
(
6
))
self
.
assertEqual
(
b
'abc'
,
self
.
marshal
(
b
'abc'
)
.
rjust
(
3
))
self
.
assertEqual
(
b
'abc'
,
self
.
marshal
(
b
'abc'
)
.
rjust
(
3
))
self
.
assertEqual
(
b
'abc'
,
self
.
marshal
(
b
'abc'
)
.
rjust
(
2
))
self
.
assertEqual
(
b
'abc'
,
self
.
marshal
(
b
'abc'
)
.
rjust
(
2
))
self
.
assertEqual
(
b
'*******abc'
,
self
.
marshal
(
b
'abc'
)
.
rjust
(
10
,
'*'
))
self
.
assertEqual
(
b
'*******abc'
,
self
.
marshal
(
b
'abc'
)
.
rjust
(
10
,
b
'*'
))
self
.
assertRaises
(
TypeError
,
self
.
marshal
(
b
'abc'
)
.
rjust
)
self
.
assertRaises
(
TypeError
,
self
.
marshal
(
b
'abc'
)
.
rjust
)
def
test_center
(
self
):
def
test_center
(
self
):
...
@@ -128,7 +128,7 @@ class MixinBytesBufferCommonTests(object):
...
@@ -128,7 +128,7 @@ class MixinBytesBufferCommonTests(object):
self
.
assertEqual
(
b
' abc '
,
self
.
marshal
(
b
'abc'
)
.
center
(
6
))
self
.
assertEqual
(
b
' abc '
,
self
.
marshal
(
b
'abc'
)
.
center
(
6
))
self
.
assertEqual
(
b
'abc'
,
self
.
marshal
(
b
'abc'
)
.
center
(
3
))
self
.
assertEqual
(
b
'abc'
,
self
.
marshal
(
b
'abc'
)
.
center
(
3
))
self
.
assertEqual
(
b
'abc'
,
self
.
marshal
(
b
'abc'
)
.
center
(
2
))
self
.
assertEqual
(
b
'abc'
,
self
.
marshal
(
b
'abc'
)
.
center
(
2
))
self
.
assertEqual
(
b
'***abc****'
,
self
.
marshal
(
b
'abc'
)
.
center
(
10
,
'*'
))
self
.
assertEqual
(
b
'***abc****'
,
self
.
marshal
(
b
'abc'
)
.
center
(
10
,
b
'*'
))
self
.
assertRaises
(
TypeError
,
self
.
marshal
(
b
'abc'
)
.
center
)
self
.
assertRaises
(
TypeError
,
self
.
marshal
(
b
'abc'
)
.
center
)
def
test_swapcase
(
self
):
def
test_swapcase
(
self
):
...
...
Misc/NEWS
Dosyayı görüntüle @
7fe98535
...
@@ -12,6 +12,9 @@ What's New in Python 3.1 alpha 2?
...
@@ -12,6 +12,9 @@ What's New in Python 3.1 alpha 2?
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #5499: The 'c' code for argument parsing functions now only accepts a
byte, and the 'C' code only accepts a unicode character.
- Issue #1665206: Remove the last eager import in _warnings.c and make it lazy.
- Issue #1665206: Remove the last eager import in _warnings.c and make it lazy.
- Fix a segfault when running test_exceptions with coverage, caused by
- Fix a segfault when running test_exceptions with coverage, caused by
...
...
Python/getargs.c
Dosyayı görüntüle @
7fe98535
...
@@ -776,24 +776,18 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
...
@@ -776,24 +776,18 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
char
*
p
=
va_arg
(
*
p_va
,
char
*
);
char
*
p
=
va_arg
(
*
p_va
,
char
*
);
if
(
PyBytes_Check
(
arg
)
&&
PyBytes_Size
(
arg
)
==
1
)
if
(
PyBytes_Check
(
arg
)
&&
PyBytes_Size
(
arg
)
==
1
)
*
p
=
PyBytes_AS_STRING
(
arg
)[
0
];
*
p
=
PyBytes_AS_STRING
(
arg
)[
0
];
else
if
(
PyUnicode_Check
(
arg
)
&&
PyUnicode_GET_SIZE
(
arg
)
==
1
&&
PyUnicode_AS_UNICODE
(
arg
)[
0
]
<
256
)
*
p
=
(
char
)
PyUnicode_AS_UNICODE
(
arg
)[
0
];
else
else
return
converterr
(
"
char < 256
"
,
arg
,
msgbuf
,
bufsize
);
return
converterr
(
"
a byte string of length 1
"
,
arg
,
msgbuf
,
bufsize
);
break
;
break
;
}
}
case
'C'
:
{
/* unicode char */
case
'C'
:
{
/* unicode char */
int
*
p
=
va_arg
(
*
p_va
,
int
*
);
int
*
p
=
va_arg
(
*
p_va
,
int
*
);
if
(
PyBytes_Check
(
arg
)
&&
PyBytes_Size
(
arg
)
==
1
)
if
(
PyUnicode_Check
(
arg
)
&&
*
p
=
PyBytes_AS_STRING
(
arg
)[
0
];
PyUnicode_GET_SIZE
(
arg
)
==
1
)
else
if
(
PyUnicode_Check
(
arg
)
&&
PyUnicode_GET_SIZE
(
arg
)
==
1
)
*
p
=
PyUnicode_AS_UNICODE
(
arg
)[
0
];
*
p
=
PyUnicode_AS_UNICODE
(
arg
)[
0
];
else
else
return
converterr
(
"
cha
r"
,
arg
,
msgbuf
,
bufsize
);
return
converterr
(
"
a unicode characte
r"
,
arg
,
msgbuf
,
bufsize
);
break
;
break
;
}
}
...
...
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