Current File : //usr/local/apps/python3/lib/python3.11/test/__pycache__/test_code.cpython-311.opt-1.pyc |
�
�Ke'] � � � d Z ddlZddlZddlZddlZddlZddlZddlZddlZ ddl Z n
# e
$ r dZ Y nw xY wddlmZm
Z
mZmZ ddlmZ ddlmZ ddlmZ ed Zd� Zd � Zd
� Z G d� dej � � Zd
� Z G d� dej � � Z G d� dej � � Zd� Zd� Zd� Z d� Z!d� Z" e#� � fd�Z$d� Z%d� Z&d� Z' G d� dej � � Z( e
d�� � r�e ��e j) Z* e j+ de j, � � Z-e*j. Z/e-fe/_0 e j1 e/_2 e*j3 Z4e j5 e j1 e j, fe4_0 e j6 e4_2 e*j7 Z8e j5 e j1 e j9 e j, � � fe8_0 e j6 e8_2 da:d� Z; e-e;� � Z< e/e<� � Z= G d � d!ej � � Z>d"� Z?e@d#k r ejA � � dS dS )$a� This module includes tests of the code object representation.
>>> def f(x):
... def g(y):
... return x + y
... return g
...
>>> dump(f.__code__)
name: f
argcount: 1
posonlyargcount: 0
kwonlyargcount: 0
names: ()
varnames: ('x', 'g')
cellvars: ('x',)
freevars: ()
nlocals: 2
flags: 3
consts: ('None', '<code object g>')
>>> dump(f(4).__code__)
name: g
argcount: 1
posonlyargcount: 0
kwonlyargcount: 0
names: ()
varnames: ('y',)
cellvars: ()
freevars: ('x',)
nlocals: 1
flags: 19
consts: ('None',)
>>> def h(x, y):
... a = x + y
... b = x - y
... c = a * b
... return c
...
>>> dump(h.__code__)
name: h
argcount: 2
posonlyargcount: 0
kwonlyargcount: 0
names: ()
varnames: ('x', 'y', 'a', 'b', 'c')
cellvars: ()
freevars: ()
nlocals: 5
flags: 3
consts: ('None',)
>>> def attrs(obj):
... print(obj.attr1)
... print(obj.attr2)
... print(obj.attr3)
>>> dump(attrs.__code__)
name: attrs
argcount: 1
posonlyargcount: 0
kwonlyargcount: 0
names: ('print', 'attr1', 'attr2', 'attr3')
varnames: ('obj',)
cellvars: ()
freevars: ()
nlocals: 1
flags: 3
consts: ('None',)
>>> def optimize_away():
... 'doc string'
... 'not a docstring'
... 53
... 0x53
>>> dump(optimize_away.__code__)
name: optimize_away
argcount: 0
posonlyargcount: 0
kwonlyargcount: 0
names: ()
varnames: ()
cellvars: ()
freevars: ()
nlocals: 0
flags: 3
consts: ("'doc string'", 'None')
>>> def keywordonly_args(a,b,*,k1):
... return a,b,k1
...
>>> dump(keywordonly_args.__code__)
name: keywordonly_args
argcount: 2
posonlyargcount: 0
kwonlyargcount: 1
names: ()
varnames: ('a', 'b', 'k1')
cellvars: ()
freevars: ()
nlocals: 3
flags: 3
consts: ('None',)
>>> def posonly_args(a,b,/,c):
... return a,b,c
...
>>> dump(posonly_args.__code__)
name: posonly_args
argcount: 3
posonlyargcount: 2
kwonlyargcount: 0
names: ()
varnames: ('a', 'b', 'c')
cellvars: ()
freevars: ()
nlocals: 3
flags: 3
consts: ('None',)
� N)�cpython_only�check_impl_detail�requires_debug_ranges�
gc_collect)�assert_python_ok)�threading_helper)�opmap�COPY_FREE_VARSc # �~ K � | D ]7}t |� � }|� d� � r
d|j z V � �3|V � �8dS )z.Yield a doctest-safe sequence of object reprs.z<code objectz<code object %s>N)�repr�
startswith�co_name)�t�elt�rs �8/usr/local/apps/python3/lib/python3.11/test/test_code.py�constsr � s_ � � � �� � ����I�I���<�<��'�'� �$�s�{�2�2�2�2�2��G�G�G�G�� � c
� � dD ]'}t |�dt | d|z � � ��� � �(t dt t | j � � � � � � dS )z1Print out a text representation of a code object.)
�name�argcount�posonlyargcount�kwonlyargcount�names�varnames�cellvars�freevars�nlocals�flagsz: �co_zconsts:N)�print�getattr�tupler � co_consts)�co�attrs r �dumpr'