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
f36dfc31
Commit
f36dfc31
authored
Mar 21, 2016
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Plain Diff
Merge commit '
c6c4356b
' into refcounting
parents
db7c7ba4
c6c4356b
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 @
f36dfc31
...
...
@@ -1717,7 +1717,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
;
...
...
@@ -1736,7 +1736,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
);
}
...
...
@@ -2096,18 +2096,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
);
...
...
@@ -2121,12 +2127,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)
...
...
@@ -2327,11 +2333,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 @
f36dfc31
...
...
@@ -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
)
...
...
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