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
cbeb9fa6
Kaydet (Commit)
cbeb9fa6
authored
Eki 14, 2010
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#9964: fix lib2to3 fixer fix_operator when running under -OO.
üst
fb3c84a8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
7 deletions
+15
-7
fix_operator.py
Lib/lib2to3/fixes/fix_operator.py
+15
-7
No files found.
Lib/lib2to3/fixes/fix_operator.py
Dosyayı görüntüle @
cbeb9fa6
...
@@ -10,11 +10,19 @@ operator.irepeat(obj, n) -> operator.imul(obj, n)
...
@@ -10,11 +10,19 @@ operator.irepeat(obj, n) -> operator.imul(obj, n)
"""
"""
import
collections
import
collections
from
functools
import
wraps
# Local imports
# Local imports
from
lib2to3
import
fixer_base
from
lib2to3
import
fixer_base
from
lib2to3.fixer_util
import
Call
,
Name
,
String
,
touch_import
from
lib2to3.fixer_util
import
Call
,
Name
,
String
,
touch_import
def
useinstead
(
what
):
"""Make sure __doc__ is assigned even under -OO."""
def
deco
(
f
):
f
.
__doc__
=
what
return
f
return
deco
class
FixOperator
(
fixer_base
.
BaseFix
):
class
FixOperator
(
fixer_base
.
BaseFix
):
...
@@ -36,34 +44,34 @@ class FixOperator(fixer_base.BaseFix):
...
@@ -36,34 +44,34 @@ class FixOperator(fixer_base.BaseFix):
if
method
is
not
None
:
if
method
is
not
None
:
return
method
(
node
,
results
)
return
method
(
node
,
results
)
@useinstead
(
"operator.contains(
%
s)"
)
def
_sequenceIncludes
(
self
,
node
,
results
):
def
_sequenceIncludes
(
self
,
node
,
results
):
"""operator.contains(
%
s)"""
return
self
.
_handle_rename
(
node
,
results
,
"contains"
)
return
self
.
_handle_rename
(
node
,
results
,
"contains"
)
@useinstead
(
"hasattr(
%
s, '__call__')"
)
def
_isCallable
(
self
,
node
,
results
):
def
_isCallable
(
self
,
node
,
results
):
"""hasattr(
%
s, '__call__')"""
obj
=
results
[
"obj"
]
obj
=
results
[
"obj"
]
args
=
[
obj
.
clone
(),
String
(
", "
),
String
(
"'__call__'"
)]
args
=
[
obj
.
clone
(),
String
(
", "
),
String
(
"'__call__'"
)]
return
Call
(
Name
(
"hasattr"
),
args
,
prefix
=
node
.
prefix
)
return
Call
(
Name
(
"hasattr"
),
args
,
prefix
=
node
.
prefix
)
@useinstead
(
"operator.mul(
%
s)"
)
def
_repeat
(
self
,
node
,
results
):
def
_repeat
(
self
,
node
,
results
):
"""operator.mul(
%
s)"""
return
self
.
_handle_rename
(
node
,
results
,
"mul"
)
return
self
.
_handle_rename
(
node
,
results
,
"mul"
)
@useinstead
(
"operator.imul(
%
s)"
)
def
_irepeat
(
self
,
node
,
results
):
def
_irepeat
(
self
,
node
,
results
):
"""operator.imul(
%
s)"""
return
self
.
_handle_rename
(
node
,
results
,
"imul"
)
return
self
.
_handle_rename
(
node
,
results
,
"imul"
)
@useinstead
(
"isinstance(
%
s, collections.Sequence)"
)
def
_isSequenceType
(
self
,
node
,
results
):
def
_isSequenceType
(
self
,
node
,
results
):
"""isinstance(
%
s, collections.Sequence)"""
return
self
.
_handle_type2abc
(
node
,
results
,
"collections"
,
"Sequence"
)
return
self
.
_handle_type2abc
(
node
,
results
,
"collections"
,
"Sequence"
)
@useinstead
(
"isinstance(
%
s, collections.Mapping)"
)
def
_isMappingType
(
self
,
node
,
results
):
def
_isMappingType
(
self
,
node
,
results
):
"""isinstance(
%
s, collections.Mapping)"""
return
self
.
_handle_type2abc
(
node
,
results
,
"collections"
,
"Mapping"
)
return
self
.
_handle_type2abc
(
node
,
results
,
"collections"
,
"Mapping"
)
@useinstead
(
"isinstance(
%
s, numbers.Number)"
)
def
_isNumberType
(
self
,
node
,
results
):
def
_isNumberType
(
self
,
node
,
results
):
"""isinstance(
%
s, numbers.Number)"""
return
self
.
_handle_type2abc
(
node
,
results
,
"numbers"
,
"Number"
)
return
self
.
_handle_type2abc
(
node
,
results
,
"numbers"
,
"Number"
)
def
_handle_rename
(
self
,
node
,
results
,
name
):
def
_handle_rename
(
self
,
node
,
results
,
name
):
...
...
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