Skip to content

Commit

Permalink
Merge pull request #111 from blink1073/update-to-0.25-kernel
Browse files Browse the repository at this point in the history
Update to 0.25 kernel
  • Loading branch information
blink1073 committed Jan 28, 2017
2 parents 8b28f29 + 622a47d commit 8c52e90
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ language: python

env:
- CONDA="python=2.7 numpy=1.7"
- CONDA="python=3.4 numpy"
- CONDA="python=3.6 numpy"

before_install:
- sudo apt-add-repository -y ppa:picaso/octave;
Expand Down
9 changes: 6 additions & 3 deletions oct2py/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
import time
import tempfile
import types
import weakref

from metakernel.pexpect import TIMEOUT, EOF
from octave_kernel.kernel import OctaveEngine
from octave_kernel.kernel import OctaveEngine, STDIN_PROMPT

from oct2py.matwrite import MatWrite
from oct2py.matread import MatRead
Expand Down Expand Up @@ -579,7 +578,7 @@ def __init__(self, executable, logger=None):
os.environ['OCTAVE_EXECUTABLE'] = executable
if 'OCTAVE_EXECUTABLE' not in os.environ and 'OCTAVE' in os.environ:
os.environ['OCTAVE_EXECUTABLE'] = os.environ['OCTAVE']
self.engine = OctaveEngine(stdin_handler=input)
self.engine = OctaveEngine(stdin_handler=self._handle_stdin)
self.proc = self.engine.repl.child
self.logger = logger or get_log()
self._lines = []
Expand Down Expand Up @@ -693,6 +692,10 @@ def _log_line(self, line):
self._lines.append(line)
self.logger.debug(line)

def _handle_stdin(self, line):
"""Handle a stdin request from the session."""
return input(line.replace(STDIN_PROMPT, ''))

def __del__(self):
try:
self.close()
Expand Down
12 changes: 9 additions & 3 deletions oct2py/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import inspect
import dis
from oct2py.compat import PY2

import sys

def get_nout():
"""
Expand All @@ -27,10 +27,16 @@ def get_nout():
# nout is two frames back
frame = frame.f_back.f_back
bytecode = frame.f_code.co_code
instruction = bytecode[frame.f_lasti + 3]
if(sys.version_info > (3,5)):
instruction = bytecode[frame.f_lasti + 2]
else:
instruction = bytecode[frame.f_lasti + 3]
instruction = ord(instruction) if PY2 else instruction
if instruction == dis.opmap['UNPACK_SEQUENCE']:
howmany = bytecode[frame.f_lasti + 4]
if(sys.version_info > (3,5)):
howmany = bytecode[frame.f_lasti + 3]
else:
howmany = bytecode[frame.f_lasti + 4]
howmany = ord(howmany) if PY2 else howmany
return howmany
elif instruction in [dis.opmap['POP_TOP'], dis.opmap['PRINT_EXPR']]:
Expand Down

0 comments on commit 8c52e90

Please sign in to comment.