Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Acquisition
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
Acquisition
Commits
75c852e0
Commit
75c852e0
authored
Apr 23, 2015
by
Tres Seaver
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'NextThought-unicode-crash2'
parents
52043b7d
51c29c73
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
20 deletions
+70
-20
CHANGES.rst
CHANGES.rst
+3
-1
src/Acquisition/_Acquisition.c
src/Acquisition/_Acquisition.c
+67
-19
No files found.
CHANGES.rst
View file @
75c852e0
...
...
@@ -4,7 +4,9 @@ Changelog
4.2.1 (unreleased)
------------------
- TBD
- Correct several dangling pointer uses in the C extension,
potentially fixing a few interpreter crashes. See
https://github.com/zopefoundation/Acquisition/issues/5.
4.2 (2015-04-04)
----------------
...
...
src/Acquisition/_Acquisition.c
View file @
75c852e0
...
...
@@ -452,6 +452,11 @@ Wrapper_acquire(Wrapper *self, PyObject *oname,
PyObject
*
filter
,
PyObject
*
extra
,
PyObject
*
orig
,
int
explicit
,
int
containment
);
static
PyObject
*
Wrapper_findattr_name
(
Wrapper
*
self
,
char
*
name
,
PyObject
*
oname
,
PyObject
*
filter
,
PyObject
*
extra
,
PyObject
*
orig
,
int
sob
,
int
sco
,
int
explicit
,
int
containment
);
static
PyObject
*
Wrapper_findattr
(
Wrapper
*
self
,
PyObject
*
oname
,
PyObject
*
filter
,
PyObject
*
extra
,
PyObject
*
orig
,
...
...
@@ -474,16 +479,48 @@ Wrapper_findattr(Wrapper *self, PyObject *oname,
attribute.
*/
{
PyObject
*
r
,
*
v
,
*
tb
,
*
tmp
;
PyObject
*
tmp
=
NULL
;
PyObject
*
result
;
char
*
name
=
""
;
if
(
PyString_Check
(
oname
))
name
=
PyString_AS_STRING
(
oname
);
if
(
PyUnicode_Check
(
oname
))
{
else
if
(
PyUnicode_Check
(
oname
))
{
tmp
=
PyUnicode_AsASCIIString
(
oname
);
if
(
tmp
==
NULL
)
return
NULL
;
name
=
PyString_AS_STRING
(
tmp
);
Py_DECREF
(
tmp
);
}
result
=
Wrapper_findattr_name
(
self
,
name
,
oname
,
filter
,
extra
,
orig
,
sob
,
sco
,
explicit
,
containment
);
Py_XDECREF
(
tmp
);
return
result
;
}
static
PyObject
*
Wrapper_findattr_name
(
Wrapper
*
self
,
char
*
name
,
PyObject
*
oname
,
PyObject
*
filter
,
PyObject
*
extra
,
PyObject
*
orig
,
int
sob
,
int
sco
,
int
explicit
,
int
containment
)
/*
Exactly the same as Wrapper_findattr, except that the incoming
Python name string/unicode object has already been decoded
into a C string. This helper function lets us more easily manage
the lifetime of any temporary allocations.
This function uses Wrapper_acquire, which only takes the original
oname value, not the decoded value. That function can call back into
this one (via Wrapper_findattr). Although that may lead to a few
temporary allocations as we walk through the containment hierarchy,
it is correct: This function may modify its internal view of the
`name` value, and if that were propagated up the hierarchy
the incorrect name may be looked up.
*/
{
PyObject
*
r
,
*
v
,
*
tb
;
if
((
*
name
==
'a'
&&
name
[
1
]
==
'q'
&&
name
[
2
]
==
'_'
)
||
(
strcmp
(
name
,
"__parent__"
)
==
0
))
{
...
...
@@ -732,62 +769,73 @@ Wrapper_getattro(Wrapper *self, PyObject *oname)
static
PyObject
*
Xaq_getattro
(
Wrapper
*
self
,
PyObject
*
oname
)
{
PyObject
*
tmp
;
PyObject
*
tmp
=
NULL
;
PyObject
*
result
;
char
*
name
=
""
;
/* Special case backward-compatible acquire method. */
if
(
PyString_Check
(
oname
))
name
=
PyString_AS_STRING
(
oname
);
if
(
PyUnicode_Check
(
oname
))
{
else
if
(
PyUnicode_Check
(
oname
))
{
tmp
=
PyUnicode_AsASCIIString
(
oname
);
if
(
tmp
==
NULL
)
return
NULL
;
name
=
PyString_AS_STRING
(
tmp
);
Py_DECREF
(
tmp
);
}
if
(
*
name
==
'a'
&&
name
[
1
]
==
'c'
&&
strcmp
(
name
+
2
,
"quire"
)
==
0
)
re
turn
Py_FindAttr
(
OBJECT
(
self
),
oname
);
re
sult
=
Py_FindAttr
(
OBJECT
(
self
),
oname
);
if
(
self
->
obj
||
self
->
container
)
re
turn
Wrapper_findattr
(
self
,
oname
,
NULL
,
NULL
,
NULL
,
1
,
0
,
0
,
0
);
else
if
(
self
->
obj
||
self
->
container
)
re
sult
=
Wrapper_findattr
(
self
,
oname
,
NULL
,
NULL
,
NULL
,
1
,
0
,
0
,
0
);
/* Maybe we are getting initialized? */
return
Py_FindAttr
(
OBJECT
(
self
),
oname
);
else
result
=
Py_FindAttr
(
OBJECT
(
self
),
oname
);
Py_XDECREF
(
tmp
);
return
result
;
}
static
int
Wrapper_setattro
(
Wrapper
*
self
,
PyObject
*
oname
,
PyObject
*
v
)
{
PyObject
*
tmp
;
PyObject
*
tmp
=
NULL
;
char
*
name
=
""
;
int
result
;
/* Allow assignment to parent, to change context. */
if
(
PyString_Check
(
oname
))
name
=
PyString_AS_STRING
(
oname
);
if
(
PyUnicode_Check
(
oname
))
{
else
if
(
PyUnicode_Check
(
oname
))
{
tmp
=
PyUnicode_AsASCIIString
(
oname
);
if
(
tmp
==
NULL
)
return
-
1
;
name
=
PyString_AS_STRING
(
tmp
);
Py_DECREF
(
tmp
);
}
if
((
*
name
==
'a'
&&
name
[
1
]
==
'q'
&&
name
[
2
]
==
'_'
&&
strcmp
(
name
+
3
,
"parent"
)
==
0
)
||
(
strcmp
(
name
,
"__parent__"
)
==
0
))
{
Py_XINCREF
(
v
);
ASSIGN
(
self
->
container
,
v
);
re
turn
0
;
re
sult
=
0
;
}
if
(
self
->
obj
)
else
if
(
self
->
obj
)
{
/* Unwrap passed in wrappers! */
while
(
v
&&
isWrapper
(
v
))
v
=
WRAPPER
(
v
)
->
obj
;
if
(
v
)
re
turn
PyObject_SetAttr
(
self
->
obj
,
oname
,
v
);
else
re
turn
PyObject_DelAttr
(
self
->
obj
,
oname
);
if
(
v
)
re
sult
=
PyObject_SetAttr
(
self
->
obj
,
oname
,
v
);
else
re
sult
=
PyObject_DelAttr
(
self
->
obj
,
oname
);
}
else
{
PyErr_SetString
(
PyExc_AttributeError
,
"Attempt to set attribute on empty acquisition wrapper"
);
return
-
1
;
result
=
-
1
;
}
Py_XDECREF
(
tmp
);
return
result
;
}
static
int
...
...
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