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
ab9cfb5c
Commit
ab9cfb5c
authored
Dec 14, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get bucket's __repr__ working in C extension under Py3k.
parent
d0d0401f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
2 deletions
+25
-2
BTrees/BucketTemplate.c
BTrees/BucketTemplate.c
+25
-2
No files found.
BTrees/BucketTemplate.c
View file @
ab9cfb5c
...
...
@@ -1808,6 +1808,9 @@ static PyObject *
bucket_repr
(
Bucket
*
self
)
{
PyObject
*
i
,
*
r
;
#ifdef PY3K
PyObject
*
rb
;
#endif
char
repr
[
10000
];
int
rv
;
...
...
@@ -1822,20 +1825,34 @@ bucket_repr(Bucket *self)
{
return
NULL
;
}
#ifdef PY3K
rb
=
PyUnicode_AsLatin1String
(
r
);
rv
=
PyOS_snprintf
(
repr
,
sizeof
(
repr
),
"%s(%s)"
,
Py_TYPE
(
self
)
->
tp_name
,
PyBytes_AsString
(
rb
));
Py_DECREF
(
rb
);
#else
rv
=
PyOS_snprintf
(
repr
,
sizeof
(
repr
),
"%s(%s)"
,
Py_TYPE
(
self
)
->
tp_name
,
PyBytes_AS_STRING
(
r
));
#endif
if
(
rv
>
0
&&
rv
<
sizeof
(
repr
))
{
Py_DECREF
(
r
);
return
PyBytes_FromStringAndSize
(
repr
,
strlen
(
repr
));
#ifdef PY3K
return
PyUnicode_DecodeLatin1
(
repr
,
sizeof
(
repr
),
"surrogateescape"
);
#else
return
PyBytes_FromStringAndSize
(
repr
,
sizeof
(
repr
));
#endif
}
else
{
/* The static buffer wasn't big enough */
int
size
;
PyObject
*
s
;
#ifdef PY3K
PyObject
*
result
;
#endif
/* 3 for the parens and the null byte */
size
=
strlen
(
Py_TYPE
(
self
)
->
tp_name
)
+
PyBytes_GET_SIZE
(
r
)
+
3
;
s
=
PyBytes_FromStringAndSize
(
NULL
,
size
);
...
...
@@ -1846,7 +1863,13 @@ bucket_repr(Bucket *self)
PyOS_snprintf
(
PyBytes_AS_STRING
(
s
),
size
,
"%s(%s)"
,
Py_TYPE
(
self
)
->
tp_name
,
PyBytes_AS_STRING
(
r
));
Py_DECREF
(
r
);
#ifdef PY3K
result
=
PyUnicode_FromEncodedObject
(
s
,
"latin1"
,
"surrogateescape"
);
Py_DECREF
(
s
);
return
result
;
#else
return
s
;
#endif
}
}
...
...
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