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
6d143b9f
Commit
6d143b9f
authored
Oct 01, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #939 from undingen/m2crypto
add m2crypto test + fix missing stuff
parents
81019f42
e6ade3a0
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
110 additions
and
33 deletions
+110
-33
.travis.yml
.travis.yml
+1
-0
from_cpython/Include/code.h
from_cpython/Include/code.h
+3
-0
src/runtime/classobj.cpp
src/runtime/classobj.cpp
+0
-6
src/runtime/code.cpp
src/runtime/code.cpp
+5
-0
src/runtime/import.cpp
src/runtime/import.cpp
+9
-0
src/runtime/types.cpp
src/runtime/types.cpp
+12
-0
test/extra/M2Crypto_patch.patch
test/extra/M2Crypto_patch.patch
+23
-0
test/extra/M2Crypto_test.py
test/extra/M2Crypto_test.py
+49
-0
test/extra/pyopenssl_test.py
test/extra/pyopenssl_test.py
+1
-1
test/lib/test_helper.py
test/lib/test_helper.py
+6
-25
test/tests/oldstyle_classes.py
test/tests/oldstyle_classes.py
+1
-1
No files found.
.travis.yml
View file @
6d143b9f
...
...
@@ -51,6 +51,7 @@ addons:
-
libxml2-dev
-
libxslt1-dev
-
libssl-dev
-
swig
before_install
:
-
if [ "$CC" = "clang" ]; then export CC="clang-3.5" CXX="clang++-3.5"; fi
...
...
from_cpython/Include/code.h
View file @
6d143b9f
...
...
@@ -91,6 +91,9 @@ PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno) PYS
use PyFrame_GetLineNumber() instead. */
PyAPI_FUNC
(
int
)
PyCode_Addr2Line
(
PyCodeObject
*
,
int
)
PYSTON_NOEXCEPT
;
// Pyston addition:
PyAPI_FUNC
(
int
)
PyCode_GetArgCount
(
PyCodeObject
*
)
PYSTON_NOEXCEPT
;
/* for internal use only */
#define _PyCode_GETCODEPTR(co, pp) \
((*Py_TYPE((co)->co_code)->tp_as_buffer->bf_getreadbuffer) \
...
...
src/runtime/classobj.cpp
View file @
6d143b9f
...
...
@@ -148,12 +148,6 @@ Box* classobjNew(Box* _cls, Box* _name, Box* _bases, Box** _args) {
made
->
setattr
(
s
,
p
.
second
,
NULL
);
}
// Note: make sure to do this after assigning the attrs, since it will overwrite any defined __name__
static
BoxedString
*
name_str
=
internStringImmortal
(
"__name__"
);
static
BoxedString
*
bases_str
=
internStringImmortal
(
"__bases__"
);
made
->
setattr
(
name_str
,
name
,
NULL
);
made
->
setattr
(
bases_str
,
bases
,
NULL
);
return
made
;
}
...
...
src/runtime/code.cpp
View file @
6d143b9f
...
...
@@ -110,6 +110,11 @@ extern "C" PyCodeObject* PyCode_New(int, int, int, int, PyObject*, PyObject*, Py
RELEASE_ASSERT
(
0
,
"not implemented"
);
}
extern
"C"
int
PyCode_GetArgCount
(
PyCodeObject
*
op
)
noexcept
{
RELEASE_ASSERT
(
PyCode_Check
((
Box
*
)
op
),
""
);
return
unboxInt
(
BoxedCode
::
argcount
((
Box
*
)
op
,
NULL
));
}
void
setupCode
()
{
code_cls
=
BoxedClass
::
create
(
type_cls
,
object_cls
,
&
BoxedCode
::
gcHandler
,
0
,
0
,
sizeof
(
BoxedCode
),
false
,
"code"
);
...
...
src/runtime/import.cpp
View file @
6d143b9f
...
...
@@ -615,6 +615,15 @@ extern "C" PyObject* PyImport_ImportModule(const char* name) noexcept {
return
PyImport_Import
(
boxString
(
name
));
}
extern
"C"
PyObject
*
PyImport_GetModuleDict
(
void
)
noexcept
{
try
{
return
getSysModulesDict
();
}
catch
(
ExcInfo
e
)
{
setCAPIException
(
e
);
return
NULL
;
}
}
/* Get the module object corresponding to a module name.
First check the modules dictionary if there's one there,
if not, create a new one and insert it in the modules dictionary.
...
...
src/runtime/types.cpp
View file @
6d143b9f
...
...
@@ -463,6 +463,9 @@ void BoxedFunction::gcHandler(GCVisitor* v, Box* b) {
v
->
visit
(
&
f
->
globals
);
v
->
visit
(
&
f
->
defaults
);
if
(
f
->
f
&&
f
->
f
->
source
&&
f
->
f
->
source
->
parent_module
)
v
->
visit
(
&
f
->
f
->
source
->
parent_module
);
}
BoxedBuiltinFunctionOrMethod
::
BoxedBuiltinFunctionOrMethod
(
CLFunction
*
f
,
const
char
*
name
,
const
char
*
doc
)
...
...
@@ -1699,6 +1702,15 @@ static Box* functionCode(Box* self, void*) {
return
codeForFunction
(
func
);
}
extern
"C"
PyObject
*
PyFunction_GetCode
(
PyObject
*
func
)
noexcept
{
try
{
return
functionCode
((
Box
*
)
func
,
NULL
);
}
catch
(
ExcInfo
e
)
{
setCAPIException
(
e
);
return
NULL
;
}
}
static
void
functionSetCode
(
Box
*
self
,
Box
*
v
,
void
*
)
{
assert
(
self
->
cls
==
function_cls
);
...
...
test/extra/M2Crypto_patch.patch
0 → 100644
View file @
6d143b9f
diff -ur M2Crypto-0.21.1.orig/SWIG/_lib.i ./SWIG/_lib.i
--- M2Crypto-0.21.1/SWIG/_lib.i 2011-01-15 19:10:06.000000000 +0000
+++ ./SWIG/_lib.i 2015-09-25 12:41:17.184659427 +0100
@@ -110,12 +110,16 @@
PyCodeObject *code;
func = PyMethod_Function(ssl_verify_cb_func);
code = (PyCodeObject *) PyFunction_GetCode(func);
- if (code && code->co_argcount == 3) { /* XXX Python internals */
+ // Pyston change
+ //if (code && code->co_argcount == 3) { /* XXX Python internals */
+ if (code && PyCode_GetArgCount(code) == 3) {
new_style_callback = 1;
}
} else if (PyFunction_Check(ssl_verify_cb_func)) {
PyCodeObject *code = (PyCodeObject *) PyFunction_GetCode(ssl_verify_cb_func);
- if (code && code->co_argcount == 2) { /* XXX Python internals */
+ // Pyston change
+ //if (code && code->co_argcount == 2) { /* XXX Python internals */
+ if (code && PyCode_GetArgCount(code) == 2) {
new_style_callback = 1;
}
} else {
test/extra/M2Crypto_test.py
0 → 100644
View file @
6d143b9f
import
os
,
sys
,
subprocess
,
shutil
sys
.
path
.
append
(
os
.
path
.
dirname
(
__file__
)
+
"/../lib"
)
from
test_helper
import
create_virtenv
,
run_test
ENV_NAME
=
"M2Crypto_test_env_"
+
os
.
path
.
basename
(
sys
.
executable
)
SRC_DIR
=
os
.
path
.
abspath
(
os
.
path
.
join
(
ENV_NAME
,
"src"
))
PYTHON_EXE
=
os
.
path
.
abspath
(
os
.
path
.
join
(
ENV_NAME
,
"bin"
,
"python"
))
def
install_and_test_lxml
():
shutil
.
rmtree
(
SRC_DIR
,
ignore_errors
=
True
)
os
.
makedirs
(
SRC_DIR
)
url
=
"https://pypi.python.org/packages/source/M/M2Crypto/M2Crypto-0.21.1.tar.gz"
subprocess
.
check_call
([
"wget"
,
url
],
cwd
=
SRC_DIR
)
subprocess
.
check_call
([
"tar"
,
"-zxf"
,
"M2Crypto-0.21.1.tar.gz"
],
cwd
=
SRC_DIR
)
M2CRYPTO_DIR
=
os
.
path
.
abspath
(
os
.
path
.
join
(
SRC_DIR
,
"M2Crypto-0.21.1"
))
url
=
"http://archive.ubuntu.com/ubuntu/pool/main/m/m2crypto/m2crypto_0.21.1-3ubuntu5.debian.tar.gz"
subprocess
.
check_call
([
"wget"
,
url
],
cwd
=
M2CRYPTO_DIR
)
subprocess
.
check_call
([
"tar"
,
"-zxf"
,
"m2crypto_0.21.1-3ubuntu5.debian.tar.gz"
],
cwd
=
M2CRYPTO_DIR
)
debian_patches
=
(
"0001-Import-inspect-in-urllib-2.patch"
,
"0002-Disable-SSLv2_method-when-disabled-in-OpenSSL-iself-.patch"
,
"0003-Look-for-OpenSSL-headers-in-usr-include-DEB_HOST_MUL.patch"
,
"skip_sslv2_tests.patch"
,
"fix_testsuite_ftbfs.patch"
,
"fix_testsuite_tls1.2.patch"
,
"fix_testsuite_sha256.patch"
)
for
patch
in
debian_patches
:
PATCH_FILE
=
os
.
path
.
abspath
(
os
.
path
.
join
(
M2CRYPTO_DIR
,
"debian"
,
"patches"
,
patch
))
subprocess
.
check_call
([
"patch"
,
"-p1"
,
"--input="
+
PATCH_FILE
],
cwd
=
M2CRYPTO_DIR
)
PATCH_FILE
=
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"M2Crypto_patch.patch"
))
subprocess
.
check_call
([
"patch"
,
"-p1"
,
"--input="
+
PATCH_FILE
],
cwd
=
M2CRYPTO_DIR
)
env
=
os
.
environ
# M2Crypto can't find the opensslconf without this
env
[
"DEB_HOST_MULTIARCH"
]
=
"/usr/include/x86_64-linux-gnu"
# SWIG does not work with pyston if this define is not set
env
[
"CFLAGS"
]
=
"-DSWIG_PYTHON_SLOW_GETSET_THIS"
subprocess
.
check_call
([
PYTHON_EXE
,
"setup.py"
,
"install"
],
cwd
=
M2CRYPTO_DIR
,
env
=
env
)
expected
=
[{
'ran'
:
235
,
'failures'
:
1
,
'errors'
:
7
,
'skipped'
:
2
}]
run_test
([
PYTHON_EXE
,
"setup.py"
,
"test"
],
cwd
=
M2CRYPTO_DIR
,
expected
=
expected
)
create_virtenv
(
ENV_NAME
,
None
,
force_create
=
True
)
install_and_test_lxml
()
test/extra/pyopenssl_test.py
View file @
6d143b9f
...
...
@@ -10,5 +10,5 @@ PYOPENSSL_DIR = os.path.abspath(os.path.join(ENV_NAME, "site-packages", "OpenSSL
packages
=
[
"nose==1.3.7"
,
"pycparser==2.13"
,
"cryptography==1.0.1"
,
"pyopenssl==0.15.1"
,
"pyasn1==0.1.7"
,
"idna==2.0"
,
"six==1.9.0"
,
"enum34==1.0.4"
,
"ipaddress==1.0.14"
,
"cffi==1.1.0"
]
create_virtenv
(
ENV_NAME
,
packages
,
force_create
=
True
)
expected
=
[{
'ran'
:
247
,
'errors'
:
2
,
'failures'
:
0
}]
expected
=
[{
'ran'
:
247
,
'errors'
:
2
}]
run_test
([
NOSETESTS_EXE
],
cwd
=
PYOPENSSL_DIR
,
expected
=
expected
)
test/lib/test_helper.py
View file @
6d143b9f
...
...
@@ -40,31 +40,12 @@ def parse_output(output):
m
=
re
.
match
(
"Ran (
\
d+)
t
ests in"
,
l
)
if
m
:
result
.
append
({
"ran"
:
int
(
m
.
group
(
1
))})
m
=
re
.
match
(
"FAILED
\
(
f
ailures=(
\
d+), e
r
rors=(
\
d+)
\
)"
,
l
)
if
m
:
d
=
result
[
-
1
]
assert
d
.
keys
()
==
[
"ran"
]
d
[
'failures'
]
=
int
(
m
.
group
(
1
))
d
[
'errors'
]
=
int
(
m
.
group
(
2
))
m
=
re
.
match
(
"FAILED
\
(e
r
rors=(
\
d+),
f
ailures=(
\
d+)
\
)"
,
l
)
if
m
:
d
=
result
[
-
1
]
assert
d
.
keys
()
==
[
"ran"
]
d
[
'failures'
]
=
int
(
m
.
group
(
2
))
d
[
'errors'
]
=
int
(
m
.
group
(
1
))
m
=
re
.
match
(
"FAILED
\
(
f
ailures=(
\
d+)
\
)"
,
l
)
if
m
:
d
=
result
[
-
1
]
assert
d
.
keys
()
==
[
"ran"
]
d
[
'failures'
]
=
int
(
m
.
group
(
1
))
d
[
'errors'
]
=
0
m
=
re
.
match
(
"FAILED
\
(e
r
rors=(
\
d+)
\
)"
,
l
)
if
m
:
d
=
result
[
-
1
]
assert
d
.
keys
()
==
[
"ran"
]
d
[
'failures'
]
=
0
d
[
'errors'
]
=
int
(
m
.
group
(
1
))
continue
for
res_type
in
(
"errors"
,
"failures"
,
"skipped"
):
m
=
re
.
match
(
"FAILED
\
(.*%s=(
\
d+).*
\
)
"
% res_type, l)
if m:
result[-1][res_type] = int(m.group(1))
return result
def run_test(cmd, cwd, expected, env = None):
...
...
test/tests/oldstyle_classes.py
View file @
6d143b9f
class
C
():
pass
print
C
,
type
(
C
)
print
C
,
type
(
C
)
,
sorted
(
dir
(
C
))
print
map
(
str
,
C
.
__bases__
),
C
.
__name__
print
type
(
C
())
...
...
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