U
    ×€»d  ã                   @   s¢   d Z ddlZddlZejd dk Zejdd… dkZerZdd„ ZeZe	Z
ddlmZ eZn d	d„ ZeZeZ
dd
lmZmZ G dd„ deƒZdZdd„ Zdd„ ZdS )z*
Python2/Python3 compatibility utilities.
é    Né   é   )r   é   c                 C   s   | S ©N© )Úsr   r   ú_/mounts/lovelace/software/anaconda3/envs/rescript-2/lib/python3.8/site-packages/ijson/compat.pyÚ<lambda>   ó    r	   )ÚStringIOc                 C   s
   |   d¡S ©Nzutf-8)Údecode)Úbr   r   r   r	      r
   )ÚBytesIOr   c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )Ú
utf8readerz<Takes a utf8-encoded string reader and reads bytes out of itc                 C   s
   || _ d S r   )Ú
str_reader)Úselfr   r   r   r   Ú__init__   s    zutf8reader.__init__c                 C   s   | j  |¡ d¡S r   )r   ÚreadÚencode)r   Únr   r   r   r      s    zutf8reader.readN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r      s   r   aX  
ijson works by reading bytes, but a string reader has been given instead. This
probably, but not necessarily, means a file-like object has been opened in text
mode ('t') rather than binary mode ('b').

An automatic conversion is being performed on the fly to continue, but on the
other hand this creates unnecessary encoding/decoding operations that decrease
the efficiency of the system. In the future this automatic conversion will be
removed, and users will receive errors instead of this warning. To avoid this
problem make sure file-like objects are opened in binary mode instead of text
mode.
c                 C   s   t  tt¡ | S r   )ÚwarningsÚwarnÚ_str_vs_bytes_warningÚDeprecationWarning)Úor   r   r   Ú_warn_and_return/   s    r    c                 C   s"   t |  d¡ƒtkr| S tt| ƒƒS )z+Returns a file-like object that reads bytesr   )Útyper   Úbytetyper    r   )Úfr   r   r   Úbytes_reader3   s    r$   )r   Úsysr   Úversion_infoZIS_PY2ÚIS_PY35Zb2sÚstrr"   ÚunicodeÚtexttyper   r   ÚbytesÚioÚobjectr   r   r    r$   r   r   r   r   Ú<module>   s$   	