Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
zope-container
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-container
Commits
1e58ec7f
Commit
1e58ec7f
authored
Oct 24, 2012
by
Marius Gedminas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a bug that made it impossible to store None values in containers
(LP#1070719).
parent
7a2af522
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
2 deletions
+28
-2
CHANGES.txt
CHANGES.txt
+3
-0
src/zope/container/contained.py
src/zope/container/contained.py
+4
-2
src/zope/container/tests/test_ordered.py
src/zope/container/tests/test_ordered.py
+21
-0
No files found.
CHANGES.txt
View file @
1e58ec7f
...
...
@@ -21,6 +21,9 @@ CHANGES
- Handle Broken Objects more gracefully
- Fix a bug that made it impossible to store None values in containers
(LP#1070719).
3.12.0 (2010-12-14)
-------------------
...
...
src/zope/container/contained.py
View file @
1e58ec7f
...
...
@@ -331,6 +331,8 @@ def notifyContainerModified(object, *descriptions):
"""Notify that the container was modified."""
notify
(
ContainerModifiedEvent
(
object
,
*
descriptions
))
_SENTINEL
=
object
()
def
setitem
(
container
,
setitemf
,
name
,
object
):
"""Helper function to set an item and generate needed events
...
...
@@ -547,10 +549,10 @@ def setitem(container, setitemf, name, object):
if
not
name
:
raise
ValueError
(
"empty names are not allowed"
)
old
=
container
.
get
(
name
)
old
=
container
.
get
(
name
,
_SENTINEL
)
if
old
is
object
:
return
if
old
is
not
None
:
if
old
is
not
_SENTINEL
:
raise
KeyError
(
name
)
object
,
event
=
containedEvent
(
object
,
container
,
name
)
...
...
src/zope/container/tests/test_ordered.py
View file @
1e58ec7f
...
...
@@ -122,6 +122,27 @@ def test_exception_causes_order_fix():
"""
def
test_adding_none
():
"""Test for OrderedContainer
This is a regression test: adding None to an OrderedContainer
used to corrupt its internal data structure (_order and _data
wouldl get out of sync, causing KeyErrors when you tried to iterate).
>>> from zope.container.ordered import OrderedContainer
>>> oc = OrderedContainer()
>>> oc['foo'] = None
>>> oc.keys()
['foo']
>>> oc.values()
[None]
>>> oc.items()
[('foo', None)]
>>> print oc['foo']
None
"""
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
DocTestSuite
(
"zope.container.ordered"
,
...
...
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