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
9cd8624a
Commit
9cd8624a
authored
Feb 24, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'socket'
parents
6dab00bb
96637e72
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
78 additions
and
16 deletions
+78
-16
Makefile
Makefile
+1
-1
from_cpython/CMakeLists.txt
from_cpython/CMakeLists.txt
+1
-1
from_cpython/Include/pyconfig.h
from_cpython/Include/pyconfig.h
+4
-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/capi/typeobject.cpp
src/capi/typeobject.cpp
+8
-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/capi.cpp
src/runtime/capi.cpp
+9
-0
src/runtime/descr.cpp
src/runtime/descr.cpp
+4
-3
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+5
-2
src/runtime/types.cpp
src/runtime/types.cpp
+21
-0
test/tests/socket_test.py
test/tests/socket_test.py
+5
-0
No files found.
Makefile
View file @
9cd8624a
...
...
@@ -291,7 +291,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
$(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)
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/CMakeLists.txt
View file @
9cd8624a
...
...
@@ -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
)
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
file
(
GLOB_RECURSE STDOBJECT_SRCS Objects structseq.c capsule.c stringobject.c
)
...
...
from_cpython/Include/pyconfig.h
View file @
9cd8624a
...
...
@@ -49,6 +49,10 @@
#define HAVE_SELECT 1
#define HAVE_ALARM 1
#define HAVE_SYMLINK 1
#define HAVE_ADDRINFO 1
#define HAVE_SOCKADDR_STORAGE 1
#define HAVE_SOCKETPAIR 1
#define HAVE_GETPEERNAME 1
#define PY_FORMAT_LONG_LONG "ll"
#define PY_FORMAT_SIZE_T "z"
...
...
from_cpython/Include/pyport.h
View file @
9cd8624a
...
...
@@ -12,6 +12,8 @@
#define PYSTON_NOEXCEPT
#endif
#define Py_PROTO(x) x
// Pyston change: these are just hard-coded for now:
typedef
ssize_t
Py_ssize_t
;
#define Py_FORMAT_PARSETUPLE(func,p1,p2)
...
...
from_cpython/Modules/socketmodule.c
View file @
9cd8624a
...
...
@@ -4578,6 +4578,9 @@ init_socket(void)
if
(
!
os_init
())
return
;
// Pyston change: we require calling PyType_Ready for now:
PyType_Ready
(
&
sock_type
);
Py_TYPE
(
&
sock_type
)
=
&
PyType_Type
;
m
=
Py_InitModule3
(
PySocket_MODULE_NAME
,
socket_methods
,
...
...
src/capi/typeobject.cpp
View file @
9cd8624a
...
...
@@ -1862,6 +1862,14 @@ extern "C" int PyType_Ready(PyTypeObject* cls) noexcept {
PystonType_Ready
(
cls
);
if
(
!
cls
->
hasattr
(
"__doc__"
))
{
if
(
cls
->
tp_doc
)
{
cls
->
giveAttr
(
"__doc__"
,
boxStrConstant
(
cls
->
tp_doc
));
}
else
{
cls
->
giveAttr
(
"__doc__"
,
None
);
}
}
if
(
cls
->
tp_alloc
==
&
PystonType_GenericAlloc
)
cls
->
tp_alloc
=
&
PyType_GenericAlloc
;
...
...
src/core/types.h
View file @
9cd8624a
...
...
@@ -439,12 +439,13 @@ public:
void
setattr
(
const
std
::
string
&
attr
,
Box
*
val
,
SetattrRewriteArgs
*
rewrite_args
);
void
giveAttr
(
const
std
::
string
&
attr
,
Box
*
val
)
{
assert
(
this
->
getattr
(
attr
)
==
NULL
);
assert
(
!
this
->
hasattr
(
attr
)
);
this
->
setattr
(
attr
,
val
,
NULL
);
}
Box
*
getattr
(
const
std
::
string
&
attr
,
GetattrRewriteArgs
*
rewrite_args
);
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
);
Box
*
reprIC
();
...
...
src/runtime/builtin_modules/builtins.cpp
View file @
9cd8624a
...
...
@@ -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
{
RELEASE_ASSERT
(
_base
==
NULL
,
"unimplemented"
);
RELEASE_ASSERT
(
dict
==
NULL
,
"unimplemented"
);
if
(
_base
==
NULL
)
_base
=
Exception
;
if
(
dict
==
NULL
)
dict
=
new
BoxedDict
();
try
{
char
*
dot_pos
=
strchr
(
name
,
'.'
);
...
...
@@ -683,13 +685,16 @@ extern "C" PyObject* PyErr_NewException(char* name, PyObject* _base, PyObject* d
int
n
=
strlen
(
name
);
BoxedString
*
boxedName
=
boxStrConstantSize
(
dot_pos
+
1
,
n
-
(
dot_pos
-
name
)
-
1
);
BoxedClass
*
base
=
Exception
;
BoxedClass
*
cls
=
new
BoxedHeapClass
(
base
,
NULL
,
offsetof
(
BoxedException
,
attrs
),
sizeof
(
BoxedException
),
true
,
boxedNam
e
);
// It can also be a tuple of bases
RELEASE_ASSERT
(
isSubclass
(
_base
->
cls
,
type_cls
),
""
);
BoxedClass
*
base
=
static_cast
<
BoxedClass
*>
(
_bas
e
);
cls
->
giveAttr
(
"__module__"
,
boxStrConstantSize
(
name
,
dot_pos
-
name
));
// TODO Not sure if this should be called here
fixup_slot_dispatchers
(
cls
);
if
(
PyDict_GetItemString
(
dict
,
"__module__"
)
==
NULL
)
{
PyDict_SetItemString
(
dict
,
"__module__"
,
boxStrConstantSize
(
name
,
dot_pos
-
name
));
}
checkAndThrowCAPIException
();
Box
*
cls
=
runtimeCall
(
type_cls
,
ArgPassSpec
(
3
),
boxedName
,
new
BoxedTuple
({
base
}),
dict
,
NULL
,
NULL
);
return
cls
;
}
catch
(
ExcInfo
e
)
{
abort
();
...
...
src/runtime/capi.cpp
View file @
9cd8624a
...
...
@@ -1535,6 +1535,14 @@ Box* BoxedCApiFunction::callInternal(BoxedFunctionBase* func, CallRewriteArgs* r
return
r
;
}
static
Box
*
method_get_doc
(
Box
*
b
,
void
*
)
{
assert
(
b
->
cls
==
method_cls
);
const
char
*
s
=
static_cast
<
BoxedMethodDescriptor
*>
(
b
)
->
method
->
ml_doc
;
if
(
s
)
return
boxStrConstant
(
s
);
return
None
;
}
void
setupCAPI
()
{
capifunc_cls
=
new
BoxedHeapClass
(
object_cls
,
NULL
,
0
,
sizeof
(
BoxedCApiFunction
),
false
,
"capifunc"
);
...
...
@@ -1552,6 +1560,7 @@ void setupCAPI() {
new
BoxedFunction
(
boxRTFunction
((
void
*
)
BoxedMethodDescriptor
::
__get__
,
UNKNOWN
,
3
)));
method_cls
->
giveAttr
(
"__call__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
BoxedMethodDescriptor
::
__call__
,
UNKNOWN
,
2
,
0
,
true
,
true
)));
method_cls
->
giveAttr
(
"__doc__"
,
new
BoxedGetsetDescriptor
(
method_get_doc
,
NULL
,
NULL
));
method_cls
->
freeze
();
wrapperdescr_cls
...
...
src/runtime/descr.cpp
View file @
9cd8624a
...
...
@@ -171,9 +171,10 @@ void setupDescr() {
member_cls
->
giveAttr
(
"__get__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
memberGet
,
UNKNOWN
,
3
)));
member_cls
->
freeze
();
property_cls
->
giveAttr
(
"__init__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
propertyInit
,
UNKNOWN
,
5
,
4
,
false
,
false
),
{
NULL
,
NULL
,
NULL
,
NULL
}));
property_cls
->
giveAttr
(
"__init__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
propertyInit
,
UNKNOWN
,
5
,
4
,
false
,
false
,
ParamNames
({
""
,
"fget"
,
"fset"
,
"fdel"
,
"doc"
},
""
,
""
)),
{
NULL
,
NULL
,
NULL
,
NULL
}));
property_cls
->
giveAttr
(
"__get__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
propertyGet
,
UNKNOWN
,
3
)));
property_cls
->
giveAttr
(
"__set__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
propertySet
,
UNKNOWN
,
3
)));
property_cls
->
giveAttr
(
"__delete__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
propertyDel
,
UNKNOWN
,
2
)));
...
...
src/runtime/objmodel.cpp
View file @
9cd8624a
...
...
@@ -3543,14 +3543,17 @@ Box* typeNew(Box* _cls, Box* arg1, Box* arg2, Box** _args) {
}
made
->
tp_dictoffset
=
base
->
tp_dictoffset
;
made
->
giveAttr
(
"__module__"
,
boxString
(
getCurrentModule
()
->
name
()));
made
->
giveAttr
(
"__doc__"
,
None
);
for
(
const
auto
&
p
:
attr_dict
->
d
)
{
assert
(
p
.
first
->
cls
==
str_cls
);
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
;
PystonType_Ready
(
made
);
...
...
src/runtime/types.cpp
View file @
9cd8624a
...
...
@@ -63,6 +63,7 @@ extern "C" void inittime();
extern
"C"
void
initarray
();
extern
"C"
void
initzlib
();
extern
"C"
void
init_codecs
();
extern
"C"
void
init_socket
();
namespace
pyston
{
...
...
@@ -739,6 +740,23 @@ Box* instancemethodGet(BoxedInstanceMethod* self, Box* obj, Box* type) {
return
new
BoxedInstanceMethod
(
obj
,
self
->
func
);
}
Box
*
instancemethodNew
(
BoxedClass
*
cls
,
Box
*
func
,
Box
*
self
,
Box
**
args
)
{
Box
*
classObj
=
args
[
0
];
if
(
!
PyCallable_Check
(
func
))
{
PyErr_SetString
(
PyExc_TypeError
,
"first argument must be callable"
);
return
NULL
;
}
if
(
self
==
Py_None
)
self
=
NULL
;
if
(
self
==
NULL
&&
classObj
==
NULL
)
{
PyErr_SetString
(
PyExc_TypeError
,
"unbound methods must have non-NULL im_class"
);
return
NULL
;
}
return
new
BoxedInstanceMethod
(
self
,
func
);
}
Box
*
instancemethodRepr
(
BoxedInstanceMethod
*
self
)
{
if
(
self
->
obj
)
return
boxStrConstant
(
"<bound instancemethod object>"
);
...
...
@@ -1300,6 +1318,8 @@ void setupRuntime() {
new
BoxedGetsetDescriptor
(
builtin_function_or_method_name
,
NULL
,
NULL
));
builtin_function_or_method_cls
->
freeze
();
instancemethod_cls
->
giveAttr
(
"__new__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
instancemethodNew
,
UNKNOWN
,
4
,
1
,
false
,
false
),
{
NULL
}));
instancemethod_cls
->
giveAttr
(
"__repr__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
instancemethodRepr
,
STR
,
1
)));
instancemethod_cls
->
giveAttr
(
"__eq__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
instancemethodEq
,
UNKNOWN
,
2
)));
instancemethod_cls
->
giveAttr
(
...
...
@@ -1371,6 +1391,7 @@ void setupRuntime() {
initarray
();
initzlib
();
init_codecs
();
init_socket
();
setupSysEnd
();
...
...
test/tests/socket_test.py
0 → 100644
View file @
9cd8624a
# allow-warning: converting unicode literal to str
import
socket
s
=
socket
.
socket
()
s
.
close
()
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