Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
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
django
Commits
fc10418f
Kaydet (Commit)
fc10418f
authored
Kas 03, 2012
tarafından
Aymeric Augustin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #18963 -- Used a subclass-friendly pattern
for Python 2 object model compatibility methods.
üst
973f539a
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
61 additions
and
50 deletions
+61
-50
context_processors.py
django/contrib/auth/context_processors.py
+3
-1
measure.py
django/contrib/gis/measure.py
+12
-4
base.py
django/core/files/base.py
+6
-2
base.py
django/core/serializers/base.py
+1
-3
xml_serializer.py
django/core/serializers/xml_serializer.py
+0
-2
base.py
django/db/backends/oracle/base.py
+1
-3
expressions.py
django/db/models/expressions.py
+8
-4
query.py
django/db/models/query.py
+3
-1
saferef.py
django/dispatch/saferef.py
+9
-7
formsets.py
django/forms/formsets.py
+3
-1
multipartparser.py
django/http/multipartparser.py
+4
-12
response.py
django/http/response.py
+1
-3
tree.py
django/utils/tree.py
+3
-1
python3.txt
docs/topics/python3.txt
+7
-6
No files found.
django/contrib/auth/context_processors.py
Dosyayı görüntüle @
fc10418f
...
...
@@ -18,7 +18,9 @@ class PermLookupDict(object):
def
__bool__
(
self
):
return
self
.
user
.
has_module_perms
(
self
.
module_name
)
__nonzero__
=
__bool__
# Python 2
def
__nonzero__
(
self
):
# Python 2 compatibility
return
type
(
self
)
.
__bool__
(
self
)
class
PermWrapper
(
object
):
...
...
django/contrib/gis/measure.py
Dosyayı görüntüle @
fc10418f
...
...
@@ -151,7 +151,9 @@ class MeasureBase(object):
**
{
self
.
STANDARD_UNIT
:
(
self
.
standard
/
other
)})
else
:
raise
TypeError
(
'
%(class)
s must be divided with number or
%(class)
s'
%
{
"class"
:
pretty_name
(
self
)})
__div__
=
__truediv__
# Python 2 compatibility
def
__div__
(
self
,
other
):
# Python 2 compatibility
return
type
(
self
)
.
__truediv__
(
self
,
other
)
def
__itruediv__
(
self
,
other
):
if
isinstance
(
other
,
NUMERIC_TYPES
):
...
...
@@ -159,11 +161,15 @@ class MeasureBase(object):
return
self
else
:
raise
TypeError
(
'
%(class)
s must be divided with number'
%
{
"class"
:
pretty_name
(
self
)})
__idiv__
=
__itruediv__
# Python 2 compatibility
def
__idiv__
(
self
,
other
):
# Python 2 compatibility
return
type
(
self
)
.
__itruediv__
(
self
,
other
)
def
__bool__
(
self
):
return
bool
(
self
.
standard
)
__nonzero__
=
__bool__
# Python 2 compatibility
def
__nonzero__
(
self
):
# Python 2 compatibility
return
type
(
self
)
.
__bool__
(
self
)
def
default_units
(
self
,
kwargs
):
"""
...
...
@@ -314,7 +320,9 @@ class Area(MeasureBase):
**
{
self
.
STANDARD_UNIT
:
(
self
.
standard
/
other
)})
else
:
raise
TypeError
(
'
%(class)
s must be divided by a number'
%
{
"class"
:
pretty_name
(
self
)})
__div__
=
__truediv__
# Python 2 compatibility
def
__div__
(
self
,
other
):
# Python 2 compatibility
return
type
(
self
)
.
__truediv__
(
self
,
other
)
# Shortcuts
...
...
django/core/files/base.py
Dosyayı görüntüle @
fc10418f
...
...
@@ -28,7 +28,9 @@ class File(FileProxyMixin):
def
__bool__
(
self
):
return
bool
(
self
.
name
)
__nonzero__
=
__bool__
# Python 2
def
__nonzero__
(
self
):
# Python 2 compatibility
return
type
(
self
)
.
__bool__
(
self
)
def
__len__
(
self
):
return
self
.
size
...
...
@@ -142,7 +144,9 @@ class ContentFile(File):
def
__bool__
(
self
):
return
True
__nonzero__
=
__bool__
# Python 2
def
__nonzero__
(
self
):
# Python 2 compatibility
return
type
(
self
)
.
__bool__
(
self
)
def
open
(
self
,
mode
=
None
):
self
.
seek
(
0
)
...
...
django/core/serializers/base.py
Dosyayı görüntüle @
fc10418f
...
...
@@ -112,7 +112,7 @@ class Serializer(object):
if
callable
(
getattr
(
self
.
stream
,
'getvalue'
,
None
)):
return
self
.
stream
.
getvalue
()
class
Deserializer
(
object
):
class
Deserializer
(
six
.
Iterator
):
"""
Abstract base deserializer class.
"""
...
...
@@ -138,8 +138,6 @@ class Deserializer(object):
"""Iteration iterface -- return the next item in the stream"""
raise
NotImplementedError
next
=
__next__
# Python 2 compatibility
class
DeserializedObject
(
object
):
"""
A deserialized model.
...
...
django/core/serializers/xml_serializer.py
Dosyayı görüntüle @
fc10418f
...
...
@@ -161,8 +161,6 @@ class Deserializer(base.Deserializer):
return
self
.
_handle_object
(
node
)
raise
StopIteration
next
=
__next__
# Python 2 compatibility
def
_handle_object
(
self
,
node
):
"""
Convert an <object> node to a DeserializedObject.
...
...
django/db/backends/oracle/base.py
Dosyayı görüntüle @
fc10418f
...
...
@@ -774,7 +774,7 @@ class FormatStylePlaceholderCursor(object):
return
CursorIterator
(
self
.
cursor
)
class
CursorIterator
(
object
):
class
CursorIterator
(
six
.
Iterator
):
"""Cursor iterator wrapper that invokes our custom row factory."""
...
...
@@ -788,8 +788,6 @@ class CursorIterator(object):
def
__next__
(
self
):
return
_rowfactory
(
next
(
self
.
iter
),
self
.
cursor
)
next
=
__next__
# Python 2 compatibility
def
_rowfactory
(
row
,
cursor
):
# Cast numeric values as the appropriate Python type based upon the
...
...
django/db/models/expressions.py
Dosyayı görüntüle @
fc10418f
...
...
@@ -62,7 +62,9 @@ class ExpressionNode(tree.Node):
def
__truediv__
(
self
,
other
):
return
self
.
_combine
(
other
,
self
.
DIV
,
False
)
__div__
=
__truediv__
# Python 2 compatibility
def
__div__
(
self
,
other
):
# Python 2 compatibility
return
type
(
self
)
.
__truediv__
(
self
,
other
)
def
__mod__
(
self
,
other
):
return
self
.
_combine
(
other
,
self
.
MOD
,
False
)
...
...
@@ -94,7 +96,9 @@ class ExpressionNode(tree.Node):
def
__rtruediv__
(
self
,
other
):
return
self
.
_combine
(
other
,
self
.
DIV
,
True
)
__rdiv__
=
__rtruediv__
# Python 2 compatibility
def
__rdiv__
(
self
,
other
):
# Python 2 compatibility
return
type
(
self
)
.
__rtruediv__
(
self
,
other
)
def
__rmod__
(
self
,
other
):
return
self
.
_combine
(
other
,
self
.
MOD
,
True
)
...
...
@@ -151,10 +155,10 @@ class DateModifierNode(ExpressionNode):
(A custom function is used in order to preserve six digits of fractional
second information on sqlite, and to format both date and datetime values.)
Note that microsecond comparisons are not well supported with MySQL, since
Note that microsecond comparisons are not well supported with MySQL, since
MySQL does not store microsecond information.
Only adding and subtracting timedeltas is supported, attempts to use other
Only adding and subtracting timedeltas is supported, attempts to use other
operations raise a TypeError.
"""
def
__init__
(
self
,
children
,
connector
,
negated
=
False
):
...
...
django/db/models/query.py
Dosyayı görüntüle @
fc10418f
...
...
@@ -136,7 +136,9 @@ class QuerySet(object):
except
StopIteration
:
return
False
return
True
__nonzero__
=
__bool__
# Python 2
def
__nonzero__
(
self
):
# Python 2 compatibility
return
type
(
self
)
.
__bool__
(
self
)
def
__contains__
(
self
,
val
):
# The 'in' operator works without this method, due to __iter__. This
...
...
django/dispatch/saferef.py
Dosyayı görüntüle @
fc10418f
...
...
@@ -67,9 +67,9 @@ class BoundMethodWeakref(object):
same BoundMethodWeakref instance.
"""
_allInstances
=
weakref
.
WeakValueDictionary
()
def
__new__
(
cls
,
target
,
onDelete
=
None
,
*
arguments
,
**
named
):
"""Create new instance or return current instance
...
...
@@ -92,7 +92,7 @@ class BoundMethodWeakref(object):
cls
.
_allInstances
[
key
]
=
base
base
.
__init__
(
target
,
onDelete
,
*
arguments
,
**
named
)
return
base
def
__init__
(
self
,
target
,
onDelete
=
None
):
"""Return a weak-reference-like instance for a bound method
...
...
@@ -132,7 +132,7 @@ class BoundMethodWeakref(object):
self
.
weakFunc
=
weakref
.
ref
(
target
.
__func__
,
remove
)
self
.
selfName
=
str
(
target
.
__self__
)
self
.
funcName
=
str
(
target
.
__func__
.
__name__
)
def
calculateKey
(
cls
,
target
):
"""Calculate the reference key for this reference
...
...
@@ -141,7 +141,7 @@ class BoundMethodWeakref(object):
"""
return
(
id
(
target
.
__self__
),
id
(
target
.
__func__
))
calculateKey
=
classmethod
(
calculateKey
)
def
__str__
(
self
):
"""Give a friendly representation of the object"""
return
"""
%
s(
%
s.
%
s )"""
%
(
...
...
@@ -157,14 +157,16 @@ class BoundMethodWeakref(object):
def
__bool__
(
self
):
"""Whether we are still a valid reference"""
return
self
()
is
not
None
__nonzero__
=
__bool__
# Python 2
def
__nonzero__
(
self
):
# Python 2 compatibility
return
type
(
self
)
.
__bool__
(
self
)
def
__eq__
(
self
,
other
):
"""Compare with another reference"""
if
not
isinstance
(
other
,
self
.
__class__
):
return
self
.
__class__
==
type
(
other
)
return
self
.
key
==
other
.
key
def
__call__
(
self
):
"""Return a strong reference to the bound method
...
...
django/forms/formsets.py
Dosyayı görüntüle @
fc10418f
...
...
@@ -69,7 +69,9 @@ class BaseFormSet(object):
def
__bool__
(
self
):
"""All formsets have a management form which is not included in the length"""
return
True
__nonzero__
=
__bool__
# Python 2
def
__nonzero__
(
self
):
# Python 2 compatibility
return
type
(
self
)
.
__bool__
(
self
)
@property
def
management_form
(
self
):
...
...
django/http/multipartparser.py
Dosyayı görüntüle @
fc10418f
...
...
@@ -256,7 +256,7 @@ class MultiPartParser(object):
"""Cleanup filename from Internet Explorer full paths."""
return
filename
and
filename
[
filename
.
rfind
(
"
\\
"
)
+
1
:]
.
strip
()
class
LazyStream
(
object
):
class
LazyStream
(
six
.
Iterator
):
"""
The LazyStream wrapper allows one to get and "unget" bytes from a stream.
...
...
@@ -323,8 +323,6 @@ class LazyStream(object):
self
.
position
+=
len
(
output
)
return
output
next
=
__next__
# Python 2 compatibility
def
close
(
self
):
"""
Used to invalidate/disable this lazy stream.
...
...
@@ -369,7 +367,7 @@ class LazyStream(object):
" if there is none, report this to the Django developers."
)
class
ChunkIter
(
object
):
class
ChunkIter
(
six
.
Iterator
):
"""
An iterable that will yield chunks of data. Given a file-like object as the
constructor, this object will yield chunks of read operations from that
...
...
@@ -389,12 +387,10 @@ class ChunkIter(object):
else
:
raise
StopIteration
()
next
=
__next__
# Python 2 compatibility
def
__iter__
(
self
):
return
self
class
InterBoundaryIter
(
object
):
class
InterBoundaryIter
(
six
.
Iterator
):
"""
A Producer that will iterate over boundaries.
"""
...
...
@@ -411,9 +407,7 @@ class InterBoundaryIter(object):
except
InputStreamExhausted
:
raise
StopIteration
()
next
=
__next__
# Python 2 compatibility
class
BoundaryIter
(
object
):
class
BoundaryIter
(
six
.
Iterator
):
"""
A Producer that is sensitive to boundaries.
...
...
@@ -489,8 +483,6 @@ class BoundaryIter(object):
stream
.
unget
(
chunk
[
-
rollback
:])
return
chunk
[:
-
rollback
]
next
=
__next__
# Python 2 compatibility
def
_find_boundary
(
self
,
data
,
eof
=
False
):
"""
Finds a multipart boundary in data.
...
...
django/http/response.py
Dosyayı görüntüle @
fc10418f
...
...
@@ -23,7 +23,7 @@ class BadHeaderError(ValueError):
pass
class
HttpResponseBase
(
object
):
class
HttpResponseBase
(
six
.
Iterator
):
"""
An HTTP response base class with dictionary-accessed headers.
...
...
@@ -218,8 +218,6 @@ class HttpResponseBase(object):
# Subclasses must define self._iterator for this function.
return
self
.
make_bytes
(
next
(
self
.
_iterator
))
next
=
__next__
# Python 2 compatibility
# These methods partially implement the file-like object interface.
# See http://docs.python.org/lib/bltin-file-objects.html
...
...
django/utils/tree.py
Dosyayı görüntüle @
fc10418f
...
...
@@ -73,7 +73,9 @@ class Node(object):
For truth value testing.
"""
return
bool
(
self
.
children
)
__nonzero__
=
__bool__
# Python 2
def
__nonzero__
(
self
):
# Python 2 compatibility
return
type
(
self
)
.
__bool__
(
self
)
def
__contains__
(
self
,
other
):
"""
...
...
docs/topics/python3.txt
Dosyayı görüntüle @
fc10418f
...
...
@@ -278,15 +278,13 @@ Iterators
::
class MyIterator(
object
):
class MyIterator(
six.Iterator
):
def __iter__(self):
return self # implement some logic here
def __next__(self):
raise StopIteration # implement some logic here
next = __next__ # Python 2 compatibility
Boolean evaluation
~~~~~~~~~~~~~~~~~~
...
...
@@ -297,7 +295,8 @@ Boolean evaluation
def __bool__(self):
return True # implement some logic here
__nonzero__ = __bool__ # Python 2 compatibility
def __nonzero__(self): # Python 2 compatibility
return type(self).__bool__(self)
Division
~~~~~~~~
...
...
@@ -309,12 +308,14 @@ Division
def __truediv__(self, other):
return self / other # implement some logic here
__div__ = __truediv__ # Python 2 compatibility
def __div__(self, other): # Python 2 compatibility
return type(self).__truediv__(self, other)
def __itruediv__(self, other):
return self // other # implement some logic here
__idiv__ = __itruediv__ # Python 2 compatibility
def __idiv__(self, other): # Python 2 compatibility
return type(self).__itruediv__(self, other)
.. module: django.utils.six
...
...
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