From 301956c6a1ec274d01faea7fe208a89a300e4a03 2014-02-08 13:22:07 From: Doug Blank Date: 2014-02-08 13:22:07 Subject: [PATCH] Summary of changes: 1) IPython/core/compilerop.py: IronPython __future__ flags are non-standard, Solution try/except; comment added 2) IPython/core/completer.py: __main__ was undefined, due to local mistake in creating IronPython scope; removed this tweak 3) IPython/core/prompts.py: os.getuid() is not defined (IronPython bug; see: https://mail.python.org/pipermail/ironpython-users/2014-February/016812.html) 4) IPython/lib/inputhook.py: ctypes SystemError; comment added 5) IPython/utils/process.py and IPython/utils/_process_cli.py: adds a new _process_cli.py which would handle the processes under cli; fixed os.pathsep 6) IPython/utils/io.py: devnull opened in append mode; changed to "w" 7) New issue: IPython/external/decorator/_decorator.py: IronPython doesn't have _getframes, unless FullFrames is set to true; comment added --- diff --git a/IPython/core/compilerop.py b/IPython/core/compilerop.py index 9352375..735fa3f 100644 --- a/IPython/core/compilerop.py +++ b/IPython/core/compilerop.py @@ -43,12 +43,12 @@ import time # Roughtly equal to PyCF_MASK | PyCF_MASK_OBSOLETE as defined in pythonrun.h, # this is used as a bitmask to extract future-related code flags. -PyCF_MASK = functools.reduce(operator.or_, - (getattr(__future__, fname).compiler_flag - for fname in __future__.all_feature_names - if (hasattr(__future__, fname) and - hasattr(getattr(__future__, fname), "compiler_flag"))), - 0) +try: + PyCF_MASK = functools.reduce(operator.or_, + (getattr(__future__, fname).compiler_flag + for fname in __future__.all_feature_names)) +except AttributeError: # IronPython __future__'s are non-standard, 2/8/2014 + PyCF_MASK = 0 #----------------------------------------------------------------------------- # Local utilities diff --git a/IPython/core/completer.py b/IPython/core/completer.py index 54f4b45..b1bc646 100644 --- a/IPython/core/completer.py +++ b/IPython/core/completer.py @@ -66,10 +66,7 @@ Notes: # Imports #----------------------------------------------------------------------------- -try: - import __main__ -except ImportError: - pass +import __main__ import glob import inspect import itertools diff --git a/IPython/core/prompts.py b/IPython/core/prompts.py index fc8567c..473a591 100644 --- a/IPython/core/prompts.py +++ b/IPython/core/prompts.py @@ -148,6 +148,8 @@ USER = py3compat.str_to_unicode(os.environ.get("USER",'')) HOSTNAME = py3compat.str_to_unicode(socket.gethostname()) HOSTNAME_SHORT = HOSTNAME.split(".")[0] +# IronPython doesn't currently have os.getuid() even if +# os.name == 'posix'; 2/8/2014 ROOT_SYMBOL = "#" if (os.name=='nt' or sys.platform=='cli' or os.getuid()==0) else "$" prompt_abbreviations = { diff --git a/IPython/external/decorator/_decorator.py b/IPython/external/decorator/_decorator.py index ed37b96..93cc576 100644 --- a/IPython/external/decorator/_decorator.py +++ b/IPython/external/decorator/_decorator.py @@ -139,7 +139,10 @@ class FunctionMaker(object): func.__defaults__ = getattr(self, 'defaults', ()) func.__kwdefaults__ = getattr(self, 'kwonlydefaults', None) func.__annotations__ = getattr(self, 'annotations', None) - callermodule = sys._getframe(3).f_globals.get('__name__', '?') + try: + callermodule = sys._getframe(3).f_globals.get('__name__', '?') + except AttributeError: # IronPython _getframe only exists with FullFrames + callermodule = '?' func.__module__ = getattr(self, 'module', callermodule) func.__dict__.update(kw) diff --git a/IPython/lib/inputhook.py b/IPython/lib/inputhook.py index b175377..a29cec0 100644 --- a/IPython/lib/inputhook.py +++ b/IPython/lib/inputhook.py @@ -18,7 +18,7 @@ try: import ctypes except ImportError: ctypes = None -except SystemError: +except SystemError: # IronPython issue, 2/8/2014 ctypes = None import os import sys diff --git a/IPython/utils/_process_cli.py b/IPython/utils/_process_cli.py index 9068038..d7c8ea9 100644 --- a/IPython/utils/_process_cli.py +++ b/IPython/utils/_process_cli.py @@ -21,8 +21,7 @@ from ._process_common import arg_split def _find_cmd(cmd): """Find the full path to a command using which.""" - os_path_sep = ":" if os.name == "posix" else ";" - paths = System.Environment.GetEnvironmentVariable("PATH").Split(os_path_sep) + paths = System.Environment.GetEnvironmentVariable("PATH").Split(os.pathsep) for path in paths: filename = os.path.join(path, cmd) if System.IO.File.Exists(filename):