Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
persistent
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
Kirill Smelkov
persistent
Commits
66d6eabb
Commit
66d6eabb
authored
Aug 01, 2018
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unneeded _compat._b/_u/_native.
Also some minor DRY in test_picklecache.py Fixes #81.
parent
de8680be
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
176 additions
and
274 deletions
+176
-274
CHANGES.rst
CHANGES.rst
+4
-1
persistent/_compat.py
persistent/_compat.py
+1
-24
persistent/tests/test_persistence.py
persistent/tests/test_persistence.py
+1
-3
persistent/tests/test_picklecache.py
persistent/tests/test_picklecache.py
+159
-231
persistent/tests/test_wref.py
persistent/tests/test_wref.py
+11
-15
No files found.
CHANGES.rst
View file @
66d6eabb
...
@@ -7,7 +7,8 @@
...
@@ -7,7 +7,8 @@
- Reach and maintain 100% test coverage.
- Reach and maintain 100% test coverage.
- Simplify ``__init__.py``, including removal of an attempted legacy
- Simplify ``__init__.py``, including removal of an attempted legacy
import of ``persistent.TimeStamp``.
import of ``persistent.TimeStamp``. See `PR 80
<https://github.com/zopefoundation/persistent/pull/80>`_.
- Add support for Python 3.7 and drop support for Python 3.3.
- Add support for Python 3.7 and drop support for Python 3.3.
...
@@ -27,6 +28,8 @@
...
@@ -27,6 +28,8 @@
- Fix deleting special (``_p``) attributes of a pure-Python persistent
- Fix deleting special (``_p``) attributes of a pure-Python persistent
object that overrides ``__delattr__`` and correctly calls ``_p_delattr``.
object that overrides ``__delattr__`` and correctly calls ``_p_delattr``.
- Remove some internal compatibility shims that are no longer
necessary. See `PR 82 <https://github.com/zopefoundation/persistent/pull/82>`_.
4.3.0 (2018-07-30)
4.3.0 (2018-07-30)
------------------
------------------
...
...
persistent/_compat.py
View file @
66d6eabb
...
@@ -17,25 +17,12 @@ import os
...
@@ -17,25 +17,12 @@ import os
PURE_PYTHON
=
os
.
environ
.
get
(
'PURE_PYTHON'
)
PURE_PYTHON
=
os
.
environ
.
get
(
'PURE_PYTHON'
)
if
sys
.
version_info
[
0
]
>
2
:
# pragma: no cover
if
sys
.
version_info
[
0
]
>
2
:
import
copyreg
as
copy_reg
import
copyreg
as
copy_reg
from
collections
import
UserDict
as
IterableUserDict
from
collections
import
UserDict
as
IterableUserDict
from
collections
import
UserList
from
collections
import
UserList
from
sys
import
intern
from
sys
import
intern
def
_u
(
s
):
return
s
def
_b
(
s
):
if
isinstance
(
s
,
str
):
return
s
.
encode
(
'unicode_escape'
)
return
s
def
_native
(
s
):
if
isinstance
(
s
,
bytes
):
return
s
.
decode
(
'unicode_escape'
)
return
s
PYTHON3
=
True
PYTHON3
=
True
PYTHON2
=
False
PYTHON2
=
False
...
@@ -44,16 +31,6 @@ else: # pragma: no cover
...
@@ -44,16 +31,6 @@ else: # pragma: no cover
from
UserDict
import
IterableUserDict
from
UserDict
import
IterableUserDict
from
UserList
import
UserList
from
UserList
import
UserList
def
_u
(
s
):
return
unicode
(
s
,
'unicode_escape'
)
def
_native
(
s
):
if
isinstance
(
s
,
unicode
):
return
s
.
encode
(
'unicode_escape'
)
return
s
_b
=
_native
PYTHON3
=
False
PYTHON3
=
False
PYTHON2
=
True
PYTHON2
=
True
...
...
persistent/tests/test_persistence.py
View file @
66d6eabb
...
@@ -1735,7 +1735,6 @@ class PyPersistentTests(unittest.TestCase, _Persistent_Base):
...
@@ -1735,7 +1735,6 @@ class PyPersistentTests(unittest.TestCase, _Persistent_Base):
# but because they are newly created, they aren't in the
# but because they are newly created, they aren't in the
# pickle cache yet.
# pickle cache yet.
# Nothing should blow up when this happens
# Nothing should blow up when this happens
from
persistent._compat
import
_b
KEY
=
b'123'
KEY
=
b'123'
jar
=
self
.
_makeJar
()
jar
=
self
.
_makeJar
()
c1
=
self
.
_makeOne
()
c1
=
self
.
_makeOne
()
...
@@ -1753,8 +1752,7 @@ class PyPersistentTests(unittest.TestCase, _Persistent_Base):
...
@@ -1753,8 +1752,7 @@ class PyPersistentTests(unittest.TestCase, _Persistent_Base):
def
test_accessed_invalidated_with_jar_and_oid_but_no_cache
(
self
):
def
test_accessed_invalidated_with_jar_and_oid_but_no_cache
(
self
):
# This scenario arises in ZODB tests where the jar is faked
# This scenario arises in ZODB tests where the jar is faked
from
persistent._compat
import
_b
KEY
=
b'123'
KEY
=
_b
(
'123'
)
class
Jar
(
object
):
class
Jar
(
object
):
accessed
=
False
accessed
=
False
def
__getattr__
(
self
,
name
):
def
__getattr__
(
self
,
name
):
...
...
persistent/tests/test_picklecache.py
View file @
66d6eabb
This diff is collapsed.
Click to expand it.
persistent/tests/test_wref.py
View file @
66d6eabb
...
@@ -24,21 +24,19 @@ class WeakRefTests(unittest.TestCase):
...
@@ -24,21 +24,19 @@ class WeakRefTests(unittest.TestCase):
return
self
.
_getTargetClass
()(
ob
)
return
self
.
_getTargetClass
()(
ob
)
def
test_ctor_target_wo_jar
(
self
):
def
test_ctor_target_wo_jar
(
self
):
from
persistent._compat
import
_b
target
=
_makeTarget
()
target
=
_makeTarget
()
wref
=
self
.
_makeOne
(
target
)
wref
=
self
.
_makeOne
(
target
)
self
.
assertTrue
(
wref
.
_v_ob
is
target
)
self
.
assertTrue
(
wref
.
_v_ob
is
target
)
self
.
assertEqual
(
wref
.
oid
,
_b
(
'OID'
)
)
self
.
assertEqual
(
wref
.
oid
,
b'OID'
)
self
.
assertTrue
(
wref
.
dm
is
None
)
self
.
assertTrue
(
wref
.
dm
is
None
)
self
.
assertFalse
(
'database_name'
in
wref
.
__dict__
)
self
.
assertFalse
(
'database_name'
in
wref
.
__dict__
)
def
test_ctor_target_w_jar
(
self
):
def
test_ctor_target_w_jar
(
self
):
from
persistent._compat
import
_b
target
=
_makeTarget
()
target
=
_makeTarget
()
target
.
_p_jar
=
jar
=
_makeJar
()
target
.
_p_jar
=
jar
=
_makeJar
()
wref
=
self
.
_makeOne
(
target
)
wref
=
self
.
_makeOne
(
target
)
self
.
assertTrue
(
wref
.
_v_ob
is
target
)
self
.
assertTrue
(
wref
.
_v_ob
is
target
)
self
.
assertEqual
(
wref
.
oid
,
_b
(
'OID'
)
)
self
.
assertEqual
(
wref
.
oid
,
b'OID'
)
self
.
assertTrue
(
wref
.
dm
is
jar
)
self
.
assertTrue
(
wref
.
dm
is
jar
)
self
.
assertEqual
(
wref
.
database_name
,
'testing'
)
self
.
assertEqual
(
wref
.
database_name
,
'testing'
)
...
@@ -181,14 +179,13 @@ class PersistentWeakKeyDictionaryTests(unittest.TestCase):
...
@@ -181,14 +179,13 @@ class PersistentWeakKeyDictionaryTests(unittest.TestCase):
def
test___setstate___empty
(
self
):
def
test___setstate___empty
(
self
):
from
persistent.wref
import
WeakRef
from
persistent.wref
import
WeakRef
from
persistent._compat
import
_b
jar
=
_makeJar
()
jar
=
_makeJar
()
KEY
=
_b
(
'KEY'
)
KEY
=
b'KEY'
KEY2
=
_b
(
'KEY2'
)
KEY2
=
b'KEY2'
KEY3
=
_b
(
'KEY3'
)
KEY3
=
b'KEY3'
VALUE
=
_b
(
'VALUE'
)
VALUE
=
b'VALUE'
VALUE2
=
_b
(
'VALUE2'
)
VALUE2
=
b'VALUE2'
VALUE3
=
_b
(
'VALUE3'
)
VALUE3
=
b'VALUE3'
key
=
jar
[
KEY
]
=
_makeTarget
(
oid
=
KEY
)
key
=
jar
[
KEY
]
=
_makeTarget
(
oid
=
KEY
)
key
.
_p_jar
=
jar
key
.
_p_jar
=
jar
kref
=
WeakRef
(
key
)
kref
=
WeakRef
(
key
)
...
@@ -208,7 +205,7 @@ class PersistentWeakKeyDictionaryTests(unittest.TestCase):
...
@@ -208,7 +205,7 @@ class PersistentWeakKeyDictionaryTests(unittest.TestCase):
value3
.
_p_jar
=
jar
value3
.
_p_jar
=
jar
pwkd
=
self
.
_makeOne
(
None
)
pwkd
=
self
.
_makeOne
(
None
)
pwkd
.
__setstate__
({
'data'
:
pwkd
.
__setstate__
({
'data'
:
[(
kref
,
value
),
(
kref2
,
value2
),
(
kref3
,
value3
)]})
[(
kref
,
value
),
(
kref2
,
value2
),
(
kref3
,
value3
)]})
self
.
assertTrue
(
pwkd
[
key
]
is
value
)
self
.
assertTrue
(
pwkd
[
key
]
is
value
)
self
.
assertTrue
(
pwkd
.
get
(
key2
)
is
None
)
self
.
assertTrue
(
pwkd
.
get
(
key2
)
is
None
)
self
.
assertTrue
(
pwkd
[
key3
]
is
value3
)
self
.
assertTrue
(
pwkd
[
key3
]
is
value3
)
...
@@ -317,9 +314,8 @@ class PersistentWeakKeyDictionaryTests(unittest.TestCase):
...
@@ -317,9 +314,8 @@ class PersistentWeakKeyDictionaryTests(unittest.TestCase):
self
.
assertTrue
(
target
[
key
]
is
value
)
self
.
assertTrue
(
target
[
key
]
is
value
)
def
_makeTarget
(
oid
=
'OID'
):
def
_makeTarget
(
oid
=
b
'OID'
):
from
persistent
import
Persistent
from
persistent
import
Persistent
from
persistent._compat
import
_b
class
Derived
(
Persistent
):
class
Derived
(
Persistent
):
def
__hash__
(
self
):
def
__hash__
(
self
):
return
hash
(
self
.
_p_oid
)
return
hash
(
self
.
_p_oid
)
...
@@ -328,7 +324,7 @@ def _makeTarget(oid='OID'):
...
@@ -328,7 +324,7 @@ def _makeTarget(oid='OID'):
def
__repr__
(
self
):
# pragma: no cover
def
__repr__
(
self
):
# pragma: no cover
return
'Derived: %s'
%
self
.
_p_oid
return
'Derived: %s'
%
self
.
_p_oid
derived
=
Derived
()
derived
=
Derived
()
derived
.
_p_oid
=
_b
(
oid
)
derived
.
_p_oid
=
oid
return
derived
return
derived
def
_makeJar
():
def
_makeJar
():
...
...
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