Repository: ipython/ipython

Issue:
ipython exits with traceback when run in non-existing directory
Description of problem:  
I tried to run ipython3 in a directory, which was already deleted. ipython  
ended with Traceback.                                                                                 

Version-Release number of selected component (if applicable):  
python3-ipython-2.3.0-1.fc21.noarch                                                                   

How reproducible:  
always                                                                                                

Steps to Reproduce:  
1. run ipython3 in non-existing directory                                                             

Actual results:

```
$ ipython3
[TerminalIPythonApp] ERROR | Current working directory doesn't exist.
Traceback (most recent call last):                                                                    
  File "/usr/bin/ipython3", line 5, in <module>                                                       
    start_ipython()                                                                                   
  File "/usr/lib/python3.4/site-packages/IPython/__init__.py", line 120, in                           
start_ipython                                                                                         
    return launch_new_instance(argv=argv, **kwargs)                                                   
  File "/usr/lib/python3.4/site-packages/IPython/config/application.py", line                         
562, in launch_instance                                                                               
    app = cls.instance(**kwargs)                                                                      
  File "/usr/lib/python3.4/site-packages/IPython/config/configurable.py", line                        
354, in instance                                                                                      
    inst = cls(*args, **kwargs)                                                                       
  File "<string>", line 2, in __init__                                                                
  File "/usr/lib/python3.4/site-packages/IPython/config/application.py", line                         
92, in catch_config_error                                                                             
    return method(app, *args, **kwargs)                                                               
  File "/usr/lib/python3.4/site-packages/IPython/core/application.py", line                           
183, in __init__                                                                                      
    directory = py3compat.getcwd()                                                                    
FileNotFoundError: [Errno 2] No such file or directory                                                
```

Expected results:  
Error message, but no Traceback                                                                       

Forwarded from https://bugzilla.redhat.com/show_bug.cgi?id=1195181.



Discussion:

Resolving patch:
diff --git a/IPython/core/application.py b/IPython/core/application.py
--- a/IPython/core/application.py
+++ b/IPython/core/application.py
@@ -170,9 +170,9 @@ def __init__(self, **kwargs):
         try:
             directory = py3compat.getcwd()
         except:
-            # raise exception
+            # exit if cwd doesn't exist
             self.log.error("Current working directory doesn't exist.")
-            raise
+            self.exit(1)
 
     #-------------------------------------------------------------------------
     # Various stages of Application creation


Test patch: