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
bd9c655c
Kaydet (Commit)
bd9c655c
authored
Tem 18, 2011
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
merge heads
üst
76f7f4d9
e52181c0
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
17 deletions
+41
-17
urllib.request.rst
Doc/library/urllib.request.rst
+13
-1
warnings.rst
Doc/library/warnings.rst
+1
-2
test_itertools.py
Lib/test/test_itertools.py
+15
-6
test_warnings.py
Lib/test/test_warnings.py
+8
-6
NEWS
Misc/NEWS
+2
-0
_warnings.c
Python/_warnings.c
+2
-2
No files found.
Doc/library/urllib.request.rst
Dosyayı görüntüle @
bd9c655c
...
@@ -323,6 +323,11 @@ The following classes are provided:
...
@@ -323,6 +323,11 @@ The following classes are provided:
A catch-all class to handle unknown URLs.
A catch-all class to handle unknown URLs.
.. class:: HTTPErrorProcessor()
Process HTTP error responses.
.. _request-objects:
.. _request-objects:
Request Objects
Request Objects
...
@@ -926,7 +931,7 @@ UnknownHandler Objects
...
@@ -926,7 +931,7 @@ UnknownHandler Objects
HTTPErrorProcessor Objects
HTTPErrorProcessor Objects
--------------------------
--------------------------
.. method:: HTTPErrorProcessor.
unknown_open
()
.. method:: HTTPErrorProcessor.
http_response
()
Process HTTP error responses.
Process HTTP error responses.
...
@@ -938,6 +943,13 @@ HTTPErrorProcessor Objects
...
@@ -938,6 +943,13 @@ HTTPErrorProcessor Objects
:exc:`HTTPError` if no other handler handles the error.
:exc:`HTTPError` if no other handler handles the error.
.. method:: HTTPErrorProcessor.https_response()
Process HTTPS error responses.
The behavior is same as :meth:`http_response`.
.. _urllib-request-examples:
.. _urllib-request-examples:
Examples
Examples
...
...
Doc/library/warnings.rst
Dosyayı görüntüle @
bd9c655c
...
@@ -339,8 +339,7 @@ Available Functions
...
@@ -339,8 +339,7 @@ Available Functions
Write a warning to a file. The default implementation calls
Write a warning to a file. The default implementation calls
``formatwarning(message, category, filename, lineno, line)`` and writes the
``formatwarning(message, category, filename, lineno, line)`` and writes the
resulting string to *file*, which defaults to ``sys.stderr``. You may replace
resulting string to *file*, which defaults to ``sys.stderr``. You may replace
this function with an alternative implementation by assigning to
this function with any callable by assigning to ``warnings.showwarning``.
``warnings.showwarning``.
*line* is a line of source code to be included in the warning
*line* is a line of source code to be included in the warning
message; if *line* is not supplied, :func:`showwarning` will
message; if *line* is not supplied, :func:`showwarning` will
try to read the line specified by *filename* and *lineno*.
try to read the line specified by *filename* and *lineno*.
...
...
Lib/test/test_itertools.py
Dosyayı görüntüle @
bd9c655c
...
@@ -168,7 +168,8 @@ class TestBasicOps(unittest.TestCase):
...
@@ -168,7 +168,8 @@ class TestBasicOps(unittest.TestCase):
self
.
assertEqual
(
result
,
list
(
combinations2
(
values
,
r
)))
# matches second pure python version
self
.
assertEqual
(
result
,
list
(
combinations2
(
values
,
r
)))
# matches second pure python version
self
.
assertEqual
(
result
,
list
(
combinations3
(
values
,
r
)))
# matches second pure python version
self
.
assertEqual
(
result
,
list
(
combinations3
(
values
,
r
)))
# matches second pure python version
# Test implementation detail: tuple re-use
@support.impl_detail
(
"tuple reuse is specific to CPython"
)
def
test_combinations_tuple_reuse
(
self
):
self
.
assertEqual
(
len
(
set
(
map
(
id
,
combinations
(
'abcde'
,
3
)))),
1
)
self
.
assertEqual
(
len
(
set
(
map
(
id
,
combinations
(
'abcde'
,
3
)))),
1
)
self
.
assertNotEqual
(
len
(
set
(
map
(
id
,
list
(
combinations
(
'abcde'
,
3
))))),
1
)
self
.
assertNotEqual
(
len
(
set
(
map
(
id
,
list
(
combinations
(
'abcde'
,
3
))))),
1
)
...
@@ -238,7 +239,9 @@ class TestBasicOps(unittest.TestCase):
...
@@ -238,7 +239,9 @@ class TestBasicOps(unittest.TestCase):
self
.
assertEqual
(
result
,
list
(
cwr1
(
values
,
r
)))
# matches first pure python version
self
.
assertEqual
(
result
,
list
(
cwr1
(
values
,
r
)))
# matches first pure python version
self
.
assertEqual
(
result
,
list
(
cwr2
(
values
,
r
)))
# matches second pure python version
self
.
assertEqual
(
result
,
list
(
cwr2
(
values
,
r
)))
# matches second pure python version
# Test implementation detail: tuple re-use
@support.impl_detail
(
"tuple reuse is specific to CPython"
)
def
test_combinations_with_replacement_tuple_reuse
(
self
):
cwr
=
combinations_with_replacement
self
.
assertEqual
(
len
(
set
(
map
(
id
,
cwr
(
'abcde'
,
3
)))),
1
)
self
.
assertEqual
(
len
(
set
(
map
(
id
,
cwr
(
'abcde'
,
3
)))),
1
)
self
.
assertNotEqual
(
len
(
set
(
map
(
id
,
list
(
cwr
(
'abcde'
,
3
))))),
1
)
self
.
assertNotEqual
(
len
(
set
(
map
(
id
,
list
(
cwr
(
'abcde'
,
3
))))),
1
)
...
@@ -302,7 +305,8 @@ class TestBasicOps(unittest.TestCase):
...
@@ -302,7 +305,8 @@ class TestBasicOps(unittest.TestCase):
self
.
assertEqual
(
result
,
list
(
permutations
(
values
,
None
)))
# test r as None
self
.
assertEqual
(
result
,
list
(
permutations
(
values
,
None
)))
# test r as None
self
.
assertEqual
(
result
,
list
(
permutations
(
values
)))
# test default r
self
.
assertEqual
(
result
,
list
(
permutations
(
values
)))
# test default r
# Test implementation detail: tuple re-use
@support.impl_detail
(
"tuple resuse is CPython specific"
)
def
test_permutations_tuple_reuse
(
self
):
self
.
assertEqual
(
len
(
set
(
map
(
id
,
permutations
(
'abcde'
,
3
)))),
1
)
self
.
assertEqual
(
len
(
set
(
map
(
id
,
permutations
(
'abcde'
,
3
)))),
1
)
self
.
assertNotEqual
(
len
(
set
(
map
(
id
,
list
(
permutations
(
'abcde'
,
3
))))),
1
)
self
.
assertNotEqual
(
len
(
set
(
map
(
id
,
list
(
permutations
(
'abcde'
,
3
))))),
1
)
...
@@ -566,11 +570,13 @@ class TestBasicOps(unittest.TestCase):
...
@@ -566,11 +570,13 @@ class TestBasicOps(unittest.TestCase):
self
.
assertEqual
(
list
(
zip
()),
lzip
())
self
.
assertEqual
(
list
(
zip
()),
lzip
())
self
.
assertRaises
(
TypeError
,
zip
,
3
)
self
.
assertRaises
(
TypeError
,
zip
,
3
)
self
.
assertRaises
(
TypeError
,
zip
,
range
(
3
),
3
)
self
.
assertRaises
(
TypeError
,
zip
,
range
(
3
),
3
)
# Check tuple re-use (implementation detail)
self
.
assertEqual
([
tuple
(
list
(
pair
))
for
pair
in
zip
(
'abc'
,
'def'
)],
self
.
assertEqual
([
tuple
(
list
(
pair
))
for
pair
in
zip
(
'abc'
,
'def'
)],
lzip
(
'abc'
,
'def'
))
lzip
(
'abc'
,
'def'
))
self
.
assertEqual
([
pair
for
pair
in
zip
(
'abc'
,
'def'
)],
self
.
assertEqual
([
pair
for
pair
in
zip
(
'abc'
,
'def'
)],
lzip
(
'abc'
,
'def'
))
lzip
(
'abc'
,
'def'
))
@support.impl_detail
(
"tuple reuse is specific to CPython"
)
def
test_zip_tuple_reuse
(
self
):
ids
=
list
(
map
(
id
,
zip
(
'abc'
,
'def'
)))
ids
=
list
(
map
(
id
,
zip
(
'abc'
,
'def'
)))
self
.
assertEqual
(
min
(
ids
),
max
(
ids
))
self
.
assertEqual
(
min
(
ids
),
max
(
ids
))
ids
=
list
(
map
(
id
,
list
(
zip
(
'abc'
,
'def'
))))
ids
=
list
(
map
(
id
,
list
(
zip
(
'abc'
,
'def'
))))
...
@@ -613,11 +619,13 @@ class TestBasicOps(unittest.TestCase):
...
@@ -613,11 +619,13 @@ class TestBasicOps(unittest.TestCase):
else
:
else
:
self
.
fail
(
'Did not raise Type in: '
+
stmt
)
self
.
fail
(
'Did not raise Type in: '
+
stmt
)
# Check tuple re-use (implementation detail)
self
.
assertEqual
([
tuple
(
list
(
pair
))
for
pair
in
zip_longest
(
'abc'
,
'def'
)],
self
.
assertEqual
([
tuple
(
list
(
pair
))
for
pair
in
zip_longest
(
'abc'
,
'def'
)],
list
(
zip
(
'abc'
,
'def'
)))
list
(
zip
(
'abc'
,
'def'
)))
self
.
assertEqual
([
pair
for
pair
in
zip_longest
(
'abc'
,
'def'
)],
self
.
assertEqual
([
pair
for
pair
in
zip_longest
(
'abc'
,
'def'
)],
list
(
zip
(
'abc'
,
'def'
)))
list
(
zip
(
'abc'
,
'def'
)))
@support.impl_detail
(
"tuple reuse is specific to CPython"
)
def
test_zip_longest_tuple_reuse
(
self
):
ids
=
list
(
map
(
id
,
zip_longest
(
'abc'
,
'def'
)))
ids
=
list
(
map
(
id
,
zip_longest
(
'abc'
,
'def'
)))
self
.
assertEqual
(
min
(
ids
),
max
(
ids
))
self
.
assertEqual
(
min
(
ids
),
max
(
ids
))
ids
=
list
(
map
(
id
,
list
(
zip_longest
(
'abc'
,
'def'
))))
ids
=
list
(
map
(
id
,
list
(
zip_longest
(
'abc'
,
'def'
))))
...
@@ -721,7 +729,8 @@ class TestBasicOps(unittest.TestCase):
...
@@ -721,7 +729,8 @@ class TestBasicOps(unittest.TestCase):
args
=
map
(
iter
,
args
)
args
=
map
(
iter
,
args
)
self
.
assertEqual
(
len
(
list
(
product
(
*
args
))),
expected_len
)
self
.
assertEqual
(
len
(
list
(
product
(
*
args
))),
expected_len
)
# Test implementation detail: tuple re-use
@support.impl_detail
(
"tuple reuse is specific to CPython"
)
def
test_product_tuple_reuse
(
self
):
self
.
assertEqual
(
len
(
set
(
map
(
id
,
product
(
'abc'
,
'def'
)))),
1
)
self
.
assertEqual
(
len
(
set
(
map
(
id
,
product
(
'abc'
,
'def'
)))),
1
)
self
.
assertNotEqual
(
len
(
set
(
map
(
id
,
list
(
product
(
'abc'
,
'def'
))))),
1
)
self
.
assertNotEqual
(
len
(
set
(
map
(
id
,
list
(
product
(
'abc'
,
'def'
))))),
1
)
...
...
Lib/test/test_warnings.py
Dosyayı görüntüle @
bd9c655c
...
@@ -512,12 +512,11 @@ class _WarningsTests(BaseTest):
...
@@ -512,12 +512,11 @@ class _WarningsTests(BaseTest):
def
test_showwarning_not_callable
(
self
):
def
test_showwarning_not_callable
(
self
):
with
original_warnings
.
catch_warnings
(
module
=
self
.
module
):
with
original_warnings
.
catch_warnings
(
module
=
self
.
module
):
self
.
module
.
filterwarnings
(
"always"
,
category
=
UserWarning
)
self
.
module
.
filterwarnings
(
"always"
,
category
=
UserWarning
)
old_showwarning
=
self
.
module
.
showwarning
self
.
module
.
showwarning
=
print
with
support
.
captured_output
(
'stdout'
):
self
.
module
.
warn
(
'Warning!'
)
self
.
module
.
showwarning
=
23
self
.
module
.
showwarning
=
23
try
:
self
.
assertRaises
(
TypeError
,
self
.
module
.
warn
,
"Warning!"
)
self
.
assertRaises
(
TypeError
,
self
.
module
.
warn
,
"Warning!"
)
finally
:
self
.
module
.
showwarning
=
old_showwarning
def
test_show_warning_output
(
self
):
def
test_show_warning_output
(
self
):
# With showarning() missing, make sure that output is okay.
# With showarning() missing, make sure that output is okay.
...
@@ -547,10 +546,13 @@ class _WarningsTests(BaseTest):
...
@@ -547,10 +546,13 @@ class _WarningsTests(BaseTest):
globals_dict
=
globals
()
globals_dict
=
globals
()
oldfile
=
globals_dict
[
'__file__'
]
oldfile
=
globals_dict
[
'__file__'
]
try
:
try
:
with
original_warnings
.
catch_warnings
(
module
=
self
.
module
)
as
w
:
catch
=
original_warnings
.
catch_warnings
(
record
=
True
,
module
=
self
.
module
)
with
catch
as
w
:
self
.
module
.
filterwarnings
(
"always"
,
category
=
UserWarning
)
self
.
module
.
filterwarnings
(
"always"
,
category
=
UserWarning
)
globals_dict
[
'__file__'
]
=
None
globals_dict
[
'__file__'
]
=
None
original_warnings
.
warn
(
'test'
,
UserWarning
)
original_warnings
.
warn
(
'test'
,
UserWarning
)
self
.
assertTrue
(
len
(
w
))
finally
:
finally
:
globals_dict
[
'__file__'
]
=
oldfile
globals_dict
[
'__file__'
]
=
oldfile
...
...
Misc/NEWS
Dosyayı görüntüle @
bd9c655c
...
@@ -10,6 +10,8 @@ What's New in Python 3.3 Alpha 1?
...
@@ -10,6 +10,8 @@ What's New in Python 3.3 Alpha 1?
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #10271: Allow warnings.showwarning() be any callable.
- Issue #11627: Fix segfault when __new__ on a exception returns a non-exception
- Issue #11627: Fix segfault when __new__ on a exception returns a non-exception
class.
class.
...
...
Python/_warnings.c
Dosyayı görüntüle @
bd9c655c
...
@@ -409,10 +409,10 @@ warn_explicit(PyObject *category, PyObject *message,
...
@@ -409,10 +409,10 @@ warn_explicit(PyObject *category, PyObject *message,
else
{
else
{
PyObject
*
res
;
PyObject
*
res
;
if
(
!
Py
Method_Check
(
show_fxn
)
&&
!
PyFunction
_Check
(
show_fxn
))
{
if
(
!
Py
Callable
_Check
(
show_fxn
))
{
PyErr_SetString
(
PyExc_TypeError
,
PyErr_SetString
(
PyExc_TypeError
,
"warnings.showwarning() must be set to a "
"warnings.showwarning() must be set to a "
"
function or method
"
);
"
callable
"
);
Py_DECREF
(
show_fxn
);
Py_DECREF
(
show_fxn
);
goto
cleanup
;
goto
cleanup
;
}
}
...
...
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