
    g	                         d Z ddlZddlZddlmZ dZej                  dk(  r G d de      ZeZej                  Z	yej                  Zej                  Z	y)a6  
The temp module provides a NamedTemporaryFile that can be reopened in the same
process on any platform. Most platforms use the standard Python
tempfile.NamedTemporaryFile class, but Windows users are given a custom class.

This is needed because the Python implementation of NamedTemporaryFile uses the
O_TEMPORARY flag under Windows, which prevents the file from being reopened
if the same flag is not provided [1][2]. Note that this does not address the
more general issue of opening a file for writing and reading in multiple
processes in a manner that works across platforms.

The custom version of NamedTemporaryFile doesn't support the same keyword
arguments available in tempfile.NamedTemporaryFile.

1: https://mail.python.org/pipermail/python-list/2005-December/336957.html
2: https://bugs.python.org/issue14243
    N)FileProxyMixin)NamedTemporaryFile
gettempdirntc                   H    e Zd ZdZddZej                  Zd Zd Zd Z	d Z
y)	TemporaryFilea.  
        Temporary file object constructor that supports reopening of the
        temporary file in Windows.

        Unlike tempfile.NamedTemporaryFile from the standard library,
        __init__() doesn't support the 'delete', 'buffering', 'encoding', or
        'newline' keyword arguments.
        Nc                     t        j                  |||      \  }}|| _        t        j                  |||      | _        d| _        y )N)suffixprefixdirF)tempfilemkstempnameosfdopenfileclose_called)selfmodebufsizer
   r   r   fdr   s           n/var/www/python.vincentserveurtest.ovh/public_html/venv/lib/python3.12/site-packages/django/core/files/temp.py__init__zTemporaryFile.__init__*   s=    ''vf#NHBDI		"dG4DI %D    c                     | j                   s?d| _         	 | j                  j                          	 | j	                  | j
                         y y # t        $ r Y )w xY w# t        $ r Y y w xY w)NT)r   r   closeOSErrorunlinkr   r   s    r   r   zTemporaryFile.close5   sg    $$$(!IIOO%KK		* %    s"   A A 	AA	A('A(c                 $    | j                          y N)r   r   s    r   __del__zTemporaryFile.__del__A   s    JJLr   c                 :    | j                   j                          | S r!   )r   	__enter__r   s    r   r$   zTemporaryFile.__enter__D   s    II!Kr   c                 >    | j                   j                  |||       y r!   )r   __exit__)r   excvaluetbs       r   r&   zTemporaryFile.__exit__H   s    IIsE2.r   )zw+b r+   N)__name__
__module____qualname____doc__r   r   r   r   r"   r$   r&    r   r   r   r       s+    		& 
				/r   r   )
r/   r   r   django.core.files.utilsr   __all__r   r   r   r   r0   r   r   <module>r3      sd   $ 
  2 77d?)/ )/V '   
 "44  
r   