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
598da395
Commit
598da395
authored
Jun 05, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #581 from undingen/deco_whitespace
Add the _elementtree and update libpypa
parents
abd3c8e1
ca9d59b7
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
89 additions
and
12 deletions
+89
-12
Makefile
Makefile
+2
-1
from_cpython/CMakeLists.txt
from_cpython/CMakeLists.txt
+5
-1
from_cpython/Modules/_elementtree.c
from_cpython/Modules/_elementtree.c
+13
-2
from_cpython/setup.py
from_cpython/setup.py
+14
-1
libpypa
libpypa
+1
-1
src/gc/heap.h
src/gc/heap.h
+3
-3
src/runtime/long.cpp
src/runtime/long.cpp
+4
-0
test/tests/decorator_whitespace.py
test/tests/decorator_whitespace.py
+0
-2
test/tests/dict.py
test/tests/dict.py
+1
-1
test/tests/elementree_test.py
test/tests/elementree_test.py
+46
-0
No files found.
Makefile
View file @
598da395
...
...
@@ -1208,7 +1208,8 @@ SHAREDMODS_SRCS := \
expat/xmltok.c
\
expat/xmltok_impl.c
\
expat/xmltok_ns.c
\
pyexpat.c
pyexpat.c
\
_elementtree.c
SHAREDMODS_SRCS
:=
$
(
SHAREDMODS_SRCS:%
=
from_cpython/Modules/%
)
SHAREDMODS_OBJS
:=
$
(
SHAREDMODS_NAMES:%
=
lib_pyston/%.pyston.so
)
...
...
from_cpython/CMakeLists.txt
View file @
598da395
...
...
@@ -112,7 +112,10 @@ file(GLOB_RECURSE STDPARSER_SRCS Parser
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-Wno-missing-field-initializers -Wno-tautological-compare -Wno-type-limits -Wno-unused-result -Wno-strict-aliasing"
)
add_library
(
FROM_CPYTHON OBJECT
${
STDMODULE_SRCS
}
${
STDOBJECT_SRCS
}
${
STDPYTHON_SRCS
}
${
STDPARSER_SRCS
}
)
add_custom_command
(
OUTPUT
${
CMAKE_BINARY_DIR
}
/lib_pyston/_multiprocessing.pyston.so
${
CMAKE_BINARY_DIR
}
/lib_pyston/pyexpat.pyston.so
add_custom_command
(
OUTPUT
${
CMAKE_BINARY_DIR
}
/lib_pyston/_multiprocessing.pyston.so
${
CMAKE_BINARY_DIR
}
/lib_pyston/pyexpat.pyston.so
${
CMAKE_BINARY_DIR
}
/lib_pyston/_elementtree.pyston.so
COMMAND
${
CMAKE_BINARY_DIR
}
/pyston setup.py build --build-lib
${
CMAKE_BINARY_DIR
}
/lib_pyston
DEPENDS
pyston
...
...
@@ -127,5 +130,6 @@ add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/lib_pyston/_multiprocessing.pyston
Modules/expat/xmltok_impl.c
Modules/expat/xmltok_ns.c
Modules/pyexpat.c
Modules/_elementtree.c
WORKING_DIRECTORY
${
CMAKE_CURRENT_SOURCE_DIR
}
)
add_custom_target
(
sharedmods DEPENDS
${
CMAKE_BINARY_DIR
}
/lib_pyston/_multiprocessing.pyston.so
)
from_cpython/Modules/_elementtree.c
View file @
598da395
...
...
@@ -1791,7 +1791,8 @@ treebuilder_handle_data(TreeBuilderObject* self, PyObject* data)
Py_INCREF
(
data
);
self
->
data
=
data
;
}
else
{
/* more than one item; use a list to collect items */
if
(
PyString_CheckExact
(
self
->
data
)
&&
Py_REFCNT
(
self
->
data
)
==
1
&&
// Pyston change: Py_REFCNT(self->data) -> 2
if
(
PyString_CheckExact
(
self
->
data
)
&&
/*Py_REFCNT(self->data)*/
2
==
1
&&
PyString_CheckExact
(
data
)
&&
PyString_GET_SIZE
(
data
)
==
1
)
{
/* expat often generates single character data sections; handle
the most common case by resizing the existing string... */
...
...
@@ -2878,6 +2879,16 @@ init_elementtree(void)
Py_TYPE
(
&
XMLParser_Type
)
=
&
PyType_Type
;
#endif
// Pyston change: register types
if
(
PyType_Ready
(
&
Element_Type
)
<
0
)
return
;
if
(
PyType_Ready
(
&
TreeBuilder_Type
)
<
0
)
return
;
#if defined(USE_EXPAT)
if
(
PyType_Ready
(
&
XMLParser_Type
)
<
0
)
return
;
#endif
m
=
Py_InitModule
(
"_elementtree"
,
_functions
);
if
(
!
m
)
return
;
...
...
from_cpython/setup.py
View file @
598da395
...
...
@@ -40,8 +40,21 @@ def pyexpat_ext():
depends
=
expat_depends
,
)
def
elementtree_ext
():
# elementtree depends on expat
pyexpat
=
pyexpat_ext
()
define_macros
=
pyexpat
.
define_macros
+
[(
'USE_PYEXPAT_CAPI'
,
None
),]
return
Extension
(
'_elementtree'
,
define_macros
=
define_macros
,
include_dirs
=
pyexpat
.
include_dirs
,
libraries
=
pyexpat
.
libraries
,
sources
=
[
relpath
(
'Modules/_elementtree.c'
)],
depends
=
pyexpat
.
depends
,
)
setup
(
name
=
"Pyston"
,
version
=
"1.0"
,
description
=
"Pyston shared modules"
,
ext_modules
=
[
multiprocessing_ext
(),
pyexpat_ext
()]
ext_modules
=
[
multiprocessing_ext
(),
pyexpat_ext
()
,
elementtree_ext
()
]
)
libpypa
@
89f615a7
Subproject commit
7f14a66674f6d65c717199512e7ca705110c8da1
Subproject commit
89f615a75fbc86d0dda71b407cb704077749c2cc
src/gc/heap.h
View file @
598da395
...
...
@@ -27,9 +27,9 @@
namespace
pyston
{
namespace
gc
{
extern
"C"
inline
void
*
gc_alloc
(
size_t
bytes
,
GCKind
kind_id
)
__attribute__
((
visibility
(
"default"
)));
extern
"C"
inline
void
*
gc_realloc
(
void
*
ptr
,
size_t
bytes
)
__attribute__
((
visibility
(
"default"
)));
extern
"C"
inline
void
gc_free
(
void
*
ptr
)
__attribute__
((
visibility
(
"default"
)));
extern
"C"
void
*
gc_alloc
(
size_t
bytes
,
GCKind
kind_id
)
__attribute__
((
visibility
(
"default"
)));
extern
"C"
void
*
gc_realloc
(
void
*
ptr
,
size_t
bytes
)
__attribute__
((
visibility
(
"default"
)));
extern
"C"
void
gc_free
(
void
*
ptr
)
__attribute__
((
visibility
(
"default"
)));
}
template
<
class
T
>
class
StlCompatAllocator
{
...
...
src/runtime/long.cpp
View file @
598da395
...
...
@@ -1241,6 +1241,10 @@ Box* longHash(BoxedLong* self) {
raiseExcHelper
(
TypeError
,
"descriptor '__pow__' requires a 'long' object but received a '%s'"
,
getTypeName
(
self
));
// If the long fits into an int we have to return the same hash in order that we can find the value in a dict.
if
(
mpz_fits_slong_p
(
self
->
n
))
return
boxInt
(
mpz_get_si
(
self
->
n
));
// Not sure if this is a good hash function or not;
// simple, but only includes top bits:
union
{
...
...
test/tests/decorator_whitespace.py
View file @
598da395
# fail-if: '-x' not in EXTRA_JIT_ARGS
def
dec
(
f
):
return
f
...
...
test/tests/dict.py
View file @
598da395
d
=
{
2
:
2
}
d
[
1
]
=
1
print
d
print
d
[
1
]
print
d
[
1
]
,
d
[
1L
],
d
[
1.0
],
d
[
True
]
d
=
{}
for
i
in
xrange
(
10
):
...
...
test/tests/elementree_test.py
0 → 100644
View file @
598da395
# test is based on the cpython ElementTree doc
def
test
(
ET
):
xml_str
=
"""<?xml version="1.0"?>
<data>
<country name="Liechtenstein">
<rank>1</rank>
<year>2008</year>
<gdppc>141100</gdppc>
<neighbor name="Austria" direction="E"/>
<neighbor name="Switzerland" direction="W"/>
</country>
<country name="Singapore">
<rank>4</rank>
<year>2011</year>
<gdppc>59900</gdppc>
<neighbor name="Malaysia" direction="N"/>
</country>
<country name="Panama">
<rank>68</rank>
<year>2011</year>
<gdppc>13600</gdppc>
<neighbor name="Costa Rica" direction="W"/>
<neighbor name="Colombia" direction="E"/>
</country>
</data>
"""
root
=
ET
.
fromstring
(
xml_str
)
for
child
in
root
:
print
child
.
tag
,
child
.
attrib
print
root
[
0
][
1
].
text
for
neighbor
in
root
.
iter
(
'neighbor'
):
print
sorted
(
neighbor
.
attrib
.
items
())
for
country
in
root
.
findall
(
'country'
):
rank
=
country
.
find
(
'rank'
).
text
name
=
country
.
get
(
'name'
)
print
name
,
rank
import
xml.etree.ElementTree
as
Python_ET
import
xml.etree.cElementTree
as
CAPI_ET
test
(
Python_ET
)
test
(
CAPI_ET
)
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