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
012b3e89
Commit
012b3e89
authored
Mar 10, 2015
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the ssl module
parent
c3d7d8c2
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
51 additions
and
14 deletions
+51
-14
CMakeLists.txt
CMakeLists.txt
+1
-1
Makefile
Makefile
+2
-2
from_cpython/CMakeLists.txt
from_cpython/CMakeLists.txt
+1
-1
from_cpython/Modules/_ssl.c
from_cpython/Modules/_ssl.c
+12
-1
from_cpython/Objects/capsule.c
from_cpython/Objects/capsule.c
+0
-4
src/capi/modsupport.cpp
src/capi/modsupport.cpp
+9
-0
src/codegen/unwinding.cpp
src/codegen/unwinding.cpp
+7
-3
src/runtime/int.cpp
src/runtime/int.cpp
+4
-0
src/runtime/types.cpp
src/runtime/types.cpp
+2
-0
test/tests/ssl_test.py
test/tests/ssl_test.py
+11
-0
test/unittests/CMakeLists.txt
test/unittests/CMakeLists.txt
+1
-1
tools/CMakeLists.txt
tools/CMakeLists.txt
+1
-1
No files found.
CMakeLists.txt
View file @
012b3e89
...
...
@@ -169,7 +169,7 @@ add_subdirectory(tools)
add_executable
(
pyston $<TARGET_OBJECTS:PYSTON_MAIN_OBJECT> $<TARGET_OBJECTS:PYSTON_OBJECTS> $<TARGET_OBJECTS:FROM_CPYTHON>
)
# Wrap the stdlib in --whole-archive to force all the symbols to be included and eventually exported
target_link_libraries
(
pyston -Wl,--whole-archive stdlib -Wl,--no-whole-archive pthread m readline gmp unwind pypa double-conversion
${
LLVM_LIBS
}
${
LIBLZMA_LIBRARIES
}
${
OPTIONAL_LIBRARIES
}
)
target_link_libraries
(
pyston -Wl,--whole-archive stdlib -Wl,--no-whole-archive pthread m readline gmp
ssl crypto
unwind pypa double-conversion
${
LLVM_LIBS
}
${
LIBLZMA_LIBRARIES
}
${
OPTIONAL_LIBRARIES
}
)
# copy src/codegen/parse_ast.py to the build directory
add_custom_command
(
TARGET pyston POST_BUILD COMMAND
${
CMAKE_COMMAND
}
-E copy_if_different
${
CMAKE_SOURCE_DIR
}
/src/codegen/parse_ast.py
${
CMAKE_BINARY_DIR
}
/src/codegen/parse_ast.py
)
...
...
Makefile
View file @
012b3e89
...
...
@@ -165,7 +165,7 @@ COMMON_CXXFLAGS += -DGITREV=$(shell git rev-parse HEAD | head -c 12) -DLLVMREV=$
COMMON_CXXFLAGS
+=
-DDEFAULT_PYTHON_MAJOR_VERSION
=
$(PYTHON_MAJOR_VERSION)
-DDEFAULT_PYTHON_MINOR_VERSION
=
$(PYTHON_MINOR_VERSION)
-DDEFAULT_PYTHON_MICRO_VERSION
=
$(PYTHON_MICRO_VERSION)
# Use our "custom linker" that calls gold if available
COMMON_LDFLAGS
:=
-B
$(TOOLS_DIR)
/build_system
-L
/usr/local/lib
-lpthread
-lm
-lunwind
-llzma
-L
$(DEPS_DIR)
/gcc-4.8.2-install/lib64
-lreadline
-lgmp
COMMON_LDFLAGS
:=
-B
$(TOOLS_DIR)
/build_system
-L
/usr/local/lib
-lpthread
-lm
-lunwind
-llzma
-L
$(DEPS_DIR)
/gcc-4.8.2-install/lib64
-lreadline
-lgmp
-lssl
-lcrypto
COMMON_LDFLAGS
+=
$(DEPS_DIR)
/pypa-install/lib/libpypa.a
# Conditionally add libtinfo if available - otherwise nothing will be added
...
...
@@ -292,7 +292,7 @@ STDLIB_OBJS := stdlib.bc.o stdlib.stripped.bc.o
STDLIB_RELEASE_OBJS
:=
stdlib.release.bc.o
ASM_SRCS
:=
$(
wildcard
src/runtime/
*
.S
)
STDMODULE_SRCS
:=
errnomodule.c shamodule.c sha256module.c sha512module.c _math.c mathmodule.c md5.c md5module.c _randommodule.c _sre.c operator.c binascii.c pwdmodule.c posixmodule.c _struct.c datetimemodule.c _functoolsmodule.c _collectionsmodule.c itertoolsmodule.c resource.c signalmodule.c selectmodule.c fcntlmodule.c timemodule.c arraymodule.c zlibmodule.c _codecsmodule.c socketmodule.c unicodedata.c _weakref.c cStringIO.c _io/bufferedio.c _io/bytesio.c _io/fileio.c _io/iobase.c _io/_iomodule.c _io/stringio.c _io/textio.c zipimport.c _csv.c
$(EXTRA_STDMODULE_SRCS)
STDMODULE_SRCS
:=
errnomodule.c shamodule.c sha256module.c sha512module.c _math.c mathmodule.c md5.c md5module.c _randommodule.c _sre.c operator.c binascii.c pwdmodule.c posixmodule.c _struct.c datetimemodule.c _functoolsmodule.c _collectionsmodule.c itertoolsmodule.c resource.c signalmodule.c selectmodule.c fcntlmodule.c timemodule.c arraymodule.c zlibmodule.c _codecsmodule.c socketmodule.c unicodedata.c _weakref.c cStringIO.c _io/bufferedio.c _io/bytesio.c _io/fileio.c _io/iobase.c _io/_iomodule.c _io/stringio.c _io/textio.c zipimport.c _csv.c
_ssl.c
$(EXTRA_STDMODULE_SRCS)
STDOBJECT_SRCS
:=
structseq.c capsule.c stringobject.c exceptions.c unicodeobject.c unicodectype.c bytearrayobject.c bytes_methods.c weakrefobject.c memoryobject.c iterobject.c
$(EXTRA_STDOBJECT_SRCS)
STDPYTHON_SRCS
:=
pyctype.c getargs.c formatter_string.c pystrtod.c dtoa.c formatter_unicode.c structmember.c marshal.c
$(EXTRA_STDPYTHON_SRCS)
FROM_CPYTHON_SRCS
:=
$(
addprefix
from_cpython/Modules/,
$(STDMODULE_SRCS)
)
$(
addprefix
from_cpython/Objects/,
$(STDOBJECT_SRCS)
)
$(
addprefix
from_cpython/Python/,
$(STDPYTHON_SRCS)
)
...
...
from_cpython/CMakeLists.txt
View file @
012b3e89
...
...
@@ -15,7 +15,7 @@ endforeach(STDLIB_FILE)
add_custom_target
(
copy_stdlib ALL DEPENDS
${
STDLIB_TARGETS
}
)
# compile specified files in from_cpython/Modules
file
(
GLOB_RECURSE STDMODULE_SRCS Modules errnomodule.c shamodule.c sha256module.c sha512module.c _math.c mathmodule.c md5.c md5module.c _randommodule.c _sre.c operator.c binascii.c pwdmodule.c posixmodule.c _struct.c datetimemodule.c _functoolsmodule.c _collectionsmodule.c itertoolsmodule.c resource.c signalmodule.c selectmodule.c fcntlmodule.c timemodule.c arraymodule.c zlibmodule.c _codecsmodule.c socketmodule.c unicodedata.c _weakref.c cStringIO.c bufferedio.c bytesio.c fileio.c iobase.c _iomodule.c stringio.c textio.c zipimport.c _csv.c
)
file
(
GLOB_RECURSE STDMODULE_SRCS Modules errnomodule.c shamodule.c sha256module.c sha512module.c _math.c mathmodule.c md5.c md5module.c _randommodule.c _sre.c operator.c binascii.c pwdmodule.c posixmodule.c _struct.c datetimemodule.c _functoolsmodule.c _collectionsmodule.c itertoolsmodule.c resource.c signalmodule.c selectmodule.c fcntlmodule.c timemodule.c arraymodule.c zlibmodule.c _codecsmodule.c socketmodule.c unicodedata.c _weakref.c cStringIO.c bufferedio.c bytesio.c fileio.c iobase.c _iomodule.c stringio.c textio.c zipimport.c _csv.c
_ssl.c
)
# compile specified files in from_cpython/Objects
file
(
GLOB_RECURSE STDOBJECT_SRCS Objects structseq.c capsule.c stringobject.c exceptions.c unicodeobject.c unicodectype.c bytearrayobject.c bytes_methods.c weakrefobject.c memoryobject.c iterobject.c
)
...
...
from_cpython/Modules/_ssl.c
View file @
012b3e89
...
...
@@ -19,7 +19,8 @@
#ifdef WITH_THREAD
#include "pythread.h"
// Pyston change: changed to use our internal API
/*
#define PySSL_BEGIN_ALLOW_THREADS { \
PyThreadState *_save = NULL; \
if (_ssl_locks_count>0) {_save = PyEval_SaveThread();}
...
...
@@ -27,6 +28,13 @@
#define PySSL_UNBLOCK_THREADS if (_ssl_locks_count>0){_save = PyEval_SaveThread()};
#define PySSL_END_ALLOW_THREADS if (_ssl_locks_count>0){PyEval_RestoreThread(_save);} \
}
*/
#define PySSL_BEGIN_ALLOW_THREADS { \
if (_ssl_locks_count>0) beginAllowThreads();
#define PySSL_BLOCK_THREADS if (_ssl_locks_count>0) endAllowThreads();
#define PySSL_UNBLOCK_THREADS if (_ssl_locks_count>0) beginAllowThreads();
#define PySSL_END_ALLOW_THREADS if (_ssl_locks_count>0) endAllowThreads(); \
}
#else
/* no WITH_THREAD */
...
...
@@ -1745,6 +1753,9 @@ init_ssl(void)
Py_TYPE
(
&
PySSL_Type
)
=
&
PyType_Type
;
// Pyston change
PyType_Ready
(
&
PySSL_Type
);
m
=
Py_InitModule3
(
"_ssl"
,
PySSL_methods
,
module_doc
);
if
(
m
==
NULL
)
return
;
...
...
from_cpython/Objects/capsule.c
View file @
012b3e89
...
...
@@ -196,9 +196,6 @@ PyCapsule_SetContext(PyObject *o, void *context)
void
*
PyCapsule_Import
(
const
char
*
name
,
int
no_block
)
{
// Pyston change:
Py_FatalError
(
"Pyston TODO: implement this"
);
#if 0
PyObject
*
object
=
NULL
;
void
*
return_value
=
NULL
;
char
*
trace
;
...
...
@@ -255,7 +252,6 @@ EXIT:
PyMem_FREE
(
name_dup
);
}
return
return_value
;
#endif
}
...
...
src/capi/modsupport.cpp
View file @
012b3e89
...
...
@@ -107,6 +107,15 @@ static PyObject* do_mkvalue(const char** p_format, va_list* p_va, int flags) noe
case
'H'
:
return
PyInt_FromLong
((
long
)
va_arg
(
*
p_va
,
unsigned
int
));
case
'I'
:
{
unsigned
int
n
;
n
=
va_arg
(
*
p_va
,
unsigned
int
);
if
(
n
>
(
unsigned
long
)
PyInt_GetMax
())
return
PyLong_FromUnsignedLong
((
unsigned
long
)
n
);
else
return
PyInt_FromLong
(
n
);
}
case
'n'
:
#if SIZEOF_SIZE_T != SIZEOF_LONG
return
PyInt_FromSsize_t
(
va_arg
(
*
p_va
,
Py_ssize_t
));
...
...
src/codegen/unwinding.cpp
View file @
012b3e89
...
...
@@ -461,8 +461,8 @@ PythonFrameIterator::Manager unwindPythonFrames() {
static
std
::
unique_ptr
<
PythonFrameIterator
>
getTopPythonFrame
()
{
std
::
unique_ptr
<
PythonFrameIterator
>
fr
=
PythonFrameIterator
::
begin
();
RELEASE_ASSERT
(
fr
!=
PythonFrameIterator
::
end
(),
"no valid python frames??"
);
if
(
fr
==
PythonFrameIterator
::
end
())
return
std
::
unique_ptr
<
PythonFrameIterator
>
();
return
fr
;
}
...
...
@@ -533,12 +533,16 @@ ExcInfo* getFrameExcInfo() {
}
CompiledFunction
*
getTopCompiledFunction
()
{
auto
rtn
=
getTopPythonFrame
();
if
(
!
rtn
)
return
NULL
;
return
getTopPythonFrame
()
->
getCF
();
}
BoxedModule
*
getCurrentModule
()
{
CompiledFunction
*
compiledFunction
=
getTopCompiledFunction
();
assert
(
compiledFunction
);
if
(
!
compiledFunction
)
return
NULL
;
return
compiledFunction
->
clfunc
->
source
->
parent_module
;
}
...
...
src/runtime/int.cpp
View file @
012b3e89
...
...
@@ -32,6 +32,10 @@
namespace
pyston
{
extern
"C"
long
PyInt_GetMax
()
noexcept
{
return
LONG_MAX
;
/* To initialize sys.maxint */
}
extern
"C"
unsigned
long
PyInt_AsUnsignedLongMask
(
PyObject
*
op
)
noexcept
{
if
(
op
&&
PyInt_Check
(
op
))
return
PyInt_AS_LONG
((
PyIntObject
*
)
op
);
...
...
src/runtime/types.cpp
View file @
012b3e89
...
...
@@ -72,6 +72,7 @@ extern "C" void initcStringIO();
extern
"C"
void
init_io
();
extern
"C"
void
initzipimport
();
extern
"C"
void
init_csv
();
extern
"C"
void
init_ssl
();
namespace
pyston
{
...
...
@@ -1554,6 +1555,7 @@ void setupRuntime() {
init_io
();
initzipimport
();
init_csv
();
init_ssl
();
// some additional setup to ensure weakrefs participate in our GC
BoxedClass
*
weakref_ref_cls
=
&
_PyWeakref_RefType
;
...
...
test/tests/ssl_test.py
0 → 100644
View file @
012b3e89
import
ssl
import
socket
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
ssl_sock
=
ssl
.
wrap_socket
(
s
)
if
0
:
ssl_sock
.
connect
((
"google.com"
,
443
))
print
ssl_sock
.
getpeercert
()
ssl_sock
.
write
(
"GET /
\
n
"
)
print
ssl_sock
.
read
()
print
ssl_sock
.
getsockname
()
ssl_sock
.
close
()
test/unittests/CMakeLists.txt
View file @
012b3e89
...
...
@@ -9,7 +9,7 @@ add_custom_target(unittests)
macro
(
add_unittest unittest
)
add_executable
(
${
unittest
}
_unittest EXCLUDE_FROM_ALL
${
unittest
}
.cpp $<TARGET_OBJECTS:PYSTON_OBJECTS> $<TARGET_OBJECTS:FROM_CPYTHON>
)
target_link_libraries
(
${
unittest
}
_unittest stdlib gmp readline pypa double-conversion unwind gtest gtest_main
${
LLVM_LIBS
}
${
LIBLZMA_LIBRARIES
}
)
target_link_libraries
(
${
unittest
}
_unittest stdlib gmp
ssl crypto
readline pypa double-conversion unwind gtest gtest_main
${
LLVM_LIBS
}
${
LIBLZMA_LIBRARIES
}
)
add_dependencies
(
${
unittest
}
_unittest gtest gtest_main
)
add_dependencies
(
unittests
${
unittest
}
_unittest
)
endmacro
()
...
...
tools/CMakeLists.txt
View file @
012b3e89
...
...
@@ -9,5 +9,5 @@ add_dependencies(publicize ${LLVM_LIBS_EXTRA})
include_directories
(
${
CMAKE_SOURCE_DIR
}
/src
)
add_executable
(
astprint EXCLUDE_FROM_ALL astprint.cpp $<TARGET_OBJECTS:PYSTON_OBJECTS> $<TARGET_OBJECTS:FROM_CPYTHON>
)
target_link_libraries
(
astprint stdlib gmp readline pypa double-conversion unwind
${
LLVM_LIBS
}
${
LIBLZMA_LIBRARIES
}
)
target_link_libraries
(
astprint stdlib gmp
ssl crypto
readline pypa double-conversion unwind
${
LLVM_LIBS
}
${
LIBLZMA_LIBRARIES
}
)
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