Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
c6c4356b
Commit
c6c4356b
authored
Mar 01, 2016
by
Marius Wachtler
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix some string CAPI exception mismatches
I encountered them when I disabled str.__iter__
parent
be2d285d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
12 deletions
+19
-12
src/runtime/str.cpp
src/runtime/str.cpp
+18
-11
test/extra/paste_test.py
test/extra/paste_test.py
+1
-1
No files found.
src/runtime/str.cpp
View file @
c6c4356b
...
...
@@ -1702,7 +1702,7 @@ Box* _strSlice(BoxedString* self, i64 start, i64 stop, i64 step, i64 length) {
return
bs
;
}
static
Box
*
str_slice
(
Box
*
o
,
Py_ssize_t
i
,
Py_ssize_t
j
)
{
static
Box
*
str_slice
(
Box
*
o
,
Py_ssize_t
i
,
Py_ssize_t
j
)
noexcept
{
BoxedString
*
a
=
static_cast
<
BoxedString
*>
(
o
);
if
(
i
<
0
)
i
=
0
;
...
...
@@ -1721,7 +1721,7 @@ static Box* str_slice(Box* o, Py_ssize_t i, Py_ssize_t j) {
}
// Analoguous to CPython's, used for sq_ slots.
static
Py_ssize_t
str_length
(
Box
*
a
)
{
static
Py_ssize_t
str_length
(
Box
*
a
)
noexcept
{
return
Py_SIZE
(
a
);
}
...
...
@@ -2081,18 +2081,24 @@ Box* strSwapcase(BoxedString* self) {
return
rtn
;
}
static
inline
int
string_contains_shared
(
BoxedString
*
self
,
Box
*
elt
)
{
template
<
ExceptionStyle
S
>
static
inline
int
stringContainsShared
(
BoxedString
*
self
,
Box
*
elt
)
noexcept
(
S
==
CAPI
)
{
assert
(
PyString_Check
(
self
));
if
(
PyUnicode_Check
(
elt
))
{
int
r
=
PyUnicode_Contains
(
self
,
elt
);
if
(
r
<
0
)
if
(
r
<
0
&&
S
==
CXX
)
throwCAPIException
();
return
r
;
}
if
(
!
PyString_Check
(
elt
))
raiseExcHelper
(
TypeError
,
"'in <string>' requires string as left operand, not %s"
,
getTypeName
(
elt
));
if
(
!
PyString_Check
(
elt
))
{
if
(
S
==
CXX
)
raiseExcHelper
(
TypeError
,
"'in <string>' requires string as left operand, not %s"
,
getTypeName
(
elt
));
else
{
PyErr_Format
(
TypeError
,
"'in <string>' requires string as left operand, not %s"
,
getTypeName
(
elt
));
return
-
1
;
}
}
BoxedString
*
sub
=
static_cast
<
BoxedString
*>
(
elt
);
...
...
@@ -2106,12 +2112,12 @@ static inline int string_contains_shared(BoxedString* self, Box* elt) {
}
// Analoguous to CPython's, used for sq_ slots.
static
int
string_contains
(
PyObject
*
str_obj
,
PyObject
*
sub_obj
)
{
return
string
_contains_shared
((
BoxedString
*
)
str_obj
,
sub_obj
);
static
int
string_contains
(
PyObject
*
str_obj
,
PyObject
*
sub_obj
)
noexcept
{
return
string
ContainsShared
<
CAPI
>
((
BoxedString
*
)
str_obj
,
sub_obj
);
}
Box
*
strContains
(
BoxedString
*
self
,
Box
*
elt
)
{
return
boxBool
(
string
_contains_shared
(
self
,
elt
));
return
boxBool
(
string
ContainsShared
<
CXX
>
(
self
,
elt
));
}
// compares (a+a_pos, len) with (str)
...
...
@@ -2310,11 +2316,12 @@ Box* strEncode(BoxedString* self, Box* encoding, Box* error) {
return
result
;
}
static
PyObject
*
string_item
(
PyStringObject
*
self
,
register
Py_ssize_t
i
)
{
static
PyObject
*
string_item
(
PyStringObject
*
self
,
register
Py_ssize_t
i
)
noexcept
{
BoxedString
*
boxedString
=
(
BoxedString
*
)
self
;
if
(
i
<
0
||
i
>=
boxedString
->
size
())
{
raiseExcHelper
(
IndexError
,
"string index out of range"
);
PyErr_SetString
(
PyExc_IndexError
,
"string index out of range"
);
return
NULL
;
}
char
c
=
boxedString
->
s
()[
i
];
...
...
test/extra/paste_test.py
View file @
c6c4356b
...
...
@@ -36,7 +36,7 @@ print ">> "
# - no sys.settrace
# - no shiftjis encoding
# - slightly different error messages
expected
=
[{
"failed"
:
22
,
"passed"
:
11
3
}]
expected
=
[{
"failed"
:
22
,
"passed"
:
11
2
}]
run_test
([
PYTEST_EXE
],
cwd
=
PASTE_TEST_DIR
,
expected
=
expected
)
...
...
Boxiang Sun
@Daetalus
mentioned in commit
f36dfc31
·
Sep 08, 2016
mentioned in commit
f36dfc31
mentioned in commit f36dfc31cfd33268bb5dacf880a997be7380d924
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