Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
ZODB
Commits
f6cbe478
Commit
f6cbe478
authored
Nov 03, 2016
by
Frances Wong
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into bugfix/typos
parents
130c9dbc
e0a0ec36
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
84 additions
and
168 deletions
+84
-168
README.rst
README.rst
+5
-0
src/ZODB/FileStorage/format.py
src/ZODB/FileStorage/format.py
+3
-4
src/ZODB/POSException.py
src/ZODB/POSException.py
+16
-35
src/ZODB/_compat.py
src/ZODB/_compat.py
+1
-1
src/ZODB/blob.py
src/ZODB/blob.py
+2
-1
src/ZODB/tests/IteratorStorage.py
src/ZODB/tests/IteratorStorage.py
+2
-5
src/ZODB/tests/testCache.py
src/ZODB/tests/testCache.py
+0
-1
src/ZODB/tests/testDB.py
src/ZODB/tests/testDB.py
+42
-43
src/ZODB/tests/testPersistentList.py
src/ZODB/tests/testPersistentList.py
+5
-5
src/ZODB/tests/testPersistentMapping.py
src/ZODB/tests/testPersistentMapping.py
+1
-38
src/ZODB/tests/util.py
src/ZODB/tests/util.py
+1
-5
src/ZODB/utils.py
src/ZODB/utils.py
+6
-30
No files found.
README.rst
View file @
f6cbe478
...
@@ -109,3 +109,8 @@ More information
...
@@ -109,3 +109,8 @@ More information
================
================
See http://zodb.org/
See http://zodb.org/
.. image:: https://badges.gitter.im/zopefoundation/ZODB.svg
:alt: Join the chat at https://gitter.im/zopefoundation/ZODB
:target: https://gitter.im/zopefoundation/ZODB?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
\ No newline at end of file
src/ZODB/FileStorage/format.py
View file @
f6cbe478
...
@@ -85,11 +85,10 @@
...
@@ -85,11 +85,10 @@
import
logging
import
logging
import
struct
import
struct
import
sys
from
ZODB.POSException
import
POSKeyError
from
ZODB.POSException
import
POSKeyError
from
ZODB.utils
import
u64
,
oid_repr
,
as_bytes
from
ZODB.utils
import
u64
,
oid_repr
,
as_bytes
from
ZODB._compat
import
PY3
class
CorruptedError
(
Exception
):
class
CorruptedError
(
Exception
):
pass
pass
...
@@ -262,7 +261,7 @@ class DataHeader(object):
...
@@ -262,7 +261,7 @@ class DataHeader(object):
def
TxnHeaderFromString
(
s
):
def
TxnHeaderFromString
(
s
):
res
=
TxnHeader
(
*
struct
.
unpack
(
TRANS_HDR
,
s
))
res
=
TxnHeader
(
*
struct
.
unpack
(
TRANS_HDR
,
s
))
if
sys
.
version_info
[
0
]
>=
3
:
if
PY
3
:
res
.
status
=
res
.
status
.
decode
(
'ascii'
)
res
.
status
=
res
.
status
.
decode
(
'ascii'
)
return
res
return
res
...
...
src/ZODB/POSException.py
View file @
f6cbe478
...
@@ -15,8 +15,6 @@
...
@@ -15,8 +15,6 @@
$Id$"""
$Id$"""
import
sys
from
ZODB.utils
import
oid_repr
,
readable_tid_repr
from
ZODB.utils
import
oid_repr
,
readable_tid_repr
# BBB: We moved the two transactions to the transaction package
# BBB: We moved the two transactions to the transaction package
...
@@ -37,26 +35,9 @@ _recon.__no_side_effects__ = True
...
@@ -37,26 +35,9 @@ _recon.__no_side_effects__ = True
class
POSError
(
Exception
):
class
POSError
(
Exception
):
"""Persistent object system error."""
"""Persistent object system error."""
if
sys
.
version_info
[:
2
]
==
(
2
,
6
):
# The 'message' attribute was deprecated for BaseException with
# Python 2.6; here we create descriptor properties to continue using it
def
__set_message
(
self
,
v
):
self
.
__dict__
[
'message'
]
=
v
def
__get_message
(
self
):
return
self
.
__dict__
[
'message'
]
def
__del_message
(
self
):
del
self
.
__dict__
[
'message'
]
message
=
property
(
__get_message
,
__set_message
,
__del_message
)
if
sys
.
version_info
[:
2
]
>=
(
2
,
5
):
def
__reduce__
(
self
):
def
__reduce__
(
self
):
# Copy extra data from internal structures
# Copy extra data from internal structures
state
=
self
.
__dict__
.
copy
()
state
=
self
.
__dict__
.
copy
()
if
sys
.
version_info
[:
2
]
==
(
2
,
5
):
state
[
'message'
]
=
self
.
message
state
[
'args'
]
=
self
.
args
state
[
'args'
]
=
self
.
args
return
(
_recon
,
(
self
.
__class__
,
state
))
return
(
_recon
,
(
self
.
__class__
,
state
))
...
...
src/ZODB/_compat.py
View file @
f6cbe478
...
@@ -82,7 +82,7 @@ def PersistentPickler(persistent_id, *args, **kwargs):
...
@@ -82,7 +82,7 @@ def PersistentPickler(persistent_id, *args, **kwargs):
This covers the differences between Python 2 and 3 and PyPy/zodbpickle.
This covers the differences between Python 2 and 3 and PyPy/zodbpickle.
"""
"""
p
=
Pickler
(
*
args
,
**
kwargs
)
p
=
Pickler
(
*
args
,
**
kwargs
)
if
sys
.
version_info
[
0
]
<
3
:
if
not
PY
3
:
p
.
inst_persistent_id
=
persistent_id
p
.
inst_persistent_id
=
persistent_id
# PyPy uses a python implementation of cPickle/zodbpickle in both Python 2
# PyPy uses a python implementation of cPickle/zodbpickle in both Python 2
...
...
src/ZODB/blob.py
View file @
f6cbe478
...
@@ -36,9 +36,10 @@ from ZODB._compat import PersistentUnpickler
...
@@ -36,9 +36,10 @@ from ZODB._compat import PersistentUnpickler
from
ZODB._compat
import
decodebytes
from
ZODB._compat
import
decodebytes
from
ZODB._compat
import
ascii_bytes
from
ZODB._compat
import
ascii_bytes
from
ZODB._compat
import
INT_TYPES
from
ZODB._compat
import
INT_TYPES
from
ZODB._compat
import
PY3
if
sys
.
version_info
[
0
]
>=
3
:
if
PY
3
:
from
io
import
FileIO
as
file
from
io
import
FileIO
as
file
...
...
src/ZODB/tests/IteratorStorage.py
View file @
f6cbe478
...
@@ -24,7 +24,6 @@ from ZODB.utils import U64, p64, load_current
...
@@ -24,7 +24,6 @@ from ZODB.utils import U64, p64, load_current
from
transaction
import
Transaction
from
transaction
import
Transaction
import
sys
import
ZODB.blob
import
ZODB.blob
try
:
try
:
...
@@ -159,10 +158,8 @@ class IteratorStorage(IteratorCompare):
...
@@ -159,10 +158,8 @@ class IteratorStorage(IteratorCompare):
# We store another transaction with 1 object, the already running
# We store another transaction with 1 object, the already running
# iterator does not pick this up.
# iterator does not pick this up.
self
.
_dostore
()
self
.
_dostore
()
if
sys
.
version_info
[
0
]
<
3
:
with
self
.
assertRaises
(
StopIteration
):
self
.
assertRaises
(
StopIteration
,
iterator
.
next
)
next
(
iterator
)
else
:
self
.
assertRaises
(
StopIteration
,
iterator
.
__next__
)
class
ExtendedIteratorStorage
(
IteratorCompare
):
class
ExtendedIteratorStorage
(
IteratorCompare
):
...
...
src/ZODB/tests/testCache.py
View file @
f6cbe478
...
@@ -33,7 +33,6 @@ import ZODB
...
@@ -33,7 +33,6 @@ import ZODB
import
ZODB.MappingStorage
import
ZODB.MappingStorage
import
ZODB.tests.util
import
ZODB.tests.util
PY2
=
sys
.
version_info
[
0
]
==
2
class
CacheTestBase
(
ZODB
.
tests
.
util
.
TestCase
):
class
CacheTestBase
(
ZODB
.
tests
.
util
.
TestCase
):
...
...
src/ZODB/tests/testDB.py
View file @
f6cbe478
...
@@ -227,8 +227,7 @@ def open_convenience():
...
@@ -227,8 +227,7 @@ def open_convenience():
"""
"""
if
sys
.
version_info
>=
(
2
,
6
):
def
db_with_transaction
():
def
db_with_transaction
():
"""Using databases with with
"""Using databases with with
The transaction method returns a context manager that when entered
The transaction method returns a context manager that when entered
...
@@ -248,7 +247,7 @@ if sys.version_info >= (2, 6):
...
@@ -248,7 +247,7 @@ if sys.version_info >= (2, 6):
>>> conn2.opened
>>> conn2.opened
Now, we'll open a 3rd connection a verify that
Now, we'll open a 3rd connection a verify that
>>> conn3 = db.open()
>>> conn3 = db.open()
>>> conn3.root()['x']
>>> conn3.root()['x']
...
@@ -257,7 +256,7 @@ if sys.version_info >= (2, 6):
...
@@ -257,7 +256,7 @@ if sys.version_info >= (2, 6):
1
1
>>> conn3.close()
>>> conn3.close()
Let's try again, but this time, we'll have an exception:
Let's try again, but this time, we'll have an exception:
>>> with db.transaction() as conn2:
>>> with db.transaction() as conn2:
... conn2.root()['y'] = 2
... conn2.root()['y'] = 2
...
...
src/ZODB/tests/testPersistentList.py
View file @
f6cbe478
...
@@ -13,11 +13,11 @@
...
@@ -13,11 +13,11 @@
##############################################################################
##############################################################################
"""Test the list interface to PersistentList
"""Test the list interface to PersistentList
"""
"""
import
sys
import
unittest
import
unittest
from
persistent.list
import
PersistentList
from
persistent.list
import
PersistentList
PY2
=
sys
.
version_info
[
0
]
==
2
from
six
import
PY
2
l0
=
[]
l0
=
[]
l1
=
[
0
]
l1
=
[
0
]
...
@@ -84,7 +84,7 @@ class TestPList(unittest.TestCase):
...
@@ -84,7 +84,7 @@ class TestPList(unittest.TestCase):
except
IndexError
:
except
IndexError
:
pass
pass
else
:
else
:
raise
TestFailed
(
"uu2[2] shouldn't be assignable"
)
self
.
fail
(
"uu2[2] shouldn't be assignable"
)
# Test __delitem__
# Test __delitem__
...
@@ -95,7 +95,7 @@ class TestPList(unittest.TestCase):
...
@@ -95,7 +95,7 @@ class TestPList(unittest.TestCase):
except
IndexError
:
except
IndexError
:
pass
pass
else
:
else
:
raise
TestFailed
(
"uu2[0] shouldn't be deletable"
)
self
.
fail
(
"uu2[0] shouldn't be deletable"
)
# Test __getslice__
# Test __getslice__
...
@@ -191,7 +191,7 @@ class TestPList(unittest.TestCase):
...
@@ -191,7 +191,7 @@ class TestPList(unittest.TestCase):
except
ValueError
:
except
ValueError
:
pass
pass
else
:
else
:
raise
TestFailed
(
"expected ValueError"
)
self
.
fail
(
"expected ValueError"
)
# Test reverse
# Test reverse
...
...
src/ZODB/tests/testPersistentMapping.py
View file @
f6cbe478
...
@@ -23,20 +23,12 @@ old code, developers will have a hard time testing the new code.
...
@@ -23,20 +23,12 @@ old code, developers will have a hard time testing the new code.
import
unittest
import
unittest
import
sys
import
sys
import
transaction
from
transaction
import
Transaction
from
transaction
import
Transaction
import
ZODB
import
ZODB
from
ZODB.MappingStorage
import
MappingStorage
from
ZODB.MappingStorage
import
MappingStorage
from
ZODB._compat
import
Unpickler
try
:
from
six
import
PY2
import
cStringIO
except
ImportError
:
# Py3
import
io
as
cStringIO
PY2
=
sys
.
version_info
[
0
]
==
2
# This pickle contains a persistent mapping pickle created from the
# This pickle contains a persistent mapping pickle created from the
# old code.
# old code.
...
@@ -68,35 +60,6 @@ class PMTests(unittest.TestCase):
...
@@ -68,35 +60,6 @@ class PMTests(unittest.TestCase):
self
.
assertTrue
(
hasattr
(
r
,
'data'
))
self
.
assertTrue
(
hasattr
(
r
,
'data'
))
self
.
assertTrue
(
not
hasattr
(
r
,
'_container'
))
self
.
assertTrue
(
not
hasattr
(
r
,
'_container'
))
# TODO: This test fails in ZODB 3.3a1. It's making some assumption(s)
# about pickles that aren't true. Hard to say when it stopped working,
# because this entire test suite hasn't been run for a long time, due to
# a mysterious "return None" at the start of the test_suite() function
# below. I noticed that when the new checkBackwardCompat() test wasn't
# getting run.
def
TODO_checkNewPicklesAreSafe
(
self
):
s
=
MappingStorage
()
db
=
ZODB
.
DB
(
s
)
r
=
db
.
open
().
root
()
r
[
1
]
=
1
r
[
2
]
=
2
r
[
3
]
=
r
transaction
.
commit
()
# MappingStorage stores serialno + pickle in its _index.
root_pickle
=
s
.
_index
[
'
\
000
'
*
8
][
8
:]
# XXX not BytesIO really?
f
=
cStringIO
.
StringIO
(
root_pickle
)
u
=
Unpickler
(
f
)
klass_info
=
u
.
load
()
klass
=
find_global
(
*
klass_info
[
0
])
inst
=
klass
.
__new__
(
klass
)
state
=
u
.
load
()
inst
.
__setstate__
(
state
)
self
.
assertTrue
(
hasattr
(
inst
,
'_container'
))
self
.
assertTrue
(
not
hasattr
(
inst
,
'data'
))
def
checkBackwardCompat
(
self
):
def
checkBackwardCompat
(
self
):
# Verify that the sanest of the ZODB 3.2 dotted paths still works.
# Verify that the sanest of the ZODB 3.2 dotted paths still works.
from
persistent.mapping
import
PersistentMapping
as
newPath
from
persistent.mapping
import
PersistentMapping
as
newPath
...
...
src/ZODB/tests/util.py
View file @
f6cbe478
...
@@ -19,7 +19,6 @@ import atexit
...
@@ -19,7 +19,6 @@ import atexit
import
os
import
os
import
persistent
import
persistent
import
re
import
re
import
sys
import
tempfile
import
tempfile
import
time
import
time
import
transaction
import
transaction
...
@@ -136,9 +135,6 @@ class AAAA_Test_Runner_Hack(unittest.TestCase):
...
@@ -136,9 +135,6 @@ class AAAA_Test_Runner_Hack(unittest.TestCase):
pass
pass
def
assert_warning
(
category
,
func
,
warning_text
=
''
):
def
assert_warning
(
category
,
func
,
warning_text
=
''
):
if
sys
.
version_info
<
(
2
,
6
):
return
func
()
# Can't use catch_warnings :(
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
'default'
)
warnings
.
simplefilter
(
'default'
)
result
=
func
()
result
=
func
()
...
@@ -154,7 +150,7 @@ def assert_deprecated(func, warning_text=''):
...
@@ -154,7 +150,7 @@ def assert_deprecated(func, warning_text=''):
def
wait
(
func
=
None
,
timeout
=
30
):
def
wait
(
func
=
None
,
timeout
=
30
):
if
func
is
None
:
if
func
is
None
:
return
lambda
f
:
wait
(
f
,
timeout
)
return
lambda
f
:
wait
(
f
,
timeout
)
for
i
in
range
(
int
(
timeout
*
100
)):
for
_
in
range
(
int
(
timeout
*
100
)):
if
func
():
if
func
():
return
return
time
.
sleep
(.
01
)
time
.
sleep
(.
01
)
...
...
src/ZODB/utils.py
View file @
f6cbe478
...
@@ -17,7 +17,6 @@ import struct
...
@@ -17,7 +17,6 @@ import struct
import
sys
import
sys
import
time
import
time
import
threading
import
threading
import
warnings
from
binascii
import
hexlify
,
unhexlify
from
binascii
import
hexlify
,
unhexlify
from
struct
import
pack
,
unpack
from
struct
import
pack
,
unpack
from
tempfile
import
mkstemp
from
tempfile
import
mkstemp
...
@@ -28,6 +27,8 @@ from ZODB._compat import Unpickler
...
@@ -28,6 +27,8 @@ from ZODB._compat import Unpickler
from
ZODB._compat
import
BytesIO
from
ZODB._compat
import
BytesIO
from
ZODB._compat
import
ascii_bytes
from
ZODB._compat
import
ascii_bytes
from
six
import
PY2
__all__
=
[
'z64'
,
__all__
=
[
'z64'
,
'p64'
,
'p64'
,
'u64'
,
'u64'
,
...
@@ -40,38 +41,12 @@ __all__ = ['z64',
...
@@ -40,38 +41,12 @@ __all__ = ['z64',
'tid_repr'
,
'tid_repr'
,
'positive_id'
,
'positive_id'
,
'readable_tid_repr'
,
'readable_tid_repr'
,
'DEPRECATED_ARGUMENT'
,
'deprecated37'
,
'deprecated38'
,
'get_pickle_metadata'
,
'get_pickle_metadata'
,
'locked'
,
'locked'
,
]
]
# A unique marker to give as the default value for a deprecated argument.
# The method should then do a
#
# if that_arg is not DEPRECATED_ARGUMENT:
# complain
#
# dance.
DEPRECATED_ARGUMENT
=
object
()
# Raise DeprecationWarning, noting that the deprecated thing will go
# away in ZODB 3.7. Point to the caller of our caller (i.e., at the
# code using the deprecated thing).
def
deprecated37
(
msg
):
warnings
.
warn
(
"This will be removed in ZODB 3.7:
\
n
%s"
%
msg
,
DeprecationWarning
,
stacklevel
=
3
)
# Raise DeprecationWarning, noting that the deprecated thing will go
# away in ZODB 3.8. Point to the caller of our caller (i.e., at the
# code using the deprecated thing).
def
deprecated38
(
msg
):
warnings
.
warn
(
"This will be removed in ZODB 3.8:
\
n
%s"
%
msg
,
DeprecationWarning
,
stacklevel
=
3
)
if
sys
.
version_info
[
0
]
<
3
:
if
PY2
:
def
as_bytes
(
obj
):
def
as_bytes
(
obj
):
"Convert obj into bytes"
"Convert obj into bytes"
return
str
(
obj
)
return
str
(
obj
)
...
@@ -185,7 +160,7 @@ tid_repr = serial_repr
...
@@ -185,7 +160,7 @@ tid_repr = serial_repr
# for 8-byte string tid b'\x03D\x14"\x94\x8bC\x99'.
# for 8-byte string tid b'\x03D\x14"\x94\x8bC\x99'.
def
readable_tid_repr
(
tid
):
def
readable_tid_repr
(
tid
):
result
=
tid_repr
(
tid
)
result
=
tid_repr
(
tid
)
if
isinstance
(
tid
,
str
)
and
len
(
tid
)
==
8
:
if
isinstance
(
tid
,
bytes
)
and
len
(
tid
)
==
8
:
result
=
"%s %s"
%
(
result
,
TimeStamp
(
tid
))
result
=
"%s %s"
%
(
result
,
TimeStamp
(
tid
))
return
result
return
result
...
@@ -316,7 +291,8 @@ class locked(object):
...
@@ -316,7 +291,8 @@ class locked(object):
return
Locked
(
func
,
preconditions
=
self
.
preconditions
)
return
Locked
(
func
,
preconditions
=
self
.
preconditions
)
if
os
.
environ
.
get
(
'DEBUG_LOCKING'
):
if
os
.
environ
.
get
(
'DEBUG_LOCKING'
):
# pragma: no cover
# NOTE: This only works on Python 3.
class
Lock
:
class
Lock
:
lock_class
=
threading
.
Lock
lock_class
=
threading
.
Lock
...
...
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