[Jython-checkins] jython: Support sys.getprofile() and sys.gettrace()
jim.baker
jython-checkins at python.org
Mon Dec 8 04:01:54 CET 2014
https://hg.python.org/jython/rev/d281114823af
changeset: 7435:d281114823af
user: Jim Baker <jim.baker at rackspace.com>
date: Sun Dec 07 20:01:36 2014 -0700
summary:
Support sys.getprofile() and sys.gettrace()
These functions were added in Python 2.6
files:
Lib/test/test_profilehooks.py | 2 -
src/org/python/core/PySystemState.java | 18 ++++++++++++++
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/Lib/test/test_profilehooks.py b/Lib/test/test_profilehooks.py
--- a/Lib/test/test_profilehooks.py
+++ b/Lib/test/test_profilehooks.py
@@ -17,11 +17,9 @@
def tearDown(self):
sys.setprofile(None)
- @unittest.skip("FIXME: broken")
def test_empty(self):
assert sys.getprofile() == None
- @unittest.skip("FIXME: broken")
def test_setget(self):
def fn(*args):
pass
diff --git a/src/org/python/core/PySystemState.java b/src/org/python/core/PySystemState.java
--- a/src/org/python/core/PySystemState.java
+++ b/src/org/python/core/PySystemState.java
@@ -428,6 +428,15 @@
this.recursionlimit = recursionlimit;
}
+ public PyObject gettrace() {
+ ThreadState ts = Py.getThreadState();
+ if (ts.tracefunc == null) {
+ return Py.None;
+ } else {
+ return ((PythonTraceFunction)ts.tracefunc).tracefunc;
+ }
+ }
+
public void settrace(PyObject tracefunc) {
ThreadState ts = Py.getThreadState();
if (tracefunc == Py.None) {
@@ -437,6 +446,15 @@
}
}
+ public PyObject getprofile() {
+ ThreadState ts = Py.getThreadState();
+ if (ts.profilefunc == null) {
+ return Py.None;
+ } else {
+ return ((PythonTraceFunction)ts.profilefunc).tracefunc;
+ }
+ }
+
public void setprofile(PyObject profilefunc) {
ThreadState ts = Py.getThreadState();
if (profilefunc == Py.None) {
--
Repository URL: https://hg.python.org/jython
More information about the Jython-checkins
mailing list