Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
BTrees
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
BTrees
Commits
e23bd221
Commit
e23bd221
authored
Jan 13, 2016
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanups
parent
0718a45e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
16 deletions
+13
-16
BTrees/_base.py
BTrees/_base.py
+2
-3
BTrees/tests/common.py
BTrees/tests/common.py
+10
-12
CHANGES.rst
CHANGES.rst
+1
-1
No files found.
BTrees/_base.py
View file @
e23bd221
...
@@ -45,7 +45,7 @@ class _Base(Persistent):
...
@@ -45,7 +45,7 @@ class _Base(Persistent):
# If they're NOT around, we don't need to do any of the
# If they're NOT around, we don't need to do any of the
# special pickle support to make Python versions look like
# special pickle support to make Python versions look like
# C---we just rename the classes. By not defining these methods,
# C---we just rename the classes. By not defining these methods,
# we can (theoretically)
regain a bit of speed
.
# we can (theoretically)
avoid a bit of a slowdown
.
# If the C extensions are around, we do need these methods, but
# If the C extensions are around, we do need these methods, but
# these classes are unlikely to be used in production anyway.
# these classes are unlikely to be used in production anyway.
__import__
(
'BTrees._OOBTree'
)
__import__
(
'BTrees._OOBTree'
)
...
@@ -54,7 +54,6 @@ class _Base(Persistent):
...
@@ -54,7 +54,6 @@ class _Base(Persistent):
else
:
else
:
def
__reduce__
(
self
):
def
__reduce__
(
self
):
# Swap out the type constructor for the C version, if present.
# Swap out the type constructor for the C version, if present.
type_self
=
type
(
self
)
func
,
typ_gna
,
state
=
Persistent
.
__reduce__
(
self
)
func
,
typ_gna
,
state
=
Persistent
.
__reduce__
(
self
)
# We ignore the returned type altogether in favor of
# We ignore the returned type altogether in favor of
# our calculated class (which allows subclasses but replaces our exact
# our calculated class (which allows subclasses but replaces our exact
...
@@ -1571,7 +1570,7 @@ def _fix_pickle(mod_dict, mod_name):
...
@@ -1571,7 +1570,7 @@ def _fix_pickle(mod_dict, mod_name):
except
KeyError
:
except
KeyError
:
if
name
==
'TreeIterator'
:
if
name
==
'TreeIterator'
:
# Optional
# Optional
break
continue
raise
raise
raw_type
=
mod_dict
[
raw_name
]
# Could be C or Python
raw_type
=
mod_dict
[
raw_name
]
# Could be C or Python
...
...
BTrees/tests/common.py
View file @
e23bd221
...
@@ -263,9 +263,12 @@ class Base(object):
...
@@ -263,9 +263,12 @@ class Base(object):
# Issue #2: Make sure our class swizzling doesn't break
# Issue #2: Make sure our class swizzling doesn't break
# pickling subclasses
# pickling subclasses
global
PickleSubclass
# XXX: Has to be global to pickle, but this prevents running tests in parallel
# We need a globally named subclass for pickle, but it needs
class
PickleSubclass
(
type
(
self
.
_makeOne
())):
# to be unique in case tests run in parallel
pass
base_class
=
type
(
self
.
_makeOne
())
class_name
=
'PickleSubclassOf'
+
base_class
.
__name__
PickleSubclass
=
type
(
class_name
,
(
base_class
,),
{})
globals
()[
class_name
]
=
PickleSubclass
import
pickle
import
pickle
loaded
=
pickle
.
loads
(
pickle
.
dumps
(
PickleSubclass
()))
loaded
=
pickle
.
loads
(
pickle
.
dumps
(
PickleSubclass
()))
...
@@ -879,17 +882,12 @@ class BTreeTests(MappingBase):
...
@@ -879,17 +882,12 @@ class BTreeTests(MappingBase):
def
_getTargetClass
(
self
):
def
_getTargetClass
(
self
):
# Most of the subclasses override _makeOne and not
# Most of the subclasses override _makeOne and not
# _getTargetClass, so we can get the type that way.
# _getTargetClass, so we can get the type that way.
# TODO: This could change for less repetition in the subclasses,
# using the name of the class to import the module and find
# the type.
if
type
(
self
).
_makeOne
is
not
BTreeTests
.
_makeOne
:
if
type
(
self
).
_makeOne
is
not
BTreeTests
.
_makeOne
:
return
type
(
self
.
_makeOne
())
return
type
(
self
.
_makeOne
())
raise
NotImplementedError
()
# Derive the class from the test case name, if not
# overridden
name
=
self
.
__class__
.
__name__
type_name
=
name
[:
-
4
]
mod_name
=
'BTrees.%s'
%
(
type_name
if
not
type_name
.
endswith
(
"Py"
)
else
type_name
[:
-
2
])
mod
=
__import__
(
mod_name
,
fromlist
=
[
'ignored'
])
return
getattr
(
mod
,
type_name
)
def
_makeOne
(
self
,
*
args
):
def
_makeOne
(
self
,
*
args
):
return
self
.
_getTargetClass
()(
*
args
)
return
self
.
_getTargetClass
()(
*
args
)
...
...
CHANGES.rst
View file @
e23bd221
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
https://github.com/zopefoundation/BTrees/issues/19
https://github.com/zopefoundation/BTrees/issues/19
- Unpickling empty BTrees in a pure-Python environment no longer
- Unpickling empty BTrees in a pure-Python environment no longer
creates invalid objects that fail
e
with ``AttributeError``.
creates invalid objects that fail with ``AttributeError``.
4.2.0 (2015-11-13)
4.2.0 (2015-11-13)
------------------
------------------
...
...
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