Format: application/x-python-code
1 o
2
3 ��h � @ s: d Z ddlZddlZddlZddd�Zd dd�Ze� ZdS )
4 z+
5 Utilities for dealing with text encodings
6 � Nc C s t | d�r| js
7 |S | jS )a) Return the given stream's encoding or a default.
8
9 There are cases where ``sys.std*`` might not actually be a stream, so
10 check for the encoding attribute prior to returning it, and return
11 a default if it doesn't exist or evaluates as False. ``default``
12 is None if not provided.
13 �encoding)�hasattrr )�stream�default� r �Lc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/utils/encoding.py�get_stream_enc s r Tc C sf d}| r t tj�}|r|dkrzt�� }W n ty Y nw |p$t�� }|dkr1t�dt � dS |S )a� Return IPython's guess for the default encoding for bytes as text.
14
15 If prefer_stream is True (default), asks for stdin.encoding first,
16 to match the calling Terminal, but that is often None for subprocesses.
17
18 Then fall back on locale.getpreferredencoding(),
19 which should be a sensible platform default (that respects LANG environment),
20 and finally to sys.getdefaultencoding() which is the most conservative option,
21 and usually UTF8 as of Python 3.
22 N�asciiZcp0z�Invalid code page cp0 detected - using cp1252 instead.If cp1252 is incorrect please ensure a valid code page is defined for the process.�cp1252)
23 r �sys�stdin�locale�getpreferredencoding� Exception�getdefaultencoding�warnings�warn�RuntimeWarning)Z
24 prefer_stream�encr r r r &