Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
zope.proxy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
zope.proxy
Commits
47481643
Commit
47481643
authored
Mar 14, 2011
by
Lennart Regebro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Python 3 support
parent
550c0c6e
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
173 additions
and
50 deletions
+173
-50
CHANGES.txt
CHANGES.txt
+1
-0
setup.py
setup.py
+11
-1
src/zope/proxy/_zope_proxy_proxy.c
src/zope/proxy/_zope_proxy_proxy.c
+139
-44
src/zope/proxy/tests/test_proxy.py
src/zope/proxy/tests/test_proxy.py
+22
-5
No files found.
CHANGES.txt
View file @
47481643
...
...
@@ -5,6 +5,7 @@ CHANGES
3.6.2 (unreleased)
------------------
- Python 3 support.
3.6.1 (2010-07-06)
------------------
...
...
setup.py
View file @
47481643
...
...
@@ -18,9 +18,18 @@
##############################################################################
"""Setup for zope.proxy package
"""
import
os
import
os
,
sys
from
setuptools
import
setup
,
Extension
if
sys
.
version_info
>=
(
3
,):
extra
=
dict
(
use_2to3
=
True
,
convert_2to3_doctests
=
[
'src/zope/i18nmessageid/messages.txt'
,
],
)
else
:
extra
=
{}
def
read
(
*
rnames
):
return
open
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
*
rnames
)).
read
()
...
...
@@ -61,4 +70,5 @@ setup(name='zope.proxy',
'setuptools'
],
include_package_data
=
True
,
zip_safe
=
False
,
**
extra
)
src/zope/proxy/_zope_proxy_proxy.c
View file @
47481643
This diff is collapsed.
Click to expand it.
src/zope/proxy/tests/test_proxy.py
View file @
47481643
...
...
@@ -120,6 +120,10 @@ class ProxyTestCase(unittest.TestCase):
self
.
assert_
(
w
.
__class__
is
o
.
__class__
)
def
test_pickle_prevention
(
self
):
# Proxies of old-style classes can't be pickled.
if
sys
.
version
>
'3'
:
# No old-style classes in Python 3.
return
w
=
self
.
new_proxy
(
Thing
())
self
.
assertRaises
(
pickle
.
PicklingError
,
pickle
.
dumps
,
w
)
...
...
@@ -162,8 +166,9 @@ class ProxyTestCase(unittest.TestCase):
self
.
assert_
(
w2
<=
o2
)
def
test_proxy_callable
(
self
):
w
=
self
.
new_proxy
({}.
get
)
self
.
assert_
(
callable
(
w
))
if
sys
.
version
<
'3'
:
# Gone in Python 3:
w
=
self
.
new_proxy
({}.
get
)
self
.
assert_
(
callable
(
w
))
def
test_proxy_item_protocol
(
self
):
w
=
self
.
new_proxy
({})
...
...
@@ -220,8 +225,10 @@ class ProxyTestCase(unittest.TestCase):
unops
=
[
"-x"
,
"+x"
,
"abs(x)"
,
"~x"
,
"int(x)"
,
"
long(x)"
,
"
float(x)"
,
"int(x)"
,
"float(x)"
,
]
if
sys
.
version
<
'3'
:
# long is gone in Python 3
unops
.
append
(
"long(x)"
)
def
test_unops
(
self
):
P
=
self
.
new_proxy
...
...
@@ -236,7 +243,10 @@ class ProxyTestCase(unittest.TestCase):
def
test_odd_unops
(
self
):
# unops that don't return a proxy
P
=
self
.
new_proxy
for
func
in
hex
,
oct
,
lambda
x
:
not
x
:
funcs
=
(
lambda
x
:
not
x
,)
if
sys
.
version
<
'3'
:
funcs
+=
(
oct
,
hex
)
for
func
in
funcs
:
self
.
assertEqual
(
func
(
P
(
100
)),
func
(
100
))
binops
=
[
...
...
@@ -276,6 +286,9 @@ class ProxyTestCase(unittest.TestCase):
self
.
assertEqual
(
pa
,
4
)
def
test_coerce
(
self
):
if
sys
.
version
>
'3'
:
# No coercion in Python 3
return
P
=
self
.
new_proxy
# Before 2.3, coerce() of two proxies returns them unchanged
...
...
@@ -339,7 +352,11 @@ class ProxyTestCase(unittest.TestCase):
self
.
failUnless
(
b
is
y
)
def
test_getslice
(
self
):
# Lists have special slicing bahvior.
# These tests are moot under Python 3 as __slice__ isn't supported.
if
sys
.
version
>
'3'
:
return
# Lists have special slicing behavior.
pList
=
self
.
new_proxy
([
1
,
2
])
self
.
assertEqual
(
pList
[
-
1
:],
[
2
])
self
.
assertEqual
(
pList
[
-
2
:],
[
1
,
2
])
...
...
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