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
73ccff24
Commit
73ccff24
authored
Nov 16, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Plain Diff
Merge the 'jim-fix-estimates-size' branch.
parents
2163c434
dcfeeb41
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
35 deletions
+38
-35
CHANGES.txt
CHANGES.txt
+9
-1
persistent/cPersistence.c
persistent/cPersistence.c
+3
-23
persistent/persistence.py
persistent/persistence.py
+11
-5
persistent/tests/test_persistence.py
persistent/tests/test_persistence.py
+15
-6
No files found.
CHANGES.txt
View file @
73ccff24
...
...
@@ -4,7 +4,15 @@
4.0.3 (unreleased)
------------------
- TBD
- Fixed: In the C implimentation, an integer was compared with a
pointer, with undefined results and a compiler warning.
- Fixed: the Python implementation of the _p_estimated_size propety
didn't support deletion.
- Simplified implementation of the _p_estimated_size property to
only accept integers. A TypeError is raised if an incorrect type is
provided.
4.0.2 (2012-08-27)
...
...
persistent/cPersistence.c
View file @
73ccff24
...
...
@@ -24,7 +24,7 @@ struct ccobject_head_struct {
};
/* These two objects are initialized when the module is loaded */
static
PyObject
*
TimeStamp
,
*
py_simple_new
,
*
sys_maxint
;
static
PyObject
*
TimeStamp
,
*
py_simple_new
;
/* Strings initialized by init_strings() below. */
static
PyObject
*
py_keys
,
*
py_setstate
,
*
py___dict__
,
*
py_timeTime
;
...
...
@@ -1118,14 +1118,6 @@ Per_set_estimated_size(cPersistentObject *self, PyObject *v)
{
if
(
v
)
{
if
(
PyLong_Check
(
v
))
{
long
long
llv
=
PyLong_AsLongLong
(
v
);
if
(
llv
>
sys_maxint
)
{
v
=
sys_maxint
;
/* borrow reference */
}
}
if
(
PyInt_Check
(
v
))
{
long
lv
=
PyInt_AS_LONG
(
v
);
...
...
@@ -1139,7 +1131,7 @@ Per_set_estimated_size(cPersistentObject *self, PyObject *v)
}
else
{
PyErr_SetString
(
PyExc_
Valu
eError
,
PyErr_SetString
(
PyExc_
Typ
eError
,
"_p_estimated_size must be an integer"
);
return
-
1
;
}
...
...
@@ -1430,18 +1422,6 @@ initcPersistence(void)
return
;
TimeStamp
=
PyObject_GetAttrString
(
m
,
"TimeStamp"
);
Py_DECREF
(
m
);
if
(
!
TimeStamp
)
return
;
}
if
(
!
sys_maxint
)
{
m
=
PyImport_ImportModule
(
"sys"
);
if
(
!
m
)
return
;
sys_maxint
=
PyObject_GetAttrString
(
m
,
"maxint"
);
Py_DECREF
(
m
);
if
(
!
sys_maxint
)
return
;
/* fall through to immediate return on error */
}
}
persistent/persistence.py
View file @
73ccff24
...
...
@@ -166,12 +166,18 @@ class Persistent(object):
return
self
.
__size
*
64
def
_set_estimated_size
(
self
,
value
):
value
=
int
(
value
)
if
value
<
0
:
raise
ValueError
(
'_p_estimated_size must not be negative'
)
self
.
__size
=
_estimated_size_in_24_bits
(
value
)
if
isinstance
(
value
,
int
):
if
value
<
0
:
raise
ValueError
(
'_p_estimated_size must not be negative'
)
self
.
__size
=
_estimated_size_in_24_bits
(
value
)
else
:
raise
TypeError
(
"_p_estimated_size must be an integer"
)
def
_del_estimated_size
(
self
):
self
.
__size
=
0
_p_estimated_size
=
property
(
_get_estimated_size
,
_set_estimated_size
)
_p_estimated_size
=
property
(
_get_estimated_size
,
_set_estimated_size
,
_del_estimated_size
)
# The '_p_sticky' property is not (yet) part of the API: for now,
# it exists to simplify debugging and testing assertions.
...
...
persistent/tests/test_persistence.py
View file @
73ccff24
...
...
@@ -486,6 +486,20 @@ class _Persistent_Base(object):
inst
=
self
.
_makeOne
()
self
.
assertEqual
(
inst
.
_p_estimated_size
,
0
)
def
test_query_p_estimated_size_del
(
self
):
inst
=
self
.
_makeOne
()
inst
.
_p_estimated_size
=
123
self
.
assertEqual
(
inst
.
_p_estimated_size
,
128
)
del
inst
.
_p_estimated_size
self
.
assertEqual
(
inst
.
_p_estimated_size
,
0
)
def
test_assign_p_estimated_size_wrong_type
(
self
):
inst
=
self
.
_makeOne
()
self
.
assertRaises
(
TypeError
,
lambda
:
setattr
(
inst
,
'_p_estimated_size'
,
None
))
self
.
assertRaises
(
TypeError
,
lambda
:
setattr
(
inst
,
'_p_estimated_size'
,
1L
))
def
test_assign_p_estimated_size_negative
(
self
):
inst
=
self
.
_makeOne
()
def
_test
():
...
...
@@ -504,12 +518,7 @@ class _Persistent_Base(object):
def
test_assign_p_estimated_size_bigger
(
self
):
inst
=
self
.
_makeOne
()
inst
.
_p_estimated_size
=
1073741697
*
4
#still <= 32 bits
self
.
assertEqual
(
inst
.
_p_estimated_size
,
16777215
*
64
)
def
test_assign_p_estimated_size_bigger_than_sys_maxint
(
self
):
inst
=
self
.
_makeOne
()
inst
.
_p_estimated_size
=
2
**
63
-
1
#largest 'long long' in C
inst
.
_p_estimated_size
=
1073741697
*
2
self
.
assertEqual
(
inst
.
_p_estimated_size
,
16777215
*
64
)
def
test___getattribute___p__names
(
self
):
...
...
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