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
58366391
Commit
58366391
authored
Feb 26, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge commit 'e9152b' into refcounting
parents
d15efaa1
e9152be5
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
66 additions
and
12 deletions
+66
-12
from_cpython/Lib/test/test_file.py
from_cpython/Lib/test/test_file.py
+2
-1
src/runtime/classobj.cpp
src/runtime/classobj.cpp
+4
-4
src/runtime/file.cpp
src/runtime/file.cpp
+2
-0
src/runtime/int.cpp
src/runtime/int.cpp
+4
-4
src/runtime/list.cpp
src/runtime/list.cpp
+6
-1
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+2
-0
test/CPYTHON_TEST_NOTES.md
test/CPYTHON_TEST_NOTES.md
+0
-1
test/extra/avro_test.py
test/extra/avro_test.py
+24
-0
test/tests/file.py
test/tests/file.py
+1
-0
test/tests/intmethods.py
test/tests/intmethods.py
+4
-0
test/tests/list.py
test/tests/list.py
+1
-1
test/tests/oldstyle_classes.py
test/tests/oldstyle_classes.py
+16
-0
No files found.
from_cpython/Lib/test/test_file.py
View file @
58366391
# expected: fail
# NOTE: this file tests the new `io` library backported from Python 3.x.
# Similar tests for the builtin file object can be found in test_file2k.py.
...
...
@@ -27,6 +26,8 @@ class AutoFileTests(unittest.TestCase):
self
.
f
.
close
()
os
.
remove
(
TESTFN
)
# pyston change:
@
unittest
.
skip
(
"does not work with GC"
)
def
testWeakRefs
(
self
):
# verify weak references
p
=
proxy
(
self
.
f
)
...
...
src/runtime/classobj.cpp
View file @
58366391
...
...
@@ -221,7 +221,7 @@ static Box* classobjGetattribute(Box* _cls, Box* _attr) {
BoxedString
*
attr
=
static_cast
<
BoxedString
*>
(
_attr
);
// These are special cases in CPython as well:
if
(
attr
->
s
()[
0
]
==
'_'
&&
attr
->
s
()[
1
]
==
'_'
)
{
if
(
attr
->
data
()[
0
]
==
'_'
&&
attr
->
data
()[
1
]
==
'_'
)
{
if
(
attr
->
s
()
==
"__dict__"
)
return
cls
->
getAttrWrapper
();
...
...
@@ -454,7 +454,7 @@ static Box* _instanceGetattribute(Box* _inst, BoxedString* attr_str, bool raise_
BoxedInstance
*
inst
=
static_cast
<
BoxedInstance
*>
(
_inst
);
// These are special cases in CPython as well:
if
(
attr_str
->
s
()[
0
]
==
'_'
&&
attr_str
->
s
()[
1
]
==
'_'
)
{
if
(
attr_str
->
data
()[
0
]
==
'_'
&&
attr_str
->
data
()[
1
]
==
'_'
)
{
if
(
attr_str
->
s
()
==
"__dict__"
)
return
inst
->
getAttrWrapper
();
...
...
@@ -516,7 +516,7 @@ void instanceSetattroInternal(Box* _inst, Box* _attr, STOLEN(Box*) value, Setatt
assert
(
value
);
// These are special cases in CPython as well:
if
(
attr
->
s
()[
0
]
==
'_'
&&
attr
->
s
()[
1
]
==
'_'
)
{
if
(
attr
->
data
()[
0
]
==
'_'
&&
attr
->
data
()[
1
]
==
'_'
)
{
if
(
attr
->
s
()
==
"__dict__"
)
Py_FatalError
(
"unimplemented"
);
...
...
@@ -579,7 +579,7 @@ Box* instanceDelattr(Box* _inst, Box* _attr) {
BoxedString
*
attr
=
static_cast
<
BoxedString
*>
(
_attr
);
// These are special cases in CPython as well:
if
(
attr
->
s
()[
0
]
==
'_'
&&
attr
->
s
()[
1
]
==
'_'
)
{
if
(
attr
->
data
()[
0
]
==
'_'
&&
attr
->
data
()[
1
]
==
'_'
)
{
if
(
attr
->
s
()
==
"__dict__"
)
raiseExcHelper
(
TypeError
,
"__dict__ must be set to a dictionary"
);
...
...
src/runtime/file.cpp
View file @
58366391
...
...
@@ -1887,6 +1887,8 @@ void setupFile() {
new
BoxedMemberDescriptor
(
BoxedMemberDescriptor
::
OBJECT
,
offsetof
(
BoxedFile
,
f_name
),
true
));
file_cls
->
giveAttr
(
"mode"
,
new
BoxedMemberDescriptor
(
BoxedMemberDescriptor
::
OBJECT
,
offsetof
(
BoxedFile
,
f_mode
),
true
));
file_cls
->
giveAttr
(
"encoding"
,
new
BoxedMemberDescriptor
(
BoxedMemberDescriptor
::
OBJECT
,
offsetof
(
BoxedFile
,
f_encoding
),
true
));
file_cls
->
giveAttr
(
"__new__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
fileNew
,
UNKNOWN
,
4
,
false
,
false
),
{
autoDecref
(
boxString
(
"r"
)),
autoDecref
(
boxInt
(
-
1
))
}));
...
...
src/runtime/int.cpp
View file @
58366391
...
...
@@ -1201,7 +1201,7 @@ template <ExceptionStyle S> static Box* _intNew(Box* val, Box* _base) noexcept(S
return
NULL
;
}
if
(
val
==
N
one
)
{
if
(
val
==
N
ULL
)
{
PyErr_SetString
(
PyExc_TypeError
,
"int() missing string argument"
);
return
NULL
;
}
...
...
@@ -1214,7 +1214,7 @@ template <ExceptionStyle S> static Box* _intNew(Box* val, Box* _base) noexcept(S
if
(
!
PyInt_Check
(
_base
))
raiseExcHelper
(
TypeError
,
"an integer is required"
);
if
(
val
==
N
one
)
if
(
val
==
N
ULL
)
raiseExcHelper
(
TypeError
,
"int() missing string argument"
);
if
(
!
PyString_Check
(
val
)
&&
!
PyUnicode_Check
(
val
))
...
...
@@ -1222,7 +1222,7 @@ template <ExceptionStyle S> static Box* _intNew(Box* val, Box* _base) noexcept(S
}
base
=
static_cast
<
BoxedInt
*>
(
_base
)
->
n
;
}
else
{
if
(
val
==
N
one
)
if
(
val
==
N
ULL
)
return
PyInt_FromLong
(
0L
);
Box
*
r
=
PyNumber_Int
(
val
);
...
...
@@ -1557,7 +1557,7 @@ void setupInt() {
auto
int_new
=
FunctionMetadata
::
create
((
void
*
)
intNew
<
CXX
>
,
UNKNOWN
,
3
,
false
,
false
,
ParamNames
({
""
,
"x"
,
"base"
},
""
,
""
),
CXX
);
int_new
->
addVersion
((
void
*
)
intNew
<
CAPI
>
,
UNKNOWN
,
CAPI
);
int_cls
->
giveAttr
(
"__new__"
,
new
BoxedFunction
(
int_new
,
{
N
one
,
NULL
}));
int_cls
->
giveAttr
(
"__new__"
,
new
BoxedFunction
(
int_new
,
{
N
ULL
,
NULL
}));
int_cls
->
giveAttr
(
"bit_length"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
intBitLength
,
BOXED_INT
,
1
)));
...
...
src/runtime/list.cpp
View file @
58366391
...
...
@@ -820,6 +820,11 @@ Box* listIAdd(BoxedList* self, Box* _rhs) {
return
self
;
}
Box
*
listExtend
(
BoxedList
*
self
,
Box
*
_rhs
)
{
listIAdd
(
self
,
_rhs
);
return
None
;
}
Box
*
listAdd
(
BoxedList
*
self
,
Box
*
_rhs
)
{
if
(
!
PyList_Check
(
_rhs
))
{
return
incref
(
NotImplemented
);
...
...
@@ -1426,7 +1431,7 @@ void setupList() {
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
listPop
,
UNKNOWN
,
2
,
false
,
false
),
{
None
}));
list_cls
->
giveAttr
(
"append"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
listAppend
,
NONE
,
2
)));
list_cls
->
giveAttr
(
"extend"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
list
IAdd
,
UNKNOWN
,
2
)));
list_cls
->
giveAttr
(
"extend"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
list
Extend
,
NONE
,
2
)));
list_cls
->
giveAttr
(
"insert"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
listInsert
,
NONE
,
3
)));
list_cls
->
giveAttr
(
"__mul__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
listMul
,
UNKNOWN
,
2
)));
...
...
src/runtime/objmodel.cpp
View file @
58366391
...
...
@@ -6211,6 +6211,8 @@ Box* getiter(Box* o) {
Box
*
r
=
NULL
;
if
(
PyType_HasFeature
(
type
,
Py_TPFLAGS_HAVE_ITER
)
&&
type
->
tp_iter
!=
slot_tp_iter
&&
type
->
tp_iter
)
{
r
=
type
->
tp_iter
(
o
);
if
(
!
r
&&
PyErr_Occurred
())
throwCAPIException
();
}
else
{
r
=
type
->
callIterIC
(
o
);
}
...
...
test/CPYTHON_TEST_NOTES.md
View file @
58366391
...
...
@@ -97,7 +97,6 @@ test_extcall f(**kw) crashes if kw isn't a dict
test_file2k we abort when you try to open() a directory
test_file_eintr not sure
test_fileio [unknown]
test_file wontfix: we don't destruct file objects when the test wants
test_fork1 [unknown]
test_frozen [unknown]
test_ftplib [unknown]
...
...
test/extra/avro_test.py
0 → 100644
View file @
58366391
import
os
,
sys
,
subprocess
sys
.
path
.
append
(
os
.
path
.
dirname
(
__file__
)
+
"/../lib"
)
from
test_helper
import
create_virtenv
,
run_test
ENV_NAME
=
"avro_test_env_"
+
os
.
path
.
basename
(
sys
.
executable
)
PYTHON_EXE
=
os
.
path
.
abspath
(
os
.
path
.
join
(
ENV_NAME
,
"bin"
,
"python"
))
NOSETESTS_EXE
=
os
.
path
.
abspath
(
os
.
path
.
join
(
ENV_NAME
,
"bin"
,
"nosetests"
))
AVRO_DIR
=
os
.
path
.
abspath
(
os
.
path
.
join
(
ENV_NAME
,
"avro-1.7.7"
))
packages
=
[
"nose==1.3.7"
,
"avro==1.7.7"
]
create_virtenv
(
ENV_NAME
,
packages
,
force_create
=
True
)
url
=
"https://pypi.python.org/packages/source/a/avro/avro-1.7.7.tar.gz"
subprocess
.
check_call
([
"wget"
,
url
],
cwd
=
ENV_NAME
)
subprocess
.
check_call
([
"tar"
,
"-zxf"
,
"avro-1.7.7.tar.gz"
],
cwd
=
ENV_NAME
)
env
=
os
.
environ
env
[
"PYTHONPATH"
]
=
os
.
path
.
abspath
(
os
.
path
.
join
(
ENV_NAME
,
"site-packages"
))
# this tests also fail when run in cpython with nose.
# pytest makes two of this work but we can't currently run pytest...
expected
=
[{
'ran'
:
51
,
'errors'
:
3
}]
run_test
([
NOSETESTS_EXE
],
env
=
env
,
cwd
=
AVRO_DIR
,
expected
=
expected
)
test/tests/file.py
View file @
58366391
...
...
@@ -20,6 +20,7 @@ def chop(s):
for
desc
in
[
sys
.
stderr
,
sys
.
stdout
,
sys
.
stdin
]:
print
chop
(
str
(
desc
))
print
desc
.
encoding
f
=
open
(
"/dev/null"
,
'w'
)
print
chop
(
str
(
f
))
...
...
test/tests/intmethods.py
View file @
58366391
...
...
@@ -63,6 +63,10 @@ print type(int(2**100))
print
type
(
int
(
2L
))
print
type
(
int
.
__new__
(
int
,
2
**
100
))
print
type
(
int
.
__new__
(
int
,
2L
))
try
:
print
int
(
None
)
except
TypeError
,
e
:
print
e
try
:
print
type
(
int
.
__new__
(
C
,
2
**
100
))
except
OverflowError
,
e
:
...
...
test/tests/list.py
View file @
58366391
...
...
@@ -85,7 +85,7 @@ while l:
del
l
[
0
]
l
=
range
(
5
)
l
.
extend
(
range
(
5
))
print
l
.
extend
(
range
(
5
))
print
l
# Repeating a list
...
...
test/tests/oldstyle_classes.py
View file @
58366391
...
...
@@ -511,3 +511,19 @@ for i in range(500):
if
i
==
150
:
C
.
__bases__
=
tuple
()
print
s1
,
s2
# we used to have problems with this
for
i
in
range
(
2
):
try
:
C
.
_
except
AttributeError
,
e
:
print
e
try
:
C
().
_
except
AttributeError
,
e
:
print
e
try
:
print
C
().
_
()
except
AttributeError
,
e
:
print
e
C
.
_
=
(
lambda
s
:
42
)
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