
    3j
                        d dl mZ ddgZd dlZd dlZ ej                  d      Zd	dZd
dZ	e
dk(  rd dlZ ej                          yy)    )annotationswrapWeakrefunwrapWeakrefN_Tc                P    	 t        j                  |       S # t        $ r | cY S w xY w)a  
    utility function that wraps objects as weakrefs but does not wrap
    already wrapped objects; also prevents wrapping the unwrappable "None" type, etc.

    >>> import weakref
    >>> class Mock:
    ...     pass
    >>> a1 = Mock()
    >>> ref1 = common.wrapWeakref(a1)
    >>> ref1
    <weakref at 0x101f29ae8; to ...Mock' at 0x101e45358>
    >>> ref2 = common.wrapWeakref(ref1)
    >>> ref2
    <weakref at 0x101f299af; to ...Mock' at 0x101e45358>
    >>> ref3 = common.wrapWeakref(5)
    >>> ref3
    5

    OMIT_FROM_DOCS

    Note that the ...Mock was needed after Python 3.13.
    When 3.13 is the lowest version, replace ... with the
    actual output.
    )weakrefref	TypeErrorreferents    H/DATA/.local/lib/python3.12/site-packages/music21/common/weakrefTools.pyr   r      s,    8{{8$$
  s    %%c                H    t        | t        j                        r |        S | S )a  
    Utility function that gets an object that might be an object itself
    or a weak reference to an object.  It returns obj() if it's a weakref.
    and obj if it's not.

    >>> class Mock:
    ...     pass
    >>> a1 = Mock()
    >>> a2 = Mock()
    >>> a2.strong = a1
    >>> a2.weak = common.wrapWeakref(a1)
    >>> common.unwrapWeakref(a2.strong) is a1
    True
    >>> common.unwrapWeakref(a2.weak) is a1
    True
    >>> common.unwrapWeakref(a2.strong) is common.unwrapWeakref(a2.weak)
    True
    )
isinstancer   ReferenceTyper   s    r   r   r   <   s!    & (G112z    __main__)r   r   returnzweakref.ReferenceType | _T)r   zweakref.ReferenceType | t.Anyr   zt.Any)
__future__r   __all__typingtr   TypeVarr   r   r   __name__music21mainTest r   r   <module>r      sT    #/
*  QYYt_#L2 zG r   