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
6876768d
Commit
6876768d
authored
Feb 24, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
import _socket
"import socket" does not quite work yet
parent
6dab00bb
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
33 additions
and
13 deletions
+33
-13
Makefile
Makefile
+1
-1
from_cpython/CMakeLists.txt
from_cpython/CMakeLists.txt
+1
-1
from_cpython/Include/pyconfig.h
from_cpython/Include/pyconfig.h
+3
-0
from_cpython/Include/pyport.h
from_cpython/Include/pyport.h
+2
-0
from_cpython/Modules/socketmodule.c
from_cpython/Modules/socketmodule.c
+3
-0
src/core/types.h
src/core/types.h
+2
-1
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+13
-8
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+5
-2
src/runtime/types.cpp
src/runtime/types.cpp
+2
-0
test/tests/socket_test.py
test/tests/socket_test.py
+1
-0
No files found.
Makefile
View file @
6876768d
...
@@ -291,7 +291,7 @@ STDLIB_OBJS := stdlib.bc.o stdlib.stripped.bc.o
...
@@ -291,7 +291,7 @@ STDLIB_OBJS := stdlib.bc.o stdlib.stripped.bc.o
STDLIB_RELEASE_OBJS
:=
stdlib.release.bc.o
STDLIB_RELEASE_OBJS
:=
stdlib.release.bc.o
ASM_SRCS
:=
$(
wildcard
src/runtime/
*
.S
)
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
$(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
$(EXTRA_STDMODULE_SRCS)
STDOBJECT_SRCS
:=
structseq.c capsule.c stringobject.c
$(EXTRA_STDOBJECT_SRCS)
STDOBJECT_SRCS
:=
structseq.c capsule.c stringobject.c
$(EXTRA_STDOBJECT_SRCS)
STDPYTHON_SRCS
:=
pyctype.c getargs.c formatter_string.c pystrtod.c dtoa.c
$(EXTRA_STDPYTHON_SRCS)
STDPYTHON_SRCS
:=
pyctype.c getargs.c formatter_string.c pystrtod.c dtoa.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_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 @
6876768d
...
@@ -15,7 +15,7 @@ endforeach(STDLIB_FILE)
...
@@ -15,7 +15,7 @@ endforeach(STDLIB_FILE)
add_custom_target
(
copy_stdlib ALL DEPENDS
${
STDLIB_TARGETS
}
)
add_custom_target
(
copy_stdlib ALL DEPENDS
${
STDLIB_TARGETS
}
)
# compile specified files in from_cpython/Modules
# 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
)
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
)
# compile specified files in from_cpython/Objects
# compile specified files in from_cpython/Objects
file
(
GLOB_RECURSE STDOBJECT_SRCS Objects structseq.c capsule.c stringobject.c
)
file
(
GLOB_RECURSE STDOBJECT_SRCS Objects structseq.c capsule.c stringobject.c
)
...
...
from_cpython/Include/pyconfig.h
View file @
6876768d
...
@@ -49,6 +49,9 @@
...
@@ -49,6 +49,9 @@
#define HAVE_SELECT 1
#define HAVE_SELECT 1
#define HAVE_ALARM 1
#define HAVE_ALARM 1
#define HAVE_SYMLINK 1
#define HAVE_SYMLINK 1
#define HAVE_ADDRINFO 1
#define HAVE_SOCKADDR_STORAGE 1
#define HAVE_SOCKETPAIR 1
#define PY_FORMAT_LONG_LONG "ll"
#define PY_FORMAT_LONG_LONG "ll"
#define PY_FORMAT_SIZE_T "z"
#define PY_FORMAT_SIZE_T "z"
...
...
from_cpython/Include/pyport.h
View file @
6876768d
...
@@ -12,6 +12,8 @@
...
@@ -12,6 +12,8 @@
#define PYSTON_NOEXCEPT
#define PYSTON_NOEXCEPT
#endif
#endif
#define Py_PROTO(x) x
// Pyston change: these are just hard-coded for now:
// Pyston change: these are just hard-coded for now:
typedef
ssize_t
Py_ssize_t
;
typedef
ssize_t
Py_ssize_t
;
#define Py_FORMAT_PARSETUPLE(func,p1,p2)
#define Py_FORMAT_PARSETUPLE(func,p1,p2)
...
...
from_cpython/Modules/socketmodule.c
View file @
6876768d
...
@@ -4578,6 +4578,9 @@ init_socket(void)
...
@@ -4578,6 +4578,9 @@ init_socket(void)
if
(
!
os_init
())
if
(
!
os_init
())
return
;
return
;
// Pyston change: we require calling PyType_Ready for now:
PyType_Ready
(
&
sock_type
);
Py_TYPE
(
&
sock_type
)
=
&
PyType_Type
;
Py_TYPE
(
&
sock_type
)
=
&
PyType_Type
;
m
=
Py_InitModule3
(
PySocket_MODULE_NAME
,
m
=
Py_InitModule3
(
PySocket_MODULE_NAME
,
socket_methods
,
socket_methods
,
...
...
src/core/types.h
View file @
6876768d
...
@@ -439,12 +439,13 @@ public:
...
@@ -439,12 +439,13 @@ public:
void
setattr
(
const
std
::
string
&
attr
,
Box
*
val
,
SetattrRewriteArgs
*
rewrite_args
);
void
setattr
(
const
std
::
string
&
attr
,
Box
*
val
,
SetattrRewriteArgs
*
rewrite_args
);
void
giveAttr
(
const
std
::
string
&
attr
,
Box
*
val
)
{
void
giveAttr
(
const
std
::
string
&
attr
,
Box
*
val
)
{
assert
(
this
->
getattr
(
attr
)
==
NULL
);
assert
(
!
this
->
hasattr
(
attr
)
);
this
->
setattr
(
attr
,
val
,
NULL
);
this
->
setattr
(
attr
,
val
,
NULL
);
}
}
Box
*
getattr
(
const
std
::
string
&
attr
,
GetattrRewriteArgs
*
rewrite_args
);
Box
*
getattr
(
const
std
::
string
&
attr
,
GetattrRewriteArgs
*
rewrite_args
);
Box
*
getattr
(
const
std
::
string
&
attr
)
{
return
getattr
(
attr
,
NULL
);
}
Box
*
getattr
(
const
std
::
string
&
attr
)
{
return
getattr
(
attr
,
NULL
);
}
bool
hasattr
(
const
std
::
string
&
attr
)
{
return
getattr
(
attr
)
!=
NULL
;
}
void
delattr
(
const
std
::
string
&
attr
,
DelattrRewriteArgs
*
rewrite_args
);
void
delattr
(
const
std
::
string
&
attr
,
DelattrRewriteArgs
*
rewrite_args
);
Box
*
reprIC
();
Box
*
reprIC
();
...
...
src/runtime/builtin_modules/builtins.cpp
View file @
6876768d
...
@@ -674,8 +674,10 @@ static BoxedClass* makeBuiltinException(BoxedClass* base, const char* name, int
...
@@ -674,8 +674,10 @@ static BoxedClass* makeBuiltinException(BoxedClass* base, const char* name, int
}
}
extern
"C"
PyObject
*
PyErr_NewException
(
char
*
name
,
PyObject
*
_base
,
PyObject
*
dict
)
noexcept
{
extern
"C"
PyObject
*
PyErr_NewException
(
char
*
name
,
PyObject
*
_base
,
PyObject
*
dict
)
noexcept
{
RELEASE_ASSERT
(
_base
==
NULL
,
"unimplemented"
);
if
(
_base
==
NULL
)
RELEASE_ASSERT
(
dict
==
NULL
,
"unimplemented"
);
_base
=
Exception
;
if
(
dict
==
NULL
)
dict
=
new
BoxedDict
();
try
{
try
{
char
*
dot_pos
=
strchr
(
name
,
'.'
);
char
*
dot_pos
=
strchr
(
name
,
'.'
);
...
@@ -683,13 +685,16 @@ extern "C" PyObject* PyErr_NewException(char* name, PyObject* _base, PyObject* d
...
@@ -683,13 +685,16 @@ extern "C" PyObject* PyErr_NewException(char* name, PyObject* _base, PyObject* d
int
n
=
strlen
(
name
);
int
n
=
strlen
(
name
);
BoxedString
*
boxedName
=
boxStrConstantSize
(
dot_pos
+
1
,
n
-
(
dot_pos
-
name
)
-
1
);
BoxedString
*
boxedName
=
boxStrConstantSize
(
dot_pos
+
1
,
n
-
(
dot_pos
-
name
)
-
1
);
BoxedClass
*
base
=
Exception
;
// It can also be a tuple of bases
BoxedClass
*
cls
RELEASE_ASSERT
(
isSubclass
(
_base
->
cls
,
type_cls
),
""
);
=
new
BoxedHeapClass
(
base
,
NULL
,
offsetof
(
BoxedException
,
attrs
),
sizeof
(
BoxedException
),
true
,
boxedNam
e
);
BoxedClass
*
base
=
static_cast
<
BoxedClass
*>
(
_bas
e
);
cls
->
giveAttr
(
"__module__"
,
boxStrConstantSize
(
name
,
dot_pos
-
name
));
if
(
PyDict_GetItemString
(
dict
,
"__module__"
)
==
NULL
)
{
// TODO Not sure if this should be called here
PyDict_SetItemString
(
dict
,
"__module__"
,
boxStrConstantSize
(
name
,
dot_pos
-
name
));
fixup_slot_dispatchers
(
cls
);
}
checkAndThrowCAPIException
();
Box
*
cls
=
runtimeCall
(
type_cls
,
ArgPassSpec
(
3
),
boxedName
,
new
BoxedTuple
({
base
}),
dict
,
NULL
,
NULL
);
return
cls
;
return
cls
;
}
catch
(
ExcInfo
e
)
{
}
catch
(
ExcInfo
e
)
{
abort
();
abort
();
...
...
src/runtime/objmodel.cpp
View file @
6876768d
...
@@ -3543,14 +3543,17 @@ Box* typeNew(Box* _cls, Box* arg1, Box* arg2, Box** _args) {
...
@@ -3543,14 +3543,17 @@ Box* typeNew(Box* _cls, Box* arg1, Box* arg2, Box** _args) {
}
}
made
->
tp_dictoffset
=
base
->
tp_dictoffset
;
made
->
tp_dictoffset
=
base
->
tp_dictoffset
;
made
->
giveAttr
(
"__module__"
,
boxString
(
getCurrentModule
()
->
name
()));
made
->
giveAttr
(
"__doc__"
,
None
);
for
(
const
auto
&
p
:
attr_dict
->
d
)
{
for
(
const
auto
&
p
:
attr_dict
->
d
)
{
assert
(
p
.
first
->
cls
==
str_cls
);
assert
(
p
.
first
->
cls
==
str_cls
);
made
->
setattr
(
static_cast
<
BoxedString
*>
(
p
.
first
)
->
s
,
p
.
second
,
NULL
);
made
->
setattr
(
static_cast
<
BoxedString
*>
(
p
.
first
)
->
s
,
p
.
second
,
NULL
);
}
}
if
(
!
made
->
hasattr
(
"__module__"
))
made
->
giveAttr
(
"__module__"
,
boxString
(
getCurrentModule
()
->
name
()));
if
(
!
made
->
hasattr
(
"__doc__"
))
made
->
giveAttr
(
"__doc__"
,
None
);
made
->
tp_new
=
base
->
tp_new
;
made
->
tp_new
=
base
->
tp_new
;
PystonType_Ready
(
made
);
PystonType_Ready
(
made
);
...
...
src/runtime/types.cpp
View file @
6876768d
...
@@ -63,6 +63,7 @@ extern "C" void inittime();
...
@@ -63,6 +63,7 @@ extern "C" void inittime();
extern
"C"
void
initarray
();
extern
"C"
void
initarray
();
extern
"C"
void
initzlib
();
extern
"C"
void
initzlib
();
extern
"C"
void
init_codecs
();
extern
"C"
void
init_codecs
();
extern
"C"
void
init_socket
();
namespace
pyston
{
namespace
pyston
{
...
@@ -1371,6 +1372,7 @@ void setupRuntime() {
...
@@ -1371,6 +1372,7 @@ void setupRuntime() {
initarray
();
initarray
();
initzlib
();
initzlib
();
init_codecs
();
init_codecs
();
init_socket
();
setupSysEnd
();
setupSysEnd
();
...
...
test/tests/socket_test.py
0 → 100644
View file @
6876768d
import
socket
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