Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
e9d1959b
Commit
e9d1959b
authored
Jun 26, 2015
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix syntax under Python2.6 and initialization issues under all
parent
400f2a0d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
27 deletions
+62
-27
gevent/_tblib.py
gevent/_tblib.py
+62
-27
No files found.
gevent/_tblib.py
View file @
e9d1959b
...
...
@@ -29,7 +29,7 @@ Taken verbatim from Jinja2.
https://github.com/mitsuhiko/jinja2/blob/master/jinja2/debug.py#L267
"""
import
platform
#import platform # XXX: gevent cannot import platform at the top level; interferes with monkey patching
import
sys
...
...
@@ -95,12 +95,13 @@ def _init_ugly_crap():
return
tb_set_next
tb_set_next
=
None
try
:
if
platform
.
python_implementation
()
==
'CPython'
:
tb_set_next
=
_init_ugly_crap
()
except
Exception
as
exc
:
sys
.
stderr
.
write
(
"Failed to initialize cpython support: {!r}"
.
format
(
exc
))
del
_init_ugly_crap
# try:
# if platform.python_implementation() == 'CPython':
# #tb_set_next = _init_ugly_crap()
# tb_set_next = None
# except Exception as exc:
# sys.stderr.write("Failed to initialize cpython support: {!r}".format(exc))
# del _init_ugly_crap
# __init__.py
try
:
...
...
@@ -108,10 +109,9 @@ try:
except
ImportError
:
tproxy
=
None
if
not
tb_set_next
and
not
tproxy
:
raise
ImportError
(
"Cannot use tblib. Runtime not supported."
)
#
if not tb_set_next and not tproxy:
#
raise ImportError("Cannot use tblib. Runtime not supported.")
import
sys
from
types
import
CodeType
from
types
import
TracebackType
...
...
@@ -140,9 +140,9 @@ class Code(object):
class
Frame
(
object
):
def
__init__
(
self
,
frame
):
self
.
f_globals
=
{
k
:
v
for
k
,
v
in
frame
.
f_globals
.
items
()
if
k
in
(
"__file__"
,
"__name__"
)
}
# gevent: python 2.6 syntax fix
self
.
f_globals
=
{
'__file__'
:
frame
.
f_globals
.
get
(
'__file__'
),
'__name__'
:
frame
.
f_globals
.
get
(
'__name__'
)
}
self
.
f_code
=
Code
(
frame
.
f_code
)
...
...
@@ -202,12 +202,6 @@ class Traceback(object):
# pickling_support.py
try
:
import
copy_reg
except
ImportError
:
import
copyreg
as
copy_reg
def
unpickle_traceback
(
tb_frame
,
tb_lineno
,
tb_next
):
ret
=
object
.
__new__
(
Traceback
)
ret
.
tb_frame
=
tb_frame
...
...
@@ -221,23 +215,64 @@ def pickle_traceback(tb):
def
install
():
copy_reg
.
pickle
(
TracebackType
,
pickle_traceback
)
try
:
import
copy_reg
except
ImportError
:
import
copyreg
as
copy_reg
install
(
)
copy_reg
.
pickle
(
TracebackType
,
pickle_traceback
)
# Added by gevent
try
:
from
cPickle
import
dumps
from
cPickle
import
loads
except
ImportError
:
from
pickle
import
dumps
from
pickle
import
loads
# We have to defer the initilization, and especially the import of platform,
# until runtime.
def
_import_dump_load
():
global
dumps
global
loads
try
:
import
cPickle
as
pickle
except
ImportError
:
import
pickle
dumps
=
pickle
.
dumps
loads
=
pickle
.
loads
dumps
=
loads
=
None
_installed
=
False
def
_init
():
global
_installed
global
tb_set_next
if
_installed
:
return
_installed
=
True
import
platform
try
:
if
platform
.
python_implementation
()
==
'CPython'
:
tb_set_next
=
_init_ugly_crap
()
except
Exception
as
exc
:
sys
.
stderr
.
write
(
"Failed to initialize cpython support: {!r}"
.
format
(
exc
))
try
:
from
__pypy__
import
tproxy
except
ImportError
:
tproxy
=
None
if
not
tb_set_next
and
not
tproxy
:
raise
ImportError
(
"Cannot use tblib. Runtime not supported."
)
_import_dump_load
()
install
()
def
dump_traceback
(
tb
):
_init
()
return
dumps
(
tb
)
def
load_traceback
(
s
):
_init
()
return
loads
(
s
)
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