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
4e1ee699
Commit
4e1ee699
authored
May 11, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sys.maxunicode, int subcls ops, set.issuperclass(non-set)
parent
cc3a1cc3
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
41 additions
and
14 deletions
+41
-14
src/runtime/builtin_modules/sys.cpp
src/runtime/builtin_modules/sys.cpp
+5
-0
src/runtime/int.cpp
src/runtime/int.cpp
+11
-11
src/runtime/set.cpp
src/runtime/set.cpp
+10
-2
src/runtime/stacktrace.cpp
src/runtime/stacktrace.cpp
+3
-0
test/tests/intmethods.py
test/tests/intmethods.py
+8
-0
test/tests/set.py
test/tests/set.py
+1
-1
test/tests/unicode_test.py
test/tests/unicode_test.py
+3
-0
No files found.
src/runtime/builtin_modules/sys.cpp
View file @
4e1ee699
...
...
@@ -474,6 +474,11 @@ void setupSys() {
ADD
(
optimize
);
#undef ADD
#define SET_SYS_FROM_STRING(key, value) sys_module->giveAttr((key), (value))
#ifdef Py_USING_UNICODE
SET_SYS_FROM_STRING
(
"maxunicode"
,
PyInt_FromLong
(
PyUnicode_GetMax
()));
#endif
sys_flags_cls
->
tp_mro
=
BoxedTuple
::
create
({
sys_flags_cls
,
object_cls
});
sys_flags_cls
->
freeze
();
...
...
src/runtime/int.cpp
View file @
4e1ee699
...
...
@@ -428,7 +428,7 @@ extern "C" Box* intAnd(BoxedInt* lhs, Box* rhs) {
if
(
!
isSubclass
(
lhs
->
cls
,
int_cls
))
raiseExcHelper
(
TypeError
,
"descriptor '__and__' requires a 'int' object but received a '%s'"
,
getTypeName
(
lhs
));
if
(
rhs
->
cls
!=
int_cls
)
{
if
(
!
isSubclass
(
rhs
->
cls
,
int_cls
)
)
{
return
NotImplemented
;
}
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
...
...
@@ -445,7 +445,7 @@ extern "C" Box* intOr(BoxedInt* lhs, Box* rhs) {
if
(
!
isSubclass
(
lhs
->
cls
,
int_cls
))
raiseExcHelper
(
TypeError
,
"descriptor '__or__' requires a 'int' object but received a '%s'"
,
getTypeName
(
lhs
));
if
(
rhs
->
cls
!=
int_cls
)
{
if
(
!
isSubclass
(
rhs
->
cls
,
int_cls
)
)
{
return
NotImplemented
;
}
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
...
...
@@ -462,7 +462,7 @@ extern "C" Box* intXor(BoxedInt* lhs, Box* rhs) {
if
(
!
isSubclass
(
lhs
->
cls
,
int_cls
))
raiseExcHelper
(
TypeError
,
"descriptor '__xor__' requires a 'int' object but received a '%s'"
,
getTypeName
(
lhs
));
if
(
rhs
->
cls
!=
int_cls
)
{
if
(
!
isSubclass
(
rhs
->
cls
,
int_cls
)
)
{
return
NotImplemented
;
}
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
...
...
@@ -590,7 +590,7 @@ extern "C" Box* intNe(BoxedInt* lhs, Box* rhs) {
if
(
!
isSubclass
(
lhs
->
cls
,
int_cls
))
raiseExcHelper
(
TypeError
,
"descriptor '__ne__' requires a 'int' object but received a '%s'"
,
getTypeName
(
lhs
));
if
(
rhs
->
cls
!=
int_cls
)
{
if
(
!
isSubclass
(
rhs
->
cls
,
int_cls
)
)
{
return
NotImplemented
;
}
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
...
...
@@ -607,7 +607,7 @@ extern "C" Box* intLt(BoxedInt* lhs, Box* rhs) {
if
(
!
isSubclass
(
lhs
->
cls
,
int_cls
))
raiseExcHelper
(
TypeError
,
"descriptor '__lt__' requires a 'int' object but received a '%s'"
,
getTypeName
(
lhs
));
if
(
rhs
->
cls
!=
int_cls
)
{
if
(
!
isSubclass
(
rhs
->
cls
,
int_cls
)
)
{
return
NotImplemented
;
}
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
...
...
@@ -624,7 +624,7 @@ extern "C" Box* intLe(BoxedInt* lhs, Box* rhs) {
if
(
!
isSubclass
(
lhs
->
cls
,
int_cls
))
raiseExcHelper
(
TypeError
,
"descriptor '__le__' requires a 'int' object but received a '%s'"
,
getTypeName
(
lhs
));
if
(
rhs
->
cls
!=
int_cls
)
{
if
(
!
isSubclass
(
rhs
->
cls
,
int_cls
)
)
{
return
NotImplemented
;
}
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
...
...
@@ -641,7 +641,7 @@ extern "C" Box* intGt(BoxedInt* lhs, Box* rhs) {
if
(
!
isSubclass
(
lhs
->
cls
,
int_cls
))
raiseExcHelper
(
TypeError
,
"descriptor '__gt__' requires a 'int' object but received a '%s'"
,
getTypeName
(
lhs
));
if
(
rhs
->
cls
!=
int_cls
)
{
if
(
!
isSubclass
(
rhs
->
cls
,
int_cls
)
)
{
return
NotImplemented
;
}
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
...
...
@@ -658,7 +658,7 @@ extern "C" Box* intGe(BoxedInt* lhs, Box* rhs) {
if
(
!
isSubclass
(
lhs
->
cls
,
int_cls
))
raiseExcHelper
(
TypeError
,
"descriptor '__ge__' requires a 'int' object but received a '%s'"
,
getTypeName
(
lhs
));
if
(
rhs
->
cls
!=
int_cls
)
{
if
(
!
isSubclass
(
rhs
->
cls
,
int_cls
)
)
{
return
NotImplemented
;
}
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
...
...
@@ -689,7 +689,7 @@ extern "C" Box* intLShift(BoxedInt* lhs, Box* rhs) {
if
(
rhs
->
cls
==
long_cls
)
return
longLshift
(
boxLong
(
lhs
->
n
),
rhs
);
if
(
rhs
->
cls
!=
int_cls
)
{
if
(
!
isSubclass
(
rhs
->
cls
,
int_cls
)
)
{
return
NotImplemented
;
}
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
...
...
@@ -706,7 +706,7 @@ extern "C" Box* intMod(BoxedInt* lhs, Box* rhs) {
if
(
!
isSubclass
(
lhs
->
cls
,
int_cls
))
raiseExcHelper
(
TypeError
,
"descriptor '__mod__' requires a 'int' object but received a '%s'"
,
getTypeName
(
lhs
));
if
(
rhs
->
cls
!=
int_cls
)
{
if
(
!
isSubclass
(
rhs
->
cls
,
int_cls
)
)
{
return
NotImplemented
;
}
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
...
...
@@ -812,7 +812,7 @@ extern "C" Box* intRShift(BoxedInt* lhs, Box* rhs) {
if
(
rhs
->
cls
==
long_cls
)
return
longRshift
(
boxLong
(
lhs
->
n
),
rhs
);
if
(
rhs
->
cls
!=
int_cls
)
{
if
(
!
isSubclass
(
rhs
->
cls
,
int_cls
)
)
{
return
NotImplemented
;
}
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
...
...
src/runtime/set.cpp
View file @
4e1ee699
...
...
@@ -292,7 +292,11 @@ static BoxedSet* setIntersection2(BoxedSet* self, Box* container) {
static
Box
*
setIssubset
(
BoxedSet
*
self
,
Box
*
container
)
{
assert
(
self
->
cls
==
set_cls
);
RELEASE_ASSERT
(
container
->
cls
==
set_cls
,
""
);
if
(
container
->
cls
!=
set_cls
&&
container
->
cls
!=
frozenset_cls
)
{
container
=
setNew
(
set_cls
,
container
);
}
assert
(
container
->
cls
==
set_cls
||
container
->
cls
==
frozenset_cls
);
BoxedSet
*
rhs
=
static_cast
<
BoxedSet
*>
(
container
);
for
(
auto
e
:
self
->
s
)
{
...
...
@@ -304,7 +308,11 @@ static Box* setIssubset(BoxedSet* self, Box* container) {
static
Box
*
setIssuperset
(
BoxedSet
*
self
,
Box
*
container
)
{
assert
(
self
->
cls
==
set_cls
);
RELEASE_ASSERT
(
container
->
cls
==
set_cls
,
""
);
if
(
container
->
cls
!=
set_cls
&&
container
->
cls
!=
frozenset_cls
)
{
container
=
setNew
(
set_cls
,
container
);
}
assert
(
container
->
cls
==
set_cls
||
container
->
cls
==
frozenset_cls
);
BoxedSet
*
rhs
=
static_cast
<
BoxedSet
*>
(
container
);
for
(
auto
e
:
rhs
->
s
)
{
...
...
src/runtime/stacktrace.cpp
View file @
4e1ee699
...
...
@@ -101,6 +101,9 @@ void raiseRaw(const ExcInfo& e) {
assert
(
e
.
type
);
assert
(
e
.
value
);
assert
(
e
.
traceback
);
assert
(
gc
::
isValidGCObject
(
e
.
type
));
assert
(
gc
::
isValidGCObject
(
e
.
value
));
assert
(
gc
::
isValidGCObject
(
e
.
traceback
));
// Using libgcc:
throw
e
;
...
...
test/tests/intmethods.py
View file @
4e1ee699
...
...
@@ -79,3 +79,11 @@ for b in range(26):
print
int
(
u'123'
,
b
)
except
ValueError
as
e
:
print
e
class
I
(
int
):
pass
for
i1
in
[
1
,
I
(
2
),
3
,
I
(
4
)]:
for
i2
in
[
1
,
I
(
2
),
3
,
I
(
4
)]:
print
-
i1
,
+
i1
,
~
i1
,
i1
<
i2
,
i1
<=
i2
,
i1
==
i2
,
i1
>
i2
,
i1
>=
i2
,
i1
!=
i2
,
i1
|
i2
,
i1
^
i2
,
i1
&
i2
,
i1
*
i2
,
i1
+
i2
,
i1
/
i2
,
i1
-
i2
,
i1
**
i2
,
i1
//
i2
test/tests/set.py
View file @
4e1ee699
...
...
@@ -107,4 +107,4 @@ print s
s
=
set
(
range
(
5
))
for
i
in
xrange
(
10
):
s2
=
set
(
range
(
i
))
print
s
.
issubset
(
s2
),
s
.
issuperset
(
s2
),
s
==
s2
,
s
!=
s2
,
s
.
difference
(
s2
)
print
s
.
issubset
(
s2
),
s
.
issuperset
(
s2
),
s
==
s2
,
s
!=
s2
,
s
.
difference
(
s2
)
,
s
.
issubset
(
range
(
i
)),
s
.
issuperset
(
range
(
i
))
test/tests/unicode_test.py
View file @
4e1ee699
...
...
@@ -152,3 +152,6 @@ for m in str.strip, str.lstrip, str.rstrip:
print
repr
(
m
(
s
,
*
args
))
print
""
.
join
([
u"
\
xB2
"
,
u"
\
xB3
"
])
import
sys
print
type
(
sys
.
maxunicode
)
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