
    h	                         S r SSKrSSKrSSKJr  Sr\R                  S:X  a   " S S\5      r\rO\R                  r\R                  r	g)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                   R    \ rS rSrSrS
S jr\R                  rS rS r	S r
S rS	rg)TemporaryFile    z
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                     [         R                  " X4US9u  pgXpl        [        R                  " XaU5      U l        SU l        g )N)suffixprefixdirF)tempfilemkstempnameosfdopenfileclose_called)selfmodebufsizer   r   r   fdr   s           H/var/www/html/env/lib/python3.13/site-packages/django/core/files/temp.py__init__TemporaryFile.__init__*   s5    ''v#NHBI		"G4DI %D    c                     U R                   (       d?  SU l          U R                  R                  5          U R	                  U R
                  5        g g ! [         a     N*f = f! [         a     g f = f)NT)r   r   closeOSErrorunlinkr   r   s    r   r   TemporaryFile.close5   sg    $$$(!IIOO%KK		* %    s"   A A" 
AA"
A/.A/c                 $    U R                  5         g N)r   r!   s    r   __del__TemporaryFile.__del__A   s    JJLr   c                 :    U R                   R                  5         U $ r$   )r   	__enter__r!   s    r   r(   TemporaryFile.__enter__D   s    II!Kr   c                 <    U R                   R                  XU5        g r$   )r   __exit__)r   excvaluetbs       r   r+   TemporaryFile.__exit__H   s    IIs2.r   )r   r   r   )zw+b r1   N)__name__
__module____qualname____firstlineno____doc__r   r   r    r   r%   r(   r+   __static_attributes__ r   r   r   r       s+    		& 
				/r   r   )
r6   r   r   django.core.files.utilsr   __all__r   r   r   r   r8   r   r   <module>r;      sU   $ 
  2 77d?)/ )/V '!44  
r   