← Back
Editing: temp.cpython-311.pyc
� �|�e� � �~ � d Z ddlZddlZddlmZ dZej dk r G d� de� � ZeZnej Zej Z dS )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 �@ � e Zd ZdZdd�Zej Zd� Zd� Zd � Z d � Z dS )� 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. �w+b���� Nc � � t j |||�� � \ }}|| _ t j |||� � | _ d| _ d S )N)�suffix�prefix�dirF)�tempfile�mkstemp�name�os�fdopen�file�close_called)�self�mode�bufsizer r r �fdr s �8/usr/lib/python3/dist-packages/django/core/files/temp.py�__init__zTemporaryFile.__init__% sG � ��'�v�f�#�N�N�N�H�B���D�I�� �"�d�G�4�4�D�I� %�D���� c �� � | j s`d| _ | j � � � n# t $ r Y nw xY w | � | j � � d S # t $ r Y d S w xY wd S )NT)r r �close�OSError�unlinkr �r s r r zTemporaryFile.close0 s� � ��$� �$(��!���I�O�O�%�%�%�%��� � � ��D�������K�K�� �*�*�*�*�*��� � � ��D�D����� � s �* � 7�7�A � A%�$A%c �. � | � � � d S �N)r r"