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
1f3b4e12
Kaydet (Commit)
1f3b4e12
authored
Mar 07, 2010
tarafından
Florent Xicluna
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix some py3k warnings in the standard library.
üst
2a4ab816
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
45 additions
and
40 deletions
+45
-40
_pyio.py
Lib/_pyio.py
+13
-4
calendar.py
Lib/calendar.py
+4
-0
test_callbacks.py
Lib/ctypes/test/test_callbacks.py
+2
-2
util.py
Lib/distutils/util.py
+1
-1
shutil.py
Lib/shutil.py
+2
-1
test_calendar.py
Lib/test/test_calendar.py
+3
-5
test_memoryio.py
Lib/test/test_memoryio.py
+2
-6
case.py
Lib/unittest/case.py
+17
-20
warnings.py
Lib/warnings.py
+1
-1
No files found.
Lib/_pyio.py
Dosyayı görüntüle @
1f3b4e12
...
@@ -839,8 +839,8 @@ class BytesIO(BufferedIOBase):
...
@@ -839,8 +839,8 @@ class BytesIO(BufferedIOBase):
if
self
.
closed
:
if
self
.
closed
:
raise
ValueError
(
"seek on closed file"
)
raise
ValueError
(
"seek on closed file"
)
try
:
try
:
pos
=
pos
.
__index__
()
pos
.
__index__
except
AttributeError
as
err
:
except
AttributeError
:
raise
TypeError
(
"an integer is required"
)
raise
TypeError
(
"an integer is required"
)
if
whence
==
0
:
if
whence
==
0
:
if
pos
<
0
:
if
pos
<
0
:
...
@@ -864,8 +864,13 @@ class BytesIO(BufferedIOBase):
...
@@ -864,8 +864,13 @@ class BytesIO(BufferedIOBase):
raise
ValueError
(
"truncate on closed file"
)
raise
ValueError
(
"truncate on closed file"
)
if
pos
is
None
:
if
pos
is
None
:
pos
=
self
.
_pos
pos
=
self
.
_pos
elif
pos
<
0
:
else
:
raise
ValueError
(
"negative truncate position
%
r"
%
(
pos
,))
try
:
pos
.
__index__
except
AttributeError
:
raise
TypeError
(
"an integer is required"
)
if
pos
<
0
:
raise
ValueError
(
"negative truncate position
%
r"
%
(
pos
,))
del
self
.
_buffer
[
pos
:]
del
self
.
_buffer
[
pos
:]
return
pos
return
pos
...
@@ -1813,6 +1818,10 @@ class TextIOWrapper(TextIOBase):
...
@@ -1813,6 +1818,10 @@ class TextIOWrapper(TextIOBase):
if
n
is
None
:
if
n
is
None
:
n
=
-
1
n
=
-
1
decoder
=
self
.
_decoder
or
self
.
_get_decoder
()
decoder
=
self
.
_decoder
or
self
.
_get_decoder
()
try
:
n
.
__index__
except
AttributeError
:
raise
TypeError
(
"an integer is required"
)
if
n
<
0
:
if
n
<
0
:
# Read everything.
# Read everything.
result
=
(
self
.
_get_decoded_chars
()
+
result
=
(
self
.
_get_decoded_chars
()
+
...
...
Lib/calendar.py
Dosyayı görüntüle @
1f3b4e12
...
@@ -564,6 +564,10 @@ c = TextCalendar()
...
@@ -564,6 +564,10 @@ c = TextCalendar()
firstweekday
=
c
.
getfirstweekday
firstweekday
=
c
.
getfirstweekday
def
setfirstweekday
(
firstweekday
):
def
setfirstweekday
(
firstweekday
):
try
:
firstweekday
.
__index__
except
AttributeError
:
raise
IllegalWeekdayError
(
firstweekday
)
if
not
MONDAY
<=
firstweekday
<=
SUNDAY
:
if
not
MONDAY
<=
firstweekday
<=
SUNDAY
:
raise
IllegalWeekdayError
(
firstweekday
)
raise
IllegalWeekdayError
(
firstweekday
)
c
.
firstweekday
=
firstweekday
c
.
firstweekday
=
firstweekday
...
...
Lib/ctypes/test/test_callbacks.py
Dosyayı görüntüle @
1f3b4e12
...
@@ -132,7 +132,7 @@ class Callbacks(unittest.TestCase):
...
@@ -132,7 +132,7 @@ class Callbacks(unittest.TestCase):
gc
.
collect
()
gc
.
collect
()
live
=
[
x
for
x
in
gc
.
get_objects
()
live
=
[
x
for
x
in
gc
.
get_objects
()
if
isinstance
(
x
,
X
)]
if
isinstance
(
x
,
X
)]
self
.
failUnless
Equal
(
len
(
live
),
0
)
self
.
assert
Equal
(
len
(
live
),
0
)
try
:
try
:
WINFUNCTYPE
WINFUNCTYPE
...
@@ -164,7 +164,7 @@ class SampleCallbacksTestCase(unittest.TestCase):
...
@@ -164,7 +164,7 @@ class SampleCallbacksTestCase(unittest.TestCase):
result
=
integrate
(
0.0
,
1.0
,
CALLBACK
(
func
),
10
)
result
=
integrate
(
0.0
,
1.0
,
CALLBACK
(
func
),
10
)
diff
=
abs
(
result
-
1.
/
3.
)
diff
=
abs
(
result
-
1.
/
3.
)
self
.
assert
True
(
diff
<
0.01
,
"
%
s not less than 0.01"
%
diff
)
self
.
assert
Less
(
diff
,
0.01
,
"
%
s not less than 0.01"
%
diff
)
################################################################
################################################################
...
...
Lib/distutils/util.py
Dosyayı görüntüle @
1f3b4e12
...
@@ -406,7 +406,7 @@ def execute (func, args, msg=None, verbose=0, dry_run=0):
...
@@ -406,7 +406,7 @@ def execute (func, args, msg=None, verbose=0, dry_run=0):
log
.
info
(
msg
)
log
.
info
(
msg
)
if
not
dry_run
:
if
not
dry_run
:
apply
(
func
,
args
)
func
(
*
args
)
def
strtobool
(
val
):
def
strtobool
(
val
):
...
...
Lib/shutil.py
Dosyayı görüntüle @
1f3b4e12
...
@@ -10,6 +10,7 @@ import stat
...
@@ -10,6 +10,7 @@ import stat
from
os.path
import
abspath
from
os.path
import
abspath
import
fnmatch
import
fnmatch
from
warnings
import
warn
from
warnings
import
warn
import
collections
try
:
try
:
from
pwd
import
getpwnam
from
pwd
import
getpwnam
...
@@ -500,7 +501,7 @@ def register_archive_format(name, function, extra_args=None, description=''):
...
@@ -500,7 +501,7 @@ def register_archive_format(name, function, extra_args=None, description=''):
"""
"""
if
extra_args
is
None
:
if
extra_args
is
None
:
extra_args
=
[]
extra_args
=
[]
if
not
callable
(
function
):
if
not
isinstance
(
function
,
collections
.
Callable
):
raise
TypeError
(
'The
%
s object is not callable'
%
function
)
raise
TypeError
(
'The
%
s object is not callable'
%
function
)
if
not
isinstance
(
extra_args
,
(
tuple
,
list
)):
if
not
isinstance
(
extra_args
,
(
tuple
,
list
)):
raise
TypeError
(
'extra_args needs to be a sequence'
)
raise
TypeError
(
'extra_args needs to be a sequence'
)
...
...
Lib/test/test_calendar.py
Dosyayı görüntüle @
1f3b4e12
...
@@ -212,11 +212,9 @@ class CalendarTestCase(unittest.TestCase):
...
@@ -212,11 +212,9 @@ class CalendarTestCase(unittest.TestCase):
self
.
assertEqual
(
calendar
.
isleap
(
2003
),
0
)
self
.
assertEqual
(
calendar
.
isleap
(
2003
),
0
)
def
test_setfirstweekday
(
self
):
def
test_setfirstweekday
(
self
):
# Silence a py3k warning claiming to affect Lib/calendar.py
self
.
assertRaises
(
ValueError
,
calendar
.
setfirstweekday
,
'flabber'
)
with
test_support
.
check_warnings
():
self
.
assertRaises
(
ValueError
,
calendar
.
setfirstweekday
,
-
1
)
self
.
assertRaises
(
ValueError
,
calendar
.
setfirstweekday
,
'flabber'
)
self
.
assertRaises
(
ValueError
,
calendar
.
setfirstweekday
,
200
)
self
.
assertRaises
(
ValueError
,
calendar
.
setfirstweekday
,
-
1
)
self
.
assertRaises
(
ValueError
,
calendar
.
setfirstweekday
,
200
)
orig
=
calendar
.
firstweekday
()
orig
=
calendar
.
firstweekday
()
calendar
.
setfirstweekday
(
calendar
.
SUNDAY
)
calendar
.
setfirstweekday
(
calendar
.
SUNDAY
)
self
.
assertEqual
(
calendar
.
firstweekday
(),
calendar
.
SUNDAY
)
self
.
assertEqual
(
calendar
.
firstweekday
(),
calendar
.
SUNDAY
)
...
...
Lib/test/test_memoryio.py
Dosyayı görüntüle @
1f3b4e12
...
@@ -133,9 +133,7 @@ class MemoryTestMixin:
...
@@ -133,9 +133,7 @@ class MemoryTestMixin:
pos
=
memio
.
tell
()
pos
=
memio
.
tell
()
self
.
assertEqual
(
memio
.
truncate
(
None
),
pos
)
self
.
assertEqual
(
memio
.
truncate
(
None
),
pos
)
self
.
assertEqual
(
memio
.
tell
(),
pos
)
self
.
assertEqual
(
memio
.
tell
(),
pos
)
# Silence a py3k warning
self
.
assertRaises
(
TypeError
,
memio
.
truncate
,
'0'
)
with
support
.
check_warnings
():
self
.
assertRaises
(
TypeError
,
memio
.
truncate
,
'0'
)
memio
.
close
()
memio
.
close
()
self
.
assertRaises
(
ValueError
,
memio
.
truncate
,
0
)
self
.
assertRaises
(
ValueError
,
memio
.
truncate
,
0
)
...
@@ -172,9 +170,7 @@ class MemoryTestMixin:
...
@@ -172,9 +170,7 @@ class MemoryTestMixin:
self
.
assertEqual
(
type
(
memio
.
read
()),
type
(
buf
))
self
.
assertEqual
(
type
(
memio
.
read
()),
type
(
buf
))
memio
.
seek
(
0
)
memio
.
seek
(
0
)
self
.
assertEqual
(
memio
.
read
(
None
),
buf
)
self
.
assertEqual
(
memio
.
read
(
None
),
buf
)
# Silence a py3k warning
self
.
assertRaises
(
TypeError
,
memio
.
read
,
''
)
with
support
.
check_warnings
():
self
.
assertRaises
(
TypeError
,
memio
.
read
,
''
)
memio
.
close
()
memio
.
close
()
self
.
assertRaises
(
ValueError
,
memio
.
read
)
self
.
assertRaises
(
ValueError
,
memio
.
read
)
...
...
Lib/unittest/case.py
Dosyayı görüntüle @
1f3b4e12
...
@@ -774,26 +774,23 @@ class TestCase(object):
...
@@ -774,26 +774,23 @@ class TestCase(object):
set(actual))`` but it works with sequences of unhashable objects as
set(actual))`` but it works with sequences of unhashable objects as
well.
well.
"""
"""
try
:
with
warnings
.
catch_warnings
():
expected
=
set
(
expected_seq
)
if
sys
.
py3kwarning
:
actual
=
set
(
actual_seq
)
# Silence Py3k warning raised during the sorting
missing
=
list
(
expected
.
difference
(
actual
))
for
msg
in
[
"dict inequality comparisons"
,
unexpected
=
list
(
actual
.
difference
(
expected
))
"builtin_function_or_method order comparisons"
,
missing
.
sort
()
"comparing unequal types"
]:
unexpected
.
sort
()
warnings
.
filterwarnings
(
"ignore"
,
msg
,
DeprecationWarning
)
except
TypeError
:
try
:
# Fall back to slower list-compare if any of the objects are
expected
=
set
(
expected_seq
)
# not hashable.
actual
=
set
(
actual_seq
)
expected
=
list
(
expected_seq
)
missing
=
sorted
(
expected
.
difference
(
actual
))
actual
=
list
(
actual_seq
)
unexpected
=
sorted
(
actual
.
difference
(
expected
))
with
warnings
.
catch_warnings
():
except
TypeError
:
if
sys
.
py3kwarning
:
# Fall back to slower list-compare if any of the objects are
# Silence Py3k warning
# not hashable.
warnings
.
filterwarnings
(
"ignore"
,
expected
=
sorted
(
expected_seq
)
"dict inequality comparisons "
actual
=
sorted
(
actual_seq
)
"not supported"
,
DeprecationWarning
)
expected
.
sort
()
actual
.
sort
()
missing
,
unexpected
=
sorted_list_difference
(
expected
,
actual
)
missing
,
unexpected
=
sorted_list_difference
(
expected
,
actual
)
errors
=
[]
errors
=
[]
if
missing
:
if
missing
:
...
...
Lib/warnings.py
Dosyayı görüntüle @
1f3b4e12
...
@@ -29,7 +29,7 @@ def _show_warning(message, category, filename, lineno, file=None, line=None):
...
@@ -29,7 +29,7 @@ def _show_warning(message, category, filename, lineno, file=None, line=None):
file
.
write
(
formatwarning
(
message
,
category
,
filename
,
lineno
,
line
))
file
.
write
(
formatwarning
(
message
,
category
,
filename
,
lineno
,
line
))
except
IOError
:
except
IOError
:
pass
# the file (probably stderr) is invalid - this warning gets lost.
pass
# the file (probably stderr) is invalid - this warning gets lost.
# Keep a wor
r
king version around in case the deprecation of the old API is
# Keep a working version around in case the deprecation of the old API is
# triggered.
# triggered.
showwarning
=
_show_warning
showwarning
=
_show_warning
...
...
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