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
4c593eaa
Kaydet (Commit)
4c593eaa
authored
Kas 11, 2015
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Updated six to 1.10.0.
üst
e0de82c9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
22 deletions
+55
-22
six.py
django/utils/six.py
+52
-22
1.8.7.txt
docs/releases/1.8.7.txt
+3
-0
No files found.
django/utils/six.py
Dosyayı görüntüle @
4c593eaa
...
@@ -29,12 +29,13 @@ import sys
...
@@ -29,12 +29,13 @@ import sys
import
types
import
types
__author__
=
"Benjamin Peterson <benjamin@python.org>"
__author__
=
"Benjamin Peterson <benjamin@python.org>"
__version__
=
"1.
9
.0"
__version__
=
"1.
10
.0"
# Useful for very coarse version differentiation.
# Useful for very coarse version differentiation.
PY2
=
sys
.
version_info
[
0
]
==
2
PY2
=
sys
.
version_info
[
0
]
==
2
PY3
=
sys
.
version_info
[
0
]
==
3
PY3
=
sys
.
version_info
[
0
]
==
3
PY34
=
sys
.
version_info
[
0
:
2
]
>=
(
3
,
4
)
if
PY3
:
if
PY3
:
string_types
=
str
,
string_types
=
str
,
...
@@ -57,6 +58,7 @@ else:
...
@@ -57,6 +58,7 @@ else:
else
:
else
:
# It's possible to have sizeof(long) != sizeof(Py_ssize_t).
# It's possible to have sizeof(long) != sizeof(Py_ssize_t).
class
X
(
object
):
class
X
(
object
):
def
__len__
(
self
):
def
__len__
(
self
):
return
1
<<
31
return
1
<<
31
try
:
try
:
...
@@ -88,7 +90,7 @@ class _LazyDescr(object):
...
@@ -88,7 +90,7 @@ class _LazyDescr(object):
def
__get__
(
self
,
obj
,
tp
):
def
__get__
(
self
,
obj
,
tp
):
result
=
self
.
_resolve
()
result
=
self
.
_resolve
()
setattr
(
obj
,
self
.
name
,
result
)
# Invokes __set__.
setattr
(
obj
,
self
.
name
,
result
)
# Invokes __set__.
try
:
try
:
# This is a bit ugly, but it avoids running this again by
# This is a bit ugly, but it avoids running this again by
# removing this descriptor.
# removing this descriptor.
...
@@ -160,12 +162,14 @@ class MovedAttribute(_LazyDescr):
...
@@ -160,12 +162,14 @@ class MovedAttribute(_LazyDescr):
class
_SixMetaPathImporter
(
object
):
class
_SixMetaPathImporter
(
object
):
"""
"""
A meta path importer to import six.moves and its submodules.
A meta path importer to import six.moves and its submodules.
This class implements a PEP302 finder and loader. It should be compatible
This class implements a PEP302 finder and loader. It should be compatible
with Python 2.5 and all existing versions of Python3
with Python 2.5 and all existing versions of Python3
"""
"""
def
__init__
(
self
,
six_module_name
):
def
__init__
(
self
,
six_module_name
):
self
.
name
=
six_module_name
self
.
name
=
six_module_name
self
.
known_modules
=
{}
self
.
known_modules
=
{}
...
@@ -223,6 +227,7 @@ _importer = _SixMetaPathImporter(__name__)
...
@@ -223,6 +227,7 @@ _importer = _SixMetaPathImporter(__name__)
class
_MovedItems
(
_LazyModule
):
class
_MovedItems
(
_LazyModule
):
"""Lazy loading of moved objects"""
"""Lazy loading of moved objects"""
__path__
=
[]
# mark as package
__path__
=
[]
# mark as package
...
@@ -234,8 +239,10 @@ _moved_attributes = [
...
@@ -234,8 +239,10 @@ _moved_attributes = [
MovedAttribute
(
"input"
,
"__builtin__"
,
"builtins"
,
"raw_input"
,
"input"
),
MovedAttribute
(
"input"
,
"__builtin__"
,
"builtins"
,
"raw_input"
,
"input"
),
MovedAttribute
(
"intern"
,
"__builtin__"
,
"sys"
),
MovedAttribute
(
"intern"
,
"__builtin__"
,
"sys"
),
MovedAttribute
(
"map"
,
"itertools"
,
"builtins"
,
"imap"
,
"map"
),
MovedAttribute
(
"map"
,
"itertools"
,
"builtins"
,
"imap"
,
"map"
),
MovedAttribute
(
"getcwd"
,
"os"
,
"os"
,
"getcwdu"
,
"getcwd"
),
MovedAttribute
(
"getcwdb"
,
"os"
,
"os"
,
"getcwd"
,
"getcwdb"
),
MovedAttribute
(
"range"
,
"__builtin__"
,
"builtins"
,
"xrange"
,
"range"
),
MovedAttribute
(
"range"
,
"__builtin__"
,
"builtins"
,
"xrange"
,
"range"
),
MovedAttribute
(
"reload_module"
,
"__builtin__"
,
"imp"
,
"reload"
),
MovedAttribute
(
"reload_module"
,
"__builtin__"
,
"imp
ortlib"
if
PY34
else
"imp
"
,
"reload"
),
MovedAttribute
(
"reduce"
,
"__builtin__"
,
"functools"
),
MovedAttribute
(
"reduce"
,
"__builtin__"
,
"functools"
),
MovedAttribute
(
"shlex_quote"
,
"pipes"
,
"shlex"
,
"quote"
),
MovedAttribute
(
"shlex_quote"
,
"pipes"
,
"shlex"
,
"quote"
),
MovedAttribute
(
"StringIO"
,
"StringIO"
,
"io"
),
MovedAttribute
(
"StringIO"
,
"StringIO"
,
"io"
),
...
@@ -245,7 +252,6 @@ _moved_attributes = [
...
@@ -245,7 +252,6 @@ _moved_attributes = [
MovedAttribute
(
"xrange"
,
"__builtin__"
,
"builtins"
,
"xrange"
,
"range"
),
MovedAttribute
(
"xrange"
,
"__builtin__"
,
"builtins"
,
"xrange"
,
"range"
),
MovedAttribute
(
"zip"
,
"itertools"
,
"builtins"
,
"izip"
,
"zip"
),
MovedAttribute
(
"zip"
,
"itertools"
,
"builtins"
,
"izip"
,
"zip"
),
MovedAttribute
(
"zip_longest"
,
"itertools"
,
"itertools"
,
"izip_longest"
,
"zip_longest"
),
MovedAttribute
(
"zip_longest"
,
"itertools"
,
"itertools"
,
"izip_longest"
,
"zip_longest"
),
MovedModule
(
"builtins"
,
"__builtin__"
),
MovedModule
(
"builtins"
,
"__builtin__"
),
MovedModule
(
"configparser"
,
"ConfigParser"
),
MovedModule
(
"configparser"
,
"ConfigParser"
),
MovedModule
(
"copyreg"
,
"copy_reg"
),
MovedModule
(
"copyreg"
,
"copy_reg"
),
...
@@ -292,8 +298,13 @@ _moved_attributes = [
...
@@ -292,8 +298,13 @@ _moved_attributes = [
MovedModule
(
"urllib_robotparser"
,
"robotparser"
,
"urllib.robotparser"
),
MovedModule
(
"urllib_robotparser"
,
"robotparser"
,
"urllib.robotparser"
),
MovedModule
(
"xmlrpc_client"
,
"xmlrpclib"
,
"xmlrpc.client"
),
MovedModule
(
"xmlrpc_client"
,
"xmlrpclib"
,
"xmlrpc.client"
),
MovedModule
(
"xmlrpc_server"
,
"SimpleXMLRPCServer"
,
"xmlrpc.server"
),
MovedModule
(
"xmlrpc_server"
,
"SimpleXMLRPCServer"
,
"xmlrpc.server"
),
MovedModule
(
"winreg"
,
"_winreg"
),
]
]
# Add windows specific modules.
if
sys
.
platform
==
"win32"
:
_moved_attributes
+=
[
MovedModule
(
"winreg"
,
"_winreg"
),
]
for
attr
in
_moved_attributes
:
for
attr
in
_moved_attributes
:
setattr
(
_MovedItems
,
attr
.
name
,
attr
)
setattr
(
_MovedItems
,
attr
.
name
,
attr
)
if
isinstance
(
attr
,
MovedModule
):
if
isinstance
(
attr
,
MovedModule
):
...
@@ -307,6 +318,7 @@ _importer._add_module(moves, "moves")
...
@@ -307,6 +318,7 @@ _importer._add_module(moves, "moves")
class
Module_six_moves_urllib_parse
(
_LazyModule
):
class
Module_six_moves_urllib_parse
(
_LazyModule
):
"""Lazy loading of moved objects in six.moves.urllib_parse"""
"""Lazy loading of moved objects in six.moves.urllib_parse"""
...
@@ -346,6 +358,7 @@ _importer._add_module(Module_six_moves_urllib_parse(__name__ + ".moves.urllib_pa
...
@@ -346,6 +358,7 @@ _importer._add_module(Module_six_moves_urllib_parse(__name__ + ".moves.urllib_pa
class
Module_six_moves_urllib_error
(
_LazyModule
):
class
Module_six_moves_urllib_error
(
_LazyModule
):
"""Lazy loading of moved objects in six.moves.urllib_error"""
"""Lazy loading of moved objects in six.moves.urllib_error"""
...
@@ -365,6 +378,7 @@ _importer._add_module(Module_six_moves_urllib_error(__name__ + ".moves.urllib.er
...
@@ -365,6 +378,7 @@ _importer._add_module(Module_six_moves_urllib_error(__name__ + ".moves.urllib.er
class
Module_six_moves_urllib_request
(
_LazyModule
):
class
Module_six_moves_urllib_request
(
_LazyModule
):
"""Lazy loading of moved objects in six.moves.urllib_request"""
"""Lazy loading of moved objects in six.moves.urllib_request"""
...
@@ -414,6 +428,7 @@ _importer._add_module(Module_six_moves_urllib_request(__name__ + ".moves.urllib.
...
@@ -414,6 +428,7 @@ _importer._add_module(Module_six_moves_urllib_request(__name__ + ".moves.urllib.
class
Module_six_moves_urllib_response
(
_LazyModule
):
class
Module_six_moves_urllib_response
(
_LazyModule
):
"""Lazy loading of moved objects in six.moves.urllib_response"""
"""Lazy loading of moved objects in six.moves.urllib_response"""
...
@@ -434,6 +449,7 @@ _importer._add_module(Module_six_moves_urllib_response(__name__ + ".moves.urllib
...
@@ -434,6 +449,7 @@ _importer._add_module(Module_six_moves_urllib_response(__name__ + ".moves.urllib
class
Module_six_moves_urllib_robotparser
(
_LazyModule
):
class
Module_six_moves_urllib_robotparser
(
_LazyModule
):
"""Lazy loading of moved objects in six.moves.urllib_robotparser"""
"""Lazy loading of moved objects in six.moves.urllib_robotparser"""
...
@@ -451,6 +467,7 @@ _importer._add_module(Module_six_moves_urllib_robotparser(__name__ + ".moves.url
...
@@ -451,6 +467,7 @@ _importer._add_module(Module_six_moves_urllib_robotparser(__name__ + ".moves.url
class
Module_six_moves_urllib
(
types
.
ModuleType
):
class
Module_six_moves_urllib
(
types
.
ModuleType
):
"""Create a six.moves.urllib namespace that resembles the Python 3 namespace"""
"""Create a six.moves.urllib namespace that resembles the Python 3 namespace"""
__path__
=
[]
# mark as package
__path__
=
[]
# mark as package
parse
=
_importer
.
_get_module
(
"moves.urllib_parse"
)
parse
=
_importer
.
_get_module
(
"moves.urllib_parse"
)
...
@@ -521,6 +538,9 @@ if PY3:
...
@@ -521,6 +538,9 @@ if PY3:
create_bound_method
=
types
.
MethodType
create_bound_method
=
types
.
MethodType
def
create_unbound_method
(
func
,
cls
):
return
func
Iterator
=
object
Iterator
=
object
else
:
else
:
def
get_unbound_function
(
unbound
):
def
get_unbound_function
(
unbound
):
...
@@ -529,6 +549,9 @@ else:
...
@@ -529,6 +549,9 @@ else:
def
create_bound_method
(
func
,
obj
):
def
create_bound_method
(
func
,
obj
):
return
types
.
MethodType
(
func
,
obj
,
obj
.
__class__
)
return
types
.
MethodType
(
func
,
obj
,
obj
.
__class__
)
def
create_unbound_method
(
func
,
cls
):
return
types
.
MethodType
(
func
,
None
,
cls
)
class
Iterator
(
object
):
class
Iterator
(
object
):
def
next
(
self
):
def
next
(
self
):
...
@@ -567,16 +590,16 @@ if PY3:
...
@@ -567,16 +590,16 @@ if PY3:
viewitems
=
operator
.
methodcaller
(
"items"
)
viewitems
=
operator
.
methodcaller
(
"items"
)
else
:
else
:
def
iterkeys
(
d
,
**
kw
):
def
iterkeys
(
d
,
**
kw
):
return
iter
(
d
.
iterkeys
(
**
kw
)
)
return
d
.
iterkeys
(
**
kw
)
def
itervalues
(
d
,
**
kw
):
def
itervalues
(
d
,
**
kw
):
return
iter
(
d
.
itervalues
(
**
kw
)
)
return
d
.
itervalues
(
**
kw
)
def
iteritems
(
d
,
**
kw
):
def
iteritems
(
d
,
**
kw
):
return
iter
(
d
.
iteritems
(
**
kw
)
)
return
d
.
iteritems
(
**
kw
)
def
iterlists
(
d
,
**
kw
):
def
iterlists
(
d
,
**
kw
):
return
iter
(
d
.
iterlists
(
**
kw
)
)
return
d
.
iterlists
(
**
kw
)
viewkeys
=
operator
.
methodcaller
(
"viewkeys"
)
viewkeys
=
operator
.
methodcaller
(
"viewkeys"
)
...
@@ -595,15 +618,13 @@ _add_doc(iterlists,
...
@@ -595,15 +618,13 @@ _add_doc(iterlists,
if
PY3
:
if
PY3
:
def
b
(
s
):
def
b
(
s
):
return
s
.
encode
(
"latin-1"
)
return
s
.
encode
(
"latin-1"
)
def
u
(
s
):
def
u
(
s
):
return
s
return
s
unichr
=
chr
unichr
=
chr
if
sys
.
version_info
[
1
]
<=
1
:
import
struct
def
int2byte
(
i
):
int2byte
=
struct
.
Struct
(
">B"
)
.
pack
return
bytes
((
i
,))
del
struct
else
:
# This is about 2x faster than the implementation above on 3.2+
int2byte
=
operator
.
methodcaller
(
"to_bytes"
,
1
,
"big"
)
byte2int
=
operator
.
itemgetter
(
0
)
byte2int
=
operator
.
itemgetter
(
0
)
indexbytes
=
operator
.
getitem
indexbytes
=
operator
.
getitem
iterbytes
=
iter
iterbytes
=
iter
...
@@ -611,18 +632,25 @@ if PY3:
...
@@ -611,18 +632,25 @@ if PY3:
StringIO
=
io
.
StringIO
StringIO
=
io
.
StringIO
BytesIO
=
io
.
BytesIO
BytesIO
=
io
.
BytesIO
_assertCountEqual
=
"assertCountEqual"
_assertCountEqual
=
"assertCountEqual"
_assertRaisesRegex
=
"assertRaisesRegex"
if
sys
.
version_info
[
1
]
<=
1
:
_assertRegex
=
"assertRegex"
_assertRaisesRegex
=
"assertRaisesRegexp"
_assertRegex
=
"assertRegexpMatches"
else
:
_assertRaisesRegex
=
"assertRaisesRegex"
_assertRegex
=
"assertRegex"
else
:
else
:
def
b
(
s
):
def
b
(
s
):
return
s
return
s
# Workaround for standalone backslash
# Workaround for standalone backslash
def
u
(
s
):
def
u
(
s
):
return
unicode
(
s
.
replace
(
r'\\'
,
r'\\\\'
),
"unicode_escape"
)
return
unicode
(
s
.
replace
(
r'\\'
,
r'\\\\'
),
"unicode_escape"
)
unichr
=
unichr
unichr
=
unichr
int2byte
=
chr
int2byte
=
chr
def
byte2int
(
bs
):
def
byte2int
(
bs
):
return
ord
(
bs
[
0
])
return
ord
(
bs
[
0
])
def
indexbytes
(
buf
,
i
):
def
indexbytes
(
buf
,
i
):
return
ord
(
buf
[
i
])
return
ord
(
buf
[
i
])
iterbytes
=
functools
.
partial
(
itertools
.
imap
,
ord
)
iterbytes
=
functools
.
partial
(
itertools
.
imap
,
ord
)
...
@@ -650,7 +678,6 @@ def assertRegex(self, *args, **kwargs):
...
@@ -650,7 +678,6 @@ def assertRegex(self, *args, **kwargs):
if
PY3
:
if
PY3
:
exec_
=
getattr
(
moves
.
builtins
,
"exec"
)
exec_
=
getattr
(
moves
.
builtins
,
"exec"
)
def
reraise
(
tp
,
value
,
tb
=
None
):
def
reraise
(
tp
,
value
,
tb
=
None
):
if
value
is
None
:
if
value
is
None
:
value
=
tp
()
value
=
tp
()
...
@@ -671,7 +698,6 @@ else:
...
@@ -671,7 +698,6 @@ else:
_locs_
=
_globs_
_locs_
=
_globs_
exec
(
"""exec _code_ in _globs_, _locs_"""
)
exec
(
"""exec _code_ in _globs_, _locs_"""
)
exec_
(
"""def reraise(tp, value, tb=None):
exec_
(
"""def reraise(tp, value, tb=None):
raise tp, value, tb
raise tp, value, tb
"""
)
"""
)
...
@@ -699,13 +725,14 @@ if print_ is None:
...
@@ -699,13 +725,14 @@ if print_ is None:
fp
=
kwargs
.
pop
(
"file"
,
sys
.
stdout
)
fp
=
kwargs
.
pop
(
"file"
,
sys
.
stdout
)
if
fp
is
None
:
if
fp
is
None
:
return
return
def
write
(
data
):
def
write
(
data
):
if
not
isinstance
(
data
,
basestring
):
if
not
isinstance
(
data
,
basestring
):
data
=
str
(
data
)
data
=
str
(
data
)
# If the file has an encoding, encode unicode with it.
# If the file has an encoding, encode unicode with it.
if
(
isinstance
(
fp
,
file
)
and
if
(
isinstance
(
fp
,
file
)
and
isinstance
(
data
,
unicode
)
and
isinstance
(
data
,
unicode
)
and
fp
.
encoding
is
not
None
):
fp
.
encoding
is
not
None
):
errors
=
getattr
(
fp
,
"errors"
,
None
)
errors
=
getattr
(
fp
,
"errors"
,
None
)
if
errors
is
None
:
if
errors
is
None
:
errors
=
"strict"
errors
=
"strict"
...
@@ -748,6 +775,7 @@ if print_ is None:
...
@@ -748,6 +775,7 @@ if print_ is None:
write
(
end
)
write
(
end
)
if
sys
.
version_info
[:
2
]
<
(
3
,
3
):
if
sys
.
version_info
[:
2
]
<
(
3
,
3
):
_print
=
print_
_print
=
print_
def
print_
(
*
args
,
**
kwargs
):
def
print_
(
*
args
,
**
kwargs
):
fp
=
kwargs
.
get
(
"file"
,
sys
.
stdout
)
fp
=
kwargs
.
get
(
"file"
,
sys
.
stdout
)
flush
=
kwargs
.
pop
(
"flush"
,
False
)
flush
=
kwargs
.
pop
(
"flush"
,
False
)
...
@@ -768,12 +796,14 @@ if sys.version_info[0:2] < (3, 4):
...
@@ -768,12 +796,14 @@ if sys.version_info[0:2] < (3, 4):
else
:
else
:
wraps
=
functools
.
wraps
wraps
=
functools
.
wraps
def
with_metaclass
(
meta
,
*
bases
):
def
with_metaclass
(
meta
,
*
bases
):
"""Create a base class with a metaclass."""
"""Create a base class with a metaclass."""
# This requires a bit of explanation: the basic idea is to make a dummy
# This requires a bit of explanation: the basic idea is to make a dummy
# metaclass for one level of class instantiation that replaces itself with
# metaclass for one level of class instantiation that replaces itself with
# the actual metaclass.
# the actual metaclass.
class
metaclass
(
meta
):
class
metaclass
(
meta
):
def
__new__
(
cls
,
name
,
this_bases
,
d
):
def
__new__
(
cls
,
name
,
this_bases
,
d
):
return
meta
(
name
,
bases
,
d
)
return
meta
(
name
,
bases
,
d
)
return
type
.
__new__
(
metaclass
,
'temporary_class'
,
(),
{})
return
type
.
__new__
(
metaclass
,
'temporary_class'
,
(),
{})
...
@@ -830,7 +860,7 @@ if sys.meta_path:
...
@@ -830,7 +860,7 @@ if sys.meta_path:
# the six meta path importer, since the other six instance will have
# the six meta path importer, since the other six instance will have
# inserted an importer with different class.
# inserted an importer with different class.
if
(
type
(
importer
)
.
__name__
==
"_SixMetaPathImporter"
and
if
(
type
(
importer
)
.
__name__
==
"_SixMetaPathImporter"
and
importer
.
name
==
__name__
):
importer
.
name
==
__name__
):
del
sys
.
meta_path
[
i
]
del
sys
.
meta_path
[
i
]
break
break
del
i
,
importer
del
i
,
importer
...
...
docs/releases/1.8.7.txt
Dosyayı görüntüle @
4c593eaa
...
@@ -6,6 +6,9 @@ Django 1.8.7 release notes
...
@@ -6,6 +6,9 @@ Django 1.8.7 release notes
Django 1.8.7 fixes several bugs in 1.8.6.
Django 1.8.7 fixes several bugs in 1.8.6.
Additionally, Django's vendored version of six, :mod:`django.utils.six`, has
been upgraded to the latest release (1.10.0).
Bugfixes
Bugfixes
========
========
...
...
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