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
4818b5a4
Commit
4818b5a4
authored
Oct 15, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #944 from undingen/workarounds
Remove unneeded pyston workarounds + fix misc cpython test errors
parents
464c98e7
fdf7fcca
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
59 additions
and
58 deletions
+59
-58
from_cpython/Lib/StringIO.py
from_cpython/Lib/StringIO.py
+1
-3
from_cpython/Lib/UserDict.py
from_cpython/Lib/UserDict.py
+2
-3
from_cpython/Lib/copy.py
from_cpython/Lib/copy.py
+8
-0
from_cpython/Lib/csv.py
from_cpython/Lib/csv.py
+1
-3
from_cpython/Lib/email/errors.py
from_cpython/Lib/email/errors.py
+2
-5
from_cpython/Lib/encodings/__init__.py
from_cpython/Lib/encodings/__init__.py
+1
-3
from_cpython/Lib/tempfile.py
from_cpython/Lib/tempfile.py
+3
-6
from_cpython/Lib/test/test_array.py
from_cpython/Lib/test/test_array.py
+2
-1
from_cpython/Lib/test/test_urllib2.py
from_cpython/Lib/test/test_urllib2.py
+1
-15
from_cpython/Lib/test/test_urllib2_localnet.py
from_cpython/Lib/test/test_urllib2_localnet.py
+0
-1
from_cpython/Lib/types.py
from_cpython/Lib/types.py
+1
-2
src/runtime/builtin_modules/thread.cpp
src/runtime/builtin_modules/thread.cpp
+11
-0
src/runtime/classobj.cpp
src/runtime/classobj.cpp
+1
-1
src/runtime/classobj.h
src/runtime/classobj.h
+2
-0
src/runtime/list.cpp
src/runtime/list.cpp
+10
-9
test/CPYTHON_TEST_NOTES.md
test/CPYTHON_TEST_NOTES.md
+0
-3
test/tests/copy_test.py
test/tests/copy_test.py
+2
-1
test/tests/list.py
test/tests/list.py
+3
-1
test/tests/thread_test.py
test/tests/thread_test.py
+5
-1
test/tests/weakrefs.py
test/tests/weakrefs.py
+3
-0
No files found.
from_cpython/Lib/StringIO.py
View file @
4818b5a4
...
@@ -39,9 +39,7 @@ def _complain_ifclosed(closed):
...
@@ -39,9 +39,7 @@ def _complain_ifclosed(closed):
if
closed
:
if
closed
:
raise
ValueError
,
"I/O operation on closed file"
raise
ValueError
,
"I/O operation on closed file"
# Pyston change: make this a new style class, looks like we don't support iterating otherwise
class
StringIO
:
# class StringIO:
class
StringIO
(
object
):
"""class StringIO([buffer])
"""class StringIO([buffer])
When a StringIO object is created, it can be initialized to an existing
When a StringIO object is created, it can be initialized to an existing
...
...
from_cpython/Lib/UserDict.py
View file @
4818b5a4
...
@@ -80,9 +80,8 @@ class IterableUserDict(UserDict):
...
@@ -80,9 +80,8 @@ class IterableUserDict(UserDict):
def
__iter__
(
self
):
def
__iter__
(
self
):
return
iter
(
self
.
data
)
return
iter
(
self
.
data
)
# Pyston change: disable using the _abcoll module for now.
import
_abcoll
# import _abcoll
_abcoll
.
MutableMapping
.
register
(
IterableUserDict
)
# _abcoll.MutableMapping.register(IterableUserDict)
class
DictMixin
:
class
DictMixin
:
...
...
from_cpython/Lib/copy.py
View file @
4818b5a4
...
@@ -257,6 +257,14 @@ def _deepcopy_dict(x, memo):
...
@@ -257,6 +257,14 @@ def _deepcopy_dict(x, memo):
y
[
deepcopy
(
key
,
memo
)]
=
deepcopy
(
value
,
memo
)
y
[
deepcopy
(
key
,
memo
)]
=
deepcopy
(
value
,
memo
)
return
y
return
y
d
[
dict
]
=
_deepcopy_dict
d
[
dict
]
=
_deepcopy_dict
# Pyston change: teach copy how to handle attrwrappers
def
get_attrwrapper_type
():
class
C
(
object
):
pass
return
type
(
C
().
__dict__
)
d
[
get_attrwrapper_type
()]
=
_deepcopy_dict
if
PyStringMap
is
not
None
:
if
PyStringMap
is
not
None
:
d
[
PyStringMap
]
=
_deepcopy_dict
d
[
PyStringMap
]
=
_deepcopy_dict
...
...
from_cpython/Lib/csv.py
View file @
4818b5a4
...
@@ -69,9 +69,7 @@ class excel_tab(excel):
...
@@ -69,9 +69,7 @@ class excel_tab(excel):
delimiter
=
'
\
t
'
delimiter
=
'
\
t
'
register_dialect
(
"excel-tab"
,
excel_tab
)
register_dialect
(
"excel-tab"
,
excel_tab
)
# Pyston change: make this a new style class, looks like we don't support iterating otherwise
class
DictReader
:
# class DictReader:
class
DictReader
(
object
):
def
__init__
(
self
,
f
,
fieldnames
=
None
,
restkey
=
None
,
restval
=
None
,
def
__init__
(
self
,
f
,
fieldnames
=
None
,
restkey
=
None
,
restval
=
None
,
dialect
=
"excel"
,
*
args
,
**
kwds
):
dialect
=
"excel"
,
*
args
,
**
kwds
):
self
.
_fieldnames
=
fieldnames
# list of keys for the dict
self
.
_fieldnames
=
fieldnames
# list of keys for the dict
...
...
from_cpython/Lib/email/errors.py
View file @
4818b5a4
...
@@ -22,11 +22,8 @@ class BoundaryError(MessageParseError):
...
@@ -22,11 +22,8 @@ class BoundaryError(MessageParseError):
"""Couldn't find terminating boundary."""
"""Couldn't find terminating boundary."""
# Pyston change: we don't support multiple inheritance yet, so this error class is tricky.
class
MultipartConversionError
(
MessageError
,
TypeError
):
# We could make it so that it only inherits one of the base classes, but I'd rather that
"""Conversion to a multipart is prohibited."""
# anyone who tries to use this error gets a loud error message rather than different behavior.
# class MultipartConversionError(MessageError, TypeError):
# """Conversion to a multipart is prohibited."""
class
CharsetError
(
MessageError
):
class
CharsetError
(
MessageError
):
...
...
from_cpython/Lib/encodings/__init__.py
View file @
4818b5a4
...
@@ -43,9 +43,7 @@ _norm_encoding_map = (' . '
...
@@ -43,9 +43,7 @@ _norm_encoding_map = (' . '
' '
)
' '
)
_aliases
=
aliases
.
aliases
_aliases
=
aliases
.
aliases
# Pyston change: we don't support multiple inheritance yet
class
CodecRegistryError
(
LookupError
,
SystemError
):
#class CodecRegistryError(LookupError, SystemError):
class
CodecRegistryError
(
LookupError
):
pass
pass
def
normalize_encoding
(
encoding
):
def
normalize_encoding
(
encoding
):
...
...
from_cpython/Lib/tempfile.py
View file @
4818b5a4
...
@@ -29,8 +29,7 @@ __all__ = [
...
@@ -29,8 +29,7 @@ __all__ = [
# Imports.
# Imports.
# Pyston change: don't import io
import
io
as
_io
# import io as _io
import
os
as
_os
import
os
as
_os
import
errno
as
_errno
import
errno
as
_errno
from
random
import
Random
as
_Random
from
random
import
Random
as
_Random
...
@@ -198,10 +197,8 @@ def _get_default_tempdir():
...
@@ -198,10 +197,8 @@ def _get_default_tempdir():
fd
=
_os
.
open
(
filename
,
flags
,
0o600
)
fd
=
_os
.
open
(
filename
,
flags
,
0o600
)
try
:
try
:
try
:
try
:
# Pyston change: simplify this so that it doesn't need the _io module:
with
_io
.
open
(
fd
,
'wb'
,
closefd
=
False
)
as
fp
:
_os
.
write
(
fd
,
b'blat'
)
fp
.
write
(
b'blat'
)
# with _io.open(fd, 'wb', closefd=False) as fp:
# fp.write(b'blat')
finally
:
finally
:
_os
.
close
(
fd
)
_os
.
close
(
fd
)
finally
:
finally
:
...
...
from_cpython/Lib/test/test_array.py
View file @
4818b5a4
# expected: fail
"""Test the arraymodule.
"""Test the arraymodule.
Roger E. Masse
Roger E. Masse
"""
"""
...
@@ -766,6 +765,8 @@ class BaseTest(unittest.TestCase):
...
@@ -766,6 +765,8 @@ class BaseTest(unittest.TestCase):
b
=
buffer
(
a
)
b
=
buffer
(
a
)
self
.
assertEqual
(
b
[
0
],
a
.
tostring
()[
0
])
self
.
assertEqual
(
b
[
0
],
a
.
tostring
()[
0
])
# Pyston change: disable this test because of our GC
@
unittest
.
skip
(
"Pyston"
in
sys
.
version
)
def
test_weakref
(
self
):
def
test_weakref
(
self
):
s
=
array
.
array
(
self
.
typecode
,
self
.
example
)
s
=
array
.
array
(
self
.
typecode
,
self
.
example
)
p
=
proxy
(
s
)
p
=
proxy
(
s
)
...
...
from_cpython/Lib/test/test_urllib2.py
View file @
4818b5a4
# expected: fail
import
unittest
import
unittest
from
test
import
test_support
from
test
import
test_support
...
@@ -9,11 +8,6 @@ import StringIO
...
@@ -9,11 +8,6 @@ import StringIO
import
urllib2
import
urllib2
from
urllib2
import
Request
,
OpenerDirector
from
urllib2
import
Request
,
OpenerDirector
try
:
import
ssl
except
ImportError
:
ssl
=
None
# XXX
# XXX
# Request
# Request
# CacheFTPHandler (hard to write)
# CacheFTPHandler (hard to write)
...
@@ -26,7 +20,7 @@ class TrivialTests(unittest.TestCase):
...
@@ -26,7 +20,7 @@ class TrivialTests(unittest.TestCase):
self
.
assertRaises
(
ValueError
,
urllib2
.
urlopen
,
'bogus url'
)
self
.
assertRaises
(
ValueError
,
urllib2
.
urlopen
,
'bogus url'
)
# XXX Name hacking to get this to work on Windows.
# XXX Name hacking to get this to work on Windows.
fname
=
os
.
path
.
abspath
(
urllib2
.
__file__
).
replace
(
os
.
sep
,
'/'
)
fname
=
os
.
path
.
abspath
(
urllib2
.
__file__
).
replace
(
'
\
\
'
,
'/'
)
# And more hacking to get it to work on MacOS. This assumes
# And more hacking to get it to work on MacOS. This assumes
# urllib.pathname2url works, unfortunately...
# urllib.pathname2url works, unfortunately...
...
@@ -53,14 +47,6 @@ class TrivialTests(unittest.TestCase):
...
@@ -53,14 +47,6 @@ class TrivialTests(unittest.TestCase):
for
string
,
list
in
tests
:
for
string
,
list
in
tests
:
self
.
assertEqual
(
urllib2
.
parse_http_list
(
string
),
list
)
self
.
assertEqual
(
urllib2
.
parse_http_list
(
string
),
list
)
@
unittest
.
skipUnless
(
ssl
,
"ssl module required"
)
def
test_cafile_and_context
(
self
):
context
=
ssl
.
create_default_context
()
with
self
.
assertRaises
(
ValueError
):
urllib2
.
urlopen
(
"https://localhost"
,
cafile
=
"/nonexistent/path"
,
context
=
context
)
def
test_request_headers_dict
():
def
test_request_headers_dict
():
"""
"""
...
...
from_cpython/Lib/test/test_urllib2_localnet.py
View file @
4818b5a4
# expected: fail
import
urlparse
import
urlparse
import
urllib2
import
urllib2
import
BaseHTTPServer
import
BaseHTTPServer
...
...
from_cpython/Lib/types.py
View file @
4818b5a4
...
@@ -33,8 +33,7 @@ try:
...
@@ -33,8 +33,7 @@ try:
except
NameError
:
except
NameError
:
StringTypes
=
(
StringType
,)
StringTypes
=
(
StringType
,)
# Pyston change: 'buffer' is not implemented yet
BufferType
=
buffer
# BufferType = buffer
TupleType
=
tuple
TupleType
=
tuple
ListType
=
list
ListType
=
list
...
...
src/runtime/builtin_modules/thread.cpp
View file @
4818b5a4
...
@@ -28,6 +28,7 @@ using namespace pyston::threading;
...
@@ -28,6 +28,7 @@ using namespace pyston::threading;
extern
"C"
void
initthread
();
extern
"C"
void
initthread
();
std
::
atomic_long
nb_threads
;
static
int
initialized
;
static
int
initialized
;
static
void
PyThread__init_thread
(
void
);
/* Forward */
static
void
PyThread__init_thread
(
void
);
/* Forward */
...
@@ -69,6 +70,8 @@ static void* thread_start(Box* target, Box* varargs, Box* kwargs) {
...
@@ -69,6 +70,8 @@ static void* thread_start(Box* target, Box* varargs, Box* kwargs) {
timer
.
pushTopLevel
(
getCPUTicks
());
timer
.
pushTopLevel
(
getCPUTicks
());
#endif
#endif
++
nb_threads
;
try
{
try
{
runtimeCall
(
target
,
ArgPassSpec
(
0
,
0
,
true
,
kwargs
!=
NULL
),
varargs
,
kwargs
,
NULL
,
NULL
,
NULL
);
runtimeCall
(
target
,
ArgPassSpec
(
0
,
0
,
true
,
kwargs
!=
NULL
),
varargs
,
kwargs
,
NULL
,
NULL
,
NULL
);
}
catch
(
ExcInfo
e
)
{
}
catch
(
ExcInfo
e
)
{
...
@@ -79,6 +82,8 @@ static void* thread_start(Box* target, Box* varargs, Box* kwargs) {
...
@@ -79,6 +82,8 @@ static void* thread_start(Box* target, Box* varargs, Box* kwargs) {
timer
.
popTopLevel
(
getCPUTicks
());
timer
.
popTopLevel
(
getCPUTicks
());
#endif
#endif
--
nb_threads
;
return
NULL
;
return
NULL
;
}
}
...
@@ -190,6 +195,10 @@ Box* stackSize() {
...
@@ -190,6 +195,10 @@ Box* stackSize() {
Py_FatalError
(
"unimplemented"
);
Py_FatalError
(
"unimplemented"
);
}
}
Box
*
threadCount
()
{
return
boxInt
(
nb_threads
);
}
void
setupThread
()
{
void
setupThread
()
{
// Hacky: we want to use some of CPython's implementation of the thread module (the threading local stuff),
// Hacky: we want to use some of CPython's implementation of the thread module (the threading local stuff),
// and some of ours (thread handling). Start off by calling a cut-down version of initthread, and then
// and some of ours (thread handling). Start off by calling a cut-down version of initthread, and then
...
@@ -209,6 +218,8 @@ void setupThread() {
...
@@ -209,6 +218,8 @@ void setupThread() {
"get_ident"
,
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
getIdent
,
BOXED_INT
,
0
),
"get_ident"
));
"get_ident"
,
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
getIdent
,
BOXED_INT
,
0
),
"get_ident"
));
thread_module
->
giveAttr
(
thread_module
->
giveAttr
(
"stack_size"
,
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
stackSize
,
BOXED_INT
,
0
),
"stack_size"
));
"stack_size"
,
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
stackSize
,
BOXED_INT
,
0
),
"stack_size"
));
thread_module
->
giveAttr
(
"_count"
,
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
threadCount
,
BOXED_INT
,
0
),
"_count"
));
thread_lock_cls
=
BoxedClass
::
create
(
type_cls
,
object_cls
,
NULL
,
0
,
0
,
sizeof
(
BoxedThreadLock
),
false
,
"lock"
);
thread_lock_cls
=
BoxedClass
::
create
(
type_cls
,
object_cls
,
NULL
,
0
,
0
,
sizeof
(
BoxedThreadLock
),
false
,
"lock"
);
thread_lock_cls
->
tp_dealloc
=
BoxedThreadLock
::
threadLockDestructor
;
thread_lock_cls
->
tp_dealloc
=
BoxedThreadLock
::
threadLockDestructor
;
...
...
src/runtime/classobj.cpp
View file @
4818b5a4
...
@@ -1599,7 +1599,7 @@ extern "C" PyObject* PyMethod_Class(PyObject* im) noexcept {
...
@@ -1599,7 +1599,7 @@ extern "C" PyObject* PyMethod_Class(PyObject* im) noexcept {
void
setupClassobj
()
{
void
setupClassobj
()
{
classobj_cls
=
BoxedClass
::
create
(
type_cls
,
object_cls
,
&
BoxedClassobj
::
gcHandler
,
offsetof
(
BoxedClassobj
,
attrs
),
classobj_cls
=
BoxedClass
::
create
(
type_cls
,
object_cls
,
&
BoxedClassobj
::
gcHandler
,
offsetof
(
BoxedClassobj
,
attrs
),
0
,
sizeof
(
BoxedClassobj
),
false
,
"classobj"
);
offsetof
(
BoxedClassobj
,
weakreflist
)
,
sizeof
(
BoxedClassobj
),
false
,
"classobj"
);
instance_cls
=
BoxedClass
::
create
(
type_cls
,
object_cls
,
&
BoxedInstance
::
gcHandler
,
offsetof
(
BoxedInstance
,
attrs
),
instance_cls
=
BoxedClass
::
create
(
type_cls
,
object_cls
,
&
BoxedInstance
::
gcHandler
,
offsetof
(
BoxedInstance
,
attrs
),
offsetof
(
BoxedInstance
,
weakreflist
),
sizeof
(
BoxedInstance
),
false
,
"instance"
);
offsetof
(
BoxedInstance
,
weakreflist
),
sizeof
(
BoxedInstance
),
false
,
"instance"
);
...
...
src/runtime/classobj.h
View file @
4818b5a4
...
@@ -46,6 +46,8 @@ public:
...
@@ -46,6 +46,8 @@ public:
BoxedTuple
*
bases
;
BoxedTuple
*
bases
;
BoxedString
*
name
;
BoxedString
*
name
;
Box
**
weakreflist
;
BoxedClassobj
(
BoxedString
*
name
,
BoxedTuple
*
bases
)
:
bases
(
bases
),
name
(
name
)
{}
BoxedClassobj
(
BoxedString
*
name
,
BoxedTuple
*
bases
)
:
bases
(
bases
),
name
(
name
)
{}
static
void
gcHandler
(
GCVisitor
*
v
,
Box
*
_o
)
{
static
void
gcHandler
(
GCVisitor
*
v
,
Box
*
_o
)
{
...
...
src/runtime/list.cpp
View file @
4818b5a4
...
@@ -462,9 +462,7 @@ int list_ass_ext_slice(BoxedList* self, PyObject* item, PyObject* value) {
...
@@ -462,9 +462,7 @@ int list_ass_ext_slice(BoxedList* self, PyObject* item, PyObject* value) {
/* protect against a[::-1] = a */
/* protect against a[::-1] = a */
if
(
self
==
value
)
{
if
(
self
==
value
)
{
abort
();
seq
=
list_slice
(
value
,
0
,
PyList_GET_SIZE
(
value
));
// seq = list_slice((PyListObject*)value, 0,
// PyList_GET_SIZE(value));
}
else
{
}
else
{
seq
=
PySequence_Fast
(
value
,
"must assign iterable "
seq
=
PySequence_Fast
(
value
,
"must assign iterable "
"to extended slice"
);
"to extended slice"
);
...
@@ -1021,13 +1019,16 @@ Box* listCount(BoxedList* self, Box* elt) {
...
@@ -1021,13 +1019,16 @@ Box* listCount(BoxedList* self, Box* elt) {
return
boxInt
(
count
);
return
boxInt
(
count
);
}
}
Box
*
listIndex
(
BoxedList
*
self
,
Box
*
elt
,
BoxedInt
*
_start
,
Box
**
args
)
{
Box
*
listIndex
(
BoxedList
*
self
,
Box
*
elt
,
Box
*
_start
,
Box
**
args
)
{
BoxedInt
*
_stop
=
(
BoxedInt
*
)
args
[
0
];
Box
*
_stop
=
(
BoxedInt
*
)
args
[
0
];
RELEASE_ASSERT
(
!
_start
||
_start
->
cls
==
int_cls
,
""
);
RELEASE_ASSERT
(
!
_stop
||
_stop
->
cls
==
int_cls
,
""
);
int64_t
start
=
_start
?
_start
->
n
:
0
;
int64_t
start
=
0
;
int64_t
stop
=
_stop
?
_stop
->
n
:
self
->
size
;
int64_t
stop
=
self
->
size
;
if
(
!
_PyEval_SliceIndex
(
_start
,
&
start
))
throwCAPIException
();
if
(
!
_PyEval_SliceIndex
(
_stop
,
&
stop
))
throwCAPIException
();
if
(
start
<
0
)
{
if
(
start
<
0
)
{
start
+=
self
->
size
;
start
+=
self
->
size
;
...
...
test/CPYTHON_TEST_NOTES.md
View file @
4818b5a4
...
@@ -23,7 +23,6 @@ test_aifc Unsupported subclassing from file?
...
@@ -23,7 +23,6 @@ test_aifc Unsupported subclassing from file?
test_al No module named al
test_al No module named al
test_applesingle Not really a failure, but it tries to skip itself and we don't support that
test_applesingle Not really a failure, but it tries to skip itself and we don't support that
test_argparse [unknown]
test_argparse [unknown]
test_array [unknown]
test_ascii_formattd [unknown]
test_ascii_formattd [unknown]
test_ast [unknown]
test_ast [unknown]
test_asynchat [unknown]
test_asynchat [unknown]
...
@@ -248,9 +247,7 @@ test_unicode_file exit code 139, no error message
...
@@ -248,9 +247,7 @@ test_unicode_file exit code 139, no error message
test_unittest serialize_ast assert
test_unittest serialize_ast assert
test_univnewlines2k [unknown]
test_univnewlines2k [unknown]
test_univnewlines [unknown]
test_univnewlines [unknown]
test_urllib2_localnet [unknown]
test_urllib2net [unknown]
test_urllib2net [unknown]
test_urllib2 segfault due to attrwrapper corruption
test_urllibnet [unknown]
test_urllibnet [unknown]
test_userdict segfault: repr of recursive dict?
test_userdict segfault: repr of recursive dict?
test_userlist slice(1L, 1L)
test_userlist slice(1L, 1L)
...
...
test/tests/copy_test.py
View file @
4818b5a4
...
@@ -7,6 +7,7 @@ c.a = 1
...
@@ -7,6 +7,7 @@ c.a = 1
c
.
b
=
([
"str"
,
1
],
2L
)
c
.
b
=
([
"str"
,
1
],
2L
)
print
sorted
(
c
.
__dict__
.
items
())
print
sorted
(
c
.
__dict__
.
items
())
cc
=
copy
.
deepcopy
(
c
)
cc
=
copy
.
deepcopy
(
c
)
copy_dict
=
copy
.
deepcopy
(
c
.
__dict__
)
del
c
.
a
del
c
.
a
print
sorted
(
cc
.
__dict__
.
items
())
print
sorted
(
cc
.
__dict__
.
items
())
print
sorted
(
copy_dict
.
items
())
test/tests/list.py
View file @
4818b5a4
...
@@ -61,7 +61,7 @@ list_index = [1, 2, 3, 4, 5]
...
@@ -61,7 +61,7 @@ list_index = [1, 2, 3, 4, 5]
for
i
in
xrange
(
1
,
6
):
for
i
in
xrange
(
1
,
6
):
assert
list_index
.
index
(
i
)
==
i
-
1
assert
list_index
.
index
(
i
)
==
i
-
1
try
:
try
:
print
list_index
.
index
(
i
,
3
,
4
)
print
list_index
.
index
(
i
,
3
L
,
4L
)
except
ValueError
as
e
:
except
ValueError
as
e
:
print
e
print
e
try
:
try
:
...
@@ -167,6 +167,8 @@ l = range(5)
...
@@ -167,6 +167,8 @@ l = range(5)
l
[
2
:
4
]
=
tuple
(
range
(
2
))
l
[
2
:
4
]
=
tuple
(
range
(
2
))
print
l
print
l
l
[::
-
1
]
=
l
print
l
l
=
[
None
]
*
4
l
=
[
None
]
*
4
try
:
try
:
...
...
test/tests/thread_test.py
View file @
4818b5a4
from
thread
import
start_new_thread
,
allocate_lock
from
thread
import
start_new_thread
,
allocate_lock
,
_count
import
time
import
time
print
type
(
allocate_lock
())
print
type
(
allocate_lock
())
...
@@ -9,11 +9,13 @@ done = 0
...
@@ -9,11 +9,13 @@ done = 0
def
run
(
arg
):
def
run
(
arg
):
global
done
global
done
with
print_lock
:
with
print_lock
:
print
"num threads:"
,
_count
()
print
"in other thread!"
,
arg
print
"in other thread!"
,
arg
done
=
1
done
=
1
print
"starting!"
print
"starting!"
print
"num threads:"
,
_count
()
with
print_lock
:
with
print_lock
:
t
=
start_new_thread
(
run
,
(
5
,))
t
=
start_new_thread
(
run
,
(
5
,))
print
type
(
t
)
print
type
(
t
)
...
@@ -22,6 +24,7 @@ while not done:
...
@@ -22,6 +24,7 @@ while not done:
time
.
sleep
(
0
)
time
.
sleep
(
0
)
print
"done!"
print
"done!"
print
"num threads:"
,
_count
()
done
=
False
done
=
False
with
print_lock
:
with
print_lock
:
...
@@ -46,6 +49,7 @@ def run2():
...
@@ -46,6 +49,7 @@ def run2():
global
state
global
state
print
lock
.
acquire
(
0
)
print
lock
.
acquire
(
0
)
print
"num threads:"
,
_count
()
state
=
1
state
=
1
print
lock
.
acquire
()
print
lock
.
acquire
()
lock
.
release
()
lock
.
release
()
...
...
test/tests/weakrefs.py
View file @
4818b5a4
...
@@ -48,6 +48,9 @@ test_wr(frozenset())
...
@@ -48,6 +48,9 @@ test_wr(frozenset())
test_wr
((
i
*
i
for
i
in
range
(
1000000
)))
test_wr
((
i
*
i
for
i
in
range
(
1000000
)))
test_wr
(
set
)
test_wr
(
set
)
test_wr
(
file
(
"/etc/passwd"
))
test_wr
(
file
(
"/etc/passwd"
))
class
Old
:
pass
test_wr
(
Old
)
# missing: db cursor from the bsddb module
# missing: db cursor from the bsddb module
# missing: sockets
# missing: sockets
test_wr
(
array
.
array
(
'd'
,
[
1.0
,
2.0
,
3.14
]))
test_wr
(
array
.
array
(
'd'
,
[
1.0
,
2.0
,
3.14
]))
...
...
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