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
3e360e58
Commit
3e360e58
authored
Aug 18, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #709 from toshok/mercurial-fixes
Mercurial fixes
parents
6fa67672
be56b96d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
10 deletions
+21
-10
src/runtime/file.cpp
src/runtime/file.cpp
+4
-10
src/runtime/set.cpp
src/runtime/set.cpp
+9
-0
test/tests/file_writing.py
test/tests/file_writing.py
+2
-0
test/tests/set.py
test/tests/set.py
+6
-0
No files found.
src/runtime/file.cpp
View file @
3e360e58
...
...
@@ -479,17 +479,11 @@ static PyObject* file_write(BoxedFile* f, Box* arg) noexcept {
if
(
!
f
->
writable
)
return
err_mode
(
"writing"
);
if
(
f
->
f_binary
)
{
// In CPython, this branch calls PyArg_ParseTuple for all types, but we never created
// the "args" tuple so we have to do some of the work that ParseTuple does.
// Mostly it's easy since we've already unpacked the args, but there is some unicode-specific
// code in it that is better not to duplicate.
// So, if it's unicode, just make the tuple for now and send it through PyArg_ParseTuple.
if
(
PyUnicode_Check
(
arg
))
{
if
(
!
PyArg_ParseTuple
(
BoxedTuple
::
create
({
arg
}),
"s*"
,
&
pbuf
))
return
NULL
;
}
else
if
(
PyObject_GetBuffer
(
arg
,
&
pbuf
,
0
))
// NOTE: this call will create a new tuple every time we write to a binary file. if/when this becomes hot or
// creates too much GC pressure, we can fix it by adding a Pyston specific versino of PyArg_ParseTuple that
// (instead of taking a tuple) takes length + Box**. Then we'd call that directly here (passing "1, &arg").
if
(
!
PyArg_ParseTuple
(
BoxedTuple
::
create
({
arg
}),
"s*"
,
&
pbuf
))
return
NULL
;
s
=
(
const
char
*
)
pbuf
.
buf
;
n
=
pbuf
.
len
;
}
else
{
...
...
src/runtime/set.cpp
View file @
3e360e58
...
...
@@ -426,6 +426,12 @@ static Box* setIntersection(BoxedSet* self, BoxedTuple* args) {
return
rtn
;
}
static
Box
*
setIntersectionUpdate
(
BoxedSet
*
self
,
BoxedTuple
*
args
)
{
Box
*
tmp
=
setIntersection
(
self
,
args
);
std
::
swap
(
self
->
s
,
((
BoxedSet
*
)
tmp
)
->
s
);
return
None
;
}
Box
*
setCopy
(
BoxedSet
*
self
)
{
RELEASE_ASSERT
(
PyAnySet_Check
(
self
),
""
);
...
...
@@ -598,6 +604,9 @@ void setupSet() {
set_cls
->
giveAttr
(
"intersection"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
setIntersection
,
UNKNOWN
,
1
,
0
,
true
,
false
)));
frozenset_cls
->
giveAttr
(
"intersection"
,
set_cls
->
getattr
(
internStringMortal
(
"intersection"
)));
set_cls
->
giveAttr
(
"intersection_update"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
setIntersectionUpdate
,
UNKNOWN
,
1
,
0
,
true
,
false
)));
frozenset_cls
->
giveAttr
(
"intersection_update"
,
set_cls
->
getattr
(
internStringMortal
(
"intersection_update"
)));
set_cls
->
giveAttr
(
"difference"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
setDifference
,
UNKNOWN
,
1
,
0
,
true
,
false
)));
frozenset_cls
->
giveAttr
(
"difference"
,
set_cls
->
getattr
(
internStringMortal
(
"difference"
)));
set_cls
->
giveAttr
(
"difference_update"
,
...
...
test/tests/file_writing.py
View file @
3e360e58
import
os
import
tempfile
import
array
fd
,
fn
=
tempfile
.
mkstemp
()
with
open
(
fn
,
"wb"
)
as
f
:
f
.
write
(
"hello world!
\
n
"
)
f
.
write
(
u"hello world2"
)
f
.
write
(
array
.
array
(
'c'
,
'hello world'
))
with
open
(
fn
)
as
f
:
print
repr
(
f
.
read
())
...
...
test/tests/set.py
View file @
3e360e58
...
...
@@ -133,3 +133,9 @@ for s1 in set(range(5)), frozenset(range(5)):
f
=
float
(
'nan'
)
s
=
set
([
f
])
print
f
in
s
,
f
==
list
(
s
)[
0
]
s1
=
set
([
3
,
5
])
s2
=
set
([
1
,
5
])
s1
.
intersection_update
(
s2
)
print
sorted
(
s1
)
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