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
8e455700
Commit
8e455700
authored
Oct 30, 2014
by
Tres Seaver
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tolerate unicode attribute names.
Only in ASCII encoding. Fixes LP #143358.
parent
923965c7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
1 deletion
+28
-1
CHANGES.rst
CHANGES.rst
+2
-0
src/Acquisition/_Acquisition.c
src/Acquisition/_Acquisition.c
+21
-1
src/Acquisition/tests.py
src/Acquisition/tests.py
+5
-0
No files found.
CHANGES.rst
View file @
8e455700
...
...
@@ -4,6 +4,8 @@ Changelog
4.0.1 (unreleased)
------------------
- Tolerate Unicode attribute names (ASCII only). LP #143358.
- Make module-level ``aq_acquire`` API respect the ``default`` parameter.
LP #1387363.
...
...
src/Acquisition/_Acquisition.c
View file @
8e455700
...
...
@@ -474,10 +474,16 @@ Wrapper_findattr(Wrapper *self, PyObject *oname,
attribute.
*/
{
PyObject
*
r
,
*
v
,
*
tb
;
PyObject
*
r
,
*
v
,
*
tb
,
*
tmp
;
char
*
name
=
""
;
if
(
PyString_Check
(
oname
))
name
=
PyString_AS_STRING
(
oname
);
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
]
==
'q'
&&
name
[
2
]
==
'_'
)
||
(
strcmp
(
name
,
"__parent__"
)
==
0
))
{
...
...
@@ -726,10 +732,17 @@ Wrapper_getattro(Wrapper *self, PyObject *oname)
static
PyObject
*
Xaq_getattro
(
Wrapper
*
self
,
PyObject
*
oname
)
{
PyObject
*
tmp
;
char
*
name
=
""
;
/* Special case backward-compatible acquire method. */
if
(
PyString_Check
(
oname
))
name
=
PyString_AS_STRING
(
oname
);
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
)
return
Py_FindAttr
(
OBJECT
(
self
),
oname
);
...
...
@@ -743,10 +756,17 @@ Xaq_getattro(Wrapper *self, PyObject *oname)
static
int
Wrapper_setattro
(
Wrapper
*
self
,
PyObject
*
oname
,
PyObject
*
v
)
{
PyObject
*
tmp
;
char
*
name
=
""
;
/* Allow assignment to parent, to change context. */
if
(
PyString_Check
(
oname
))
name
=
PyString_AS_STRING
(
oname
);
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
))
{
...
...
src/Acquisition/tests.py
View file @
8e455700
...
...
@@ -2540,6 +2540,11 @@ class TestAcquire(unittest.TestCase):
def
test_unwrapped_falls_back_to_default
(
self
):
self
.
assertEqual
(
self
.
acquire
(
object
(),
'nonesuch'
,
default
=
4
),
4
)
def
test_w_unicode_attr_name
(
self
):
# See https://bugs.launchpad.net/acquisition/+bug/143358
found
=
self
.
acquire
(
self
.
a
.
b
.
c
,
u'aq_parent'
)
self
.
assertTrue
(
found
.
aq_self
is
self
.
a
.
b
.
aq_self
)
class
TestUnicode
(
unittest
.
TestCase
):
...
...
Kirill Smelkov
@kirr
mentioned in commit
0f791eac
·
Sep 19, 2016
mentioned in commit
0f791eac
mentioned in commit 0f791eac7251766b803821d9364d1be629ca2d61
Toggle commit list
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