aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/ipython/py3/IPython/core/crashhandler.py
diff options
context:
space:
mode:
authorrobot-contrib <robot-contrib@yandex-team.ru>2022-05-18 00:43:36 +0300
committerrobot-contrib <robot-contrib@yandex-team.ru>2022-05-18 00:43:36 +0300
commit9e5f436a8b2a27bcc7802e443ea3ef3e41a82a75 (patch)
tree78b522cab9f76336e62064d4d8ff7c897659b20e /contrib/python/ipython/py3/IPython/core/crashhandler.py
parent8113a823ffca6451bb5ff8f0334560885a939a24 (diff)
downloadydb-9e5f436a8b2a27bcc7802e443ea3ef3e41a82a75.tar.gz
Update contrib/python/ipython/py3 to 8.3.0
ref:e84342d4d30476f9148137f37fd0c6405fd36f55
Diffstat (limited to 'contrib/python/ipython/py3/IPython/core/crashhandler.py')
-rw-r--r--contrib/python/ipython/py3/IPython/core/crashhandler.py37
1 files changed, 23 insertions, 14 deletions
diff --git a/contrib/python/ipython/py3/IPython/core/crashhandler.py b/contrib/python/ipython/py3/IPython/core/crashhandler.py
index 1e0b429d09a..4af39361e80 100644
--- a/contrib/python/ipython/py3/IPython/core/crashhandler.py
+++ b/contrib/python/ipython/py3/IPython/core/crashhandler.py
@@ -23,6 +23,7 @@ import os
import sys
import traceback
from pprint import pformat
+from pathlib import Path
from IPython.core import ultratb
from IPython.core.release import author_email
@@ -31,6 +32,8 @@ from IPython.utils.py3compat import input
from IPython.core.release import __version__ as version
+from typing import Optional
+
#-----------------------------------------------------------------------------
# Code
#-----------------------------------------------------------------------------
@@ -94,34 +97,40 @@ class CrashHandler(object):
message_template = _default_message_template
section_sep = '\n\n'+'*'*75+'\n\n'
- def __init__(self, app, contact_name=None, contact_email=None,
- bug_tracker=None, show_crash_traceback=True, call_pdb=False):
+ def __init__(
+ self,
+ app,
+ contact_name: Optional[str] = None,
+ contact_email: Optional[str] = None,
+ bug_tracker: Optional[str] = None,
+ show_crash_traceback: bool = True,
+ call_pdb: bool = False,
+ ):
"""Create a new crash handler
Parameters
----------
- app : Application
+ app : Application
A running :class:`Application` instance, which will be queried at
crash time for internal information.
-
contact_name : str
A string with the name of the person to contact.
-
contact_email : str
A string with the email address of the contact.
-
bug_tracker : str
A string with the URL for your project's bug tracker.
-
show_crash_traceback : bool
If false, don't print the crash traceback on stderr, only generate
the on-disk report
+ call_pdb
+ Whether to call pdb on crash
- Non-argument instance attributes:
-
+ Attributes
+ ----------
These instances contain some non-argument attributes which allow for
further customization of the crash handler's behavior. Please see the
source for further details.
+
"""
self.crash_report_fname = "Crash_report_%s.txt" % app.name
self.app = app
@@ -151,10 +160,10 @@ class CrashHandler(object):
try:
rptdir = self.app.ipython_dir
except:
- rptdir = os.getcwd()
- if rptdir is None or not os.path.isdir(rptdir):
- rptdir = os.getcwd()
- report_name = os.path.join(rptdir,self.crash_report_fname)
+ rptdir = Path.cwd()
+ if rptdir is None or not Path.is_dir(rptdir):
+ rptdir = Path.cwd()
+ report_name = rptdir / self.crash_report_fname
# write the report filename into the instance dict so it can get
# properly expanded out in the user message template
self.crash_report_fname = report_name
@@ -176,7 +185,7 @@ class CrashHandler(object):
# and generate a complete report on disk
try:
- report = open(report_name,'w')
+ report = open(report_name, "w", encoding="utf-8")
except:
print('Could not create crash report on disk.', file=sys.stderr)
return