매우 고수준 계층
****************

이 장의 함수들은 파일이나 버퍼에 제공된 파이썬 소스 코드를 실행할 수
있도록 하지만, 인터프리터와 더 세밀한 방식으로 상호 작용하도록 하지는
않습니다.

Several of these functions accept a start symbol from the grammar as a
parameter.  The available start symbols are "Py_eval_input",
"Py_file_input", "Py_single_input", and "Py_func_type_input".  These
are described following the functions which accept them as parameters.

또한 이 함수 중 일부는 FILE* 매개 변수를 취합니다. 주의해서 다루어야
할 한 가지 문제는 다른 C 라이브러리의 "FILE" 구조체가 다르고, 호환되지
않을 수 있다는 것입니다. (적어도) 윈도우에서는, 동적으로 링크된 확장에
서 실제로 다른 라이브러리를 사용할 수 있어서, FILE* 매개 변수가 파이썬
런타임이 사용하고 있는 것과 같은 라이브러리에서 만들어진 것이 확실할
때만 이러한 함수에 전달되도록 주의해야 합니다.

int PyRun_AnyFile(FILE *fp, const char *filename)

   아래 "PyRun_AnyFileExFlags()" 의 단순화된 인터페이스입니다.
   *closeit*은 "0"으로 *flags*는 "NULL"로 설정된 상태로 남겨둡니다.

int PyRun_AnyFileFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)

   아래 "PyRun_AnyFileExFlags()" 의 단순화된 인터페이스입니다. 이것은
   *closeit* 인자를 "0"으로 설정된 상태로 남겨둡니다.

int PyRun_AnyFileEx(FILE *fp, const char *filename, int closeit)

   아래 "PyRun_AnyFileExFlags()" 의 단순화된 인터페이스입니다. 이것은
   *flags* 인자를 "NULL"로 설정된 상태로 남겨둡니다.

int PyRun_AnyFileExFlags(FILE *fp, const char *filename, int closeit, PyCompilerFlags *flags)

   *fp*가 대화식 장치(콘솔이나 터미널 입력이나 유닉스 의사 터미널)와
   연결된 파일을 가리키면, "PyRun_InteractiveLoop()"의 값을 반환하고,
   그렇지 않으면 "PyRun_SimpleFile()"의 결과를 반환합니다. *filename*
   은 파일 시스템 인코딩("sys.getfilesystemencoding()")으로 디코딩됩니
   다. *filename*이 "NULL"이면, 이 함수는 파일명으로 ""???""를 사용합
   니다. *closeit*이 참이면, "PyRun_SimpleFileExFlags()"이 반환하기 전
   에 파일이 닫힙니다.

int PyRun_SimpleString(const char *command)

   아래 "PyRun_SimpleStringFlags()" 의 단순화된 인터페이스입니다.
   "PyCompilerFlags"* 인자를 "NULL"로 설정된 상태로 남겨둡니다.

int PyRun_SimpleStringFlags(const char *command, PyCompilerFlags *flags)

   *flags* 인자에 따라 "__main__" 모듈에서 *command*에 있는 파이썬 소
   스 코드를 실행합니다. "__main__"이 존재하지 않으면 만듭니다. 성공하
   면 "0"을, 예외가 발생하면 "-1"을 반환합니다. 에러가 있으면, 예외 정
   보를 얻을 방법이 없습니다. *flags*의 의미는 아래를 참조하십시오.

   처리되지 않은 "SystemExit"가 발생하면, 이 함수는 "PyConfig.inspect"
   가 0인 한 "-1"을 반환하지 않고 프로세스를 종료함에 유의하십시오.

int PyRun_SimpleFile(FILE *fp, const char *filename)

   아래 "PyRun_SimpleFileExFlags()" 의 단순화된 인터페이스입니다.
   *closeit*을 "0"으로, *flags*를 "NULL"로 설정된 상태로 남겨둡니다.

int PyRun_SimpleFileEx(FILE *fp, const char *filename, int closeit)

   아래 "PyRun_SimpleFileExFlags()" 의 단순화된 인터페이스입니다.
   *flags*를 "NULL"로 설정된 상태로 남겨둡니다.

int PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit, PyCompilerFlags *flags)

   "PyRun_SimpleStringFlags()" 와 비슷하지만, 메모리에 있는 문자열 대
   신 *fp*에서 파이썬 소스 코드를 읽습니다. *filename*은 파일의 이름이
   어야 하며, *파일시스템 인코딩과 에러 처리기*로 디코딩됩니다.
   *closeit*이 참이면 "PyRun_SimpleFileExFlags()" 가 반환하기 전에 파
   일이 닫힙니다.

   참고:

     윈도우에서, *fp*는 바이너리 모드로 열어야 합니다 (예를 들어
     "fopen(filename, "rb")"). 그렇지 않으면, 파이썬은 LF 줄 종료가 있
     는 스크립트 파일을 올바르게 처리하지 못할 수 있습니다.

int PyRun_InteractiveOneObject(FILE *fp, PyObject *filename, PyCompilerFlags *flags)

   Read and execute a single statement from a file associated with an
   interactive device according to the *flags* argument.  The user
   will be prompted using "sys.ps1" and "sys.ps2". *filename* must be
   a Python "str" object.

   입력이 성공적으로 실행될 때 "0"을, 예외가 있으면 "-1"을, 또는 구문
   분석 에러가 있으면 파이썬의 일부로 배포된 "errcode.h" 인클루드 파일
   에 있는 에러 코드를 반환합니다. ("errcode.h"는 "Python.h"에서 인클
   루드하지 않기 때문에 필요하면 특별히 인클루드해야 함에 유의하십시오
   .)

int PyRun_InteractiveOne(FILE *fp, const char *filename)

   아래 "PyRun_InteractiveOneFlags()" 의 단순화된 인터페이스입니다.
   *flags*를 "NULL"로 설정된 상태로 남겨둡니다.

int PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)

   Similar to "PyRun_InteractiveOneObject()", but *filename* is a
   const char*, which is decoded from the *filesystem encoding and
   error handler*.

int PyRun_InteractiveLoop(FILE *fp, const char *filename)

   아래 "PyRun_InteractiveLoopFlags()" 의 단순화된 인터페이스입니다.
   *flags*를 "NULL"로 설정된 상태로 남겨둡니다.

int PyRun_InteractiveLoopFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)

   EOF에 도달할 때까지 대화식 장치와 연관된 파일에서 문장을 읽고 실행
   합니다. "sys.ps1"과 "sys.ps2"를 사용하여 사용자에게 프롬프트 합니다
   . *filename*은 *파일시스템 인코딩과 에러 처리기*로 디코딩됩니다.
   EOF에서 "0"을 반환하거나, 실패하면 음수를 반환합니다.

int (*PyOS_InputHook)(void)
    * Part of the 안정 ABI.*

   Can be set to point to a function with the prototype "int
   func(void)".  The function will be called when Python's interpreter
   prompt is about to become idle and wait for user input from the
   terminal.  The return value is ignored.  Overriding this hook can
   be used to integrate the interpreter's prompt with other event
   loops, as done in "Modules/_tkinter.c" in the Python source code.

   버전 3.12에서 변경: This function is only called from the main
   interpreter.

char *(*PyOS_ReadlineFunctionPointer)(FILE*, FILE*, const char*)

   프로토타입 "char *func(FILE *stdin, FILE *stdout, char *prompt)"인
   함수를 가리키도록 설정하여, 인터프리터의 프롬프트에서 단일 입력 줄
   을 읽는 데 사용되는 기본 함수를 재정의할 수 있습니다. 이 함수는
   "NULL"이 아니면 문자열 *prompt*를 출력한 다음 제공된 표준 입력 파일
   에서 입력 줄을 읽고 결과 문자열을 반환할 것이라고 기대됩니다. 예를
   들어, "readline" 모듈은 이 훅을 설정하여 줄 편집과 탭 완성 기능을
   제공합니다.

   결과는 "PyMem_RawMalloc()"이나 "PyMem_RawRealloc()"으로 할당된 문자
   열 이거나, 에러가 발생했으면 "NULL"이어야 합니다.

   버전 3.4에서 변경: 결과는 "PyMem_Malloc()"이나 "PyMem_Realloc()"으
   로 할당하는 대신, "PyMem_RawMalloc()"이나 "PyMem_RawRealloc()"으로
   할당해야 합니다.

   버전 3.12에서 변경: This function is only called from the main
   interpreter.

PyObject *PyRun_String(const char *str, int start, PyObject *globals, PyObject *locals)
    *반환값: 새 참조.*

   아래 "PyRun_StringFlags()"의 단순화된 인터페이스입니다. 이것은
   *flags*를 "NULL"로 설정된 상태로 남겨둡니다.

PyObject *PyRun_StringFlags(const char *str, int start, PyObject *globals, PyObject *locals, PyCompilerFlags *flags)
    *반환값: 새 참조.*

   Execute Python source code from *str* in the context specified by
   the objects *globals* and *locals* with the compiler flags
   specified by *flags*.  *globals* must be a dictionary; *locals* can
   be any object that implements the mapping protocol.  The parameter
   *start* specifies the start symbol and must one of the available
   start symbols.

   코드를 실행한 결과를 파이썬 객체로 반환하거나, 예외가 발생하면
   "NULL"을 반환합니다.

PyObject *PyRun_File(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals)
    *반환값: 새 참조.*

   아래 "PyRun_FileExFlags()"의 단순화된 인터페이스입니다. *closeit*을
   "0"으로, *flags*를 "NULL"로 설정된 상태로 남겨둡니다.

PyObject *PyRun_FileEx(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, int closeit)
    *반환값: 새 참조.*

   아래 "PyRun_FileExFlags()"의 단순화된 인터페이스입니다. *flags*를
   "NULL"로 설정된 상태로 남겨둡니다.

PyObject *PyRun_FileFlags(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, PyCompilerFlags *flags)
    *반환값: 새 참조.*

   아래 "PyRun_FileExFlags()"의 단순화된 인터페이스입니다. *closeit*을
   "0"으로 설정된 상태로 남겨둡니다.

PyObject *PyRun_FileExFlags(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, int closeit, PyCompilerFlags *flags)
    *반환값: 새 참조.*

   "PyRun_StringFlags()"와 유사하지만, 파이썬 소스 코드는 메모리에 있
   는 문자열 대신 *fp*에서 읽습니다. *filename*은 파일명이어야 하며 *
   파일시스템 인코딩과 에러 처리기*로 디코딩됩니다. *closeit*이 참이면
   "PyRun_FileExFlags()"가 반환되기 전에 파일이 닫힙니다.

PyObject *Py_CompileString(const char *str, const char *filename, int start)
    *반환값: 새 참조.** Part of the 안정 ABI.*

   아래 "Py_CompileStringFlags()" 의 단순화된 인터페이스입니다.
   *flags*를 "NULL"로 설정된 상태로 유지합니다.

PyObject *Py_CompileStringFlags(const char *str, const char *filename, int start, PyCompilerFlags *flags)
    *반환값: 새 참조.*

   아래 "Py_CompileStringExFlags()" 의 단순화된 인터페이스입니다.
   *optimize*를 "-1"로 설정된 상태로 유지합니다.

PyObject *Py_CompileStringObject(const char *str, PyObject *filename, int start, PyCompilerFlags *flags, int optimize)
    *반환값: 새 참조.*

   Parse and compile the Python source code in *str*, returning the
   resulting code object.  The start symbol is given by *start*; this
   can be used to constrain the code which can be compiled and should
   be available start symbols.  The filename specified by *filename*
   is used to construct the code object and may appear in tracebacks
   or "SyntaxError" exception messages.  This returns "NULL" if the
   code cannot be parsed or compiled.

   정수 *optimize*는 컴파일러의 최적화 수준을 지정합니다. "-1" 값은
   "-O" 옵션으로 주어진 것처럼 인터프리터의 최적화 수준을 선택합니다.
   명시적 수준은 "0" (최적화 없음; "__debug__"가 참), "1" (어서션이 제
   거되고 "__debug__"가 거짓) 또는 "2" (독스트링도 제거됩니다)입니다.

   Added in version 3.4.

PyObject *Py_CompileStringExFlags(const char *str, const char *filename, int start, PyCompilerFlags *flags, int optimize)
    *반환값: 새 참조.*

   "Py_CompileStringObject()"와 유사하지만, *filename*은 *파일시스템
   인코딩과 에러 처리기*로 디코딩된 바이트 문자열입니다.

   Added in version 3.2.

PyObject *PyEval_EvalCode(PyObject *co, PyObject *globals, PyObject *locals)
    *반환값: 새 참조.** Part of the 안정 ABI.*

   이것은 코드 객체와 전역 변수 및 지역 변수만 있는,
   "PyEval_EvalCodeEx()"의 단순화된 인터페이스입니다. 다른 인자는
   "NULL"로 설정됩니다.

PyObject *PyEval_EvalCodeEx(PyObject *co, PyObject *globals, PyObject *locals, PyObject *const *args, int argcount, PyObject *const *kws, int kwcount, PyObject *const *defs, int defcount, PyObject *kwdefs, PyObject *closure)
    *반환값: 새 참조.** Part of the 안정 ABI.*

   주어진 평가를 위한 특정 환경에서, 미리 컴파일된 코드 객체를 평가합
   니다. 이 환경은 전역 변수의 딕셔너리, 지역 변수의 매핑 객체, 인자의
   배열, 키워드와 기본값, 키워드 전용 인자의 기본값 딕셔너리 및 셀의
   클로저 튜플로 구성됩니다.

PyObject *PyEval_EvalFrame(PyFrameObject *f)
    *반환값: 새 참조.** Part of the 안정 ABI.*

   실행 프레임을 평가합니다. 이전 버전과의 호환성을 위한,
   "PyEval_EvalFrameEx()"의 단순화된 인터페이스입니다.

PyObject *PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
    *반환값: 새 참조.** Part of the 안정 ABI.*

   이것은 파이썬 인터프리트의 메인, 꾸미지 않은 함수입니다. 실행 프레
   임 *f*와 연관된 코드 객체가 실행됩니다. 필요에 따라 바이트 코드를
   해석하고 호출을 실행합니다. 추가 *throwflag* 매개 변수는 대체로 무
   시할 수 있습니다 - 참이면, 예외가 즉시 발생하도록 합니다; 제너레이
   터 객체의 "throw()" 메서드에 사용됩니다.

   버전 3.4에서 변경: 이 함수는 이제 활성 예외를 조용히 버리지 않았는
   지 확인하도록 도우려고 디버그 어서션을 포함합니다.

int PyEval_MergeCompilerFlags(PyCompilerFlags *cf)

   이 함수는 현재 평가 프레임의 플래그를 변경하고, 성공하면 참을, 실패
   하면 거짓을 반환합니다.

struct PyCompilerFlags

   이것은 컴파일러 플래그를 담는 데 사용되는 구조체입니다. 코드가 컴파
   일되기만 하는 경우 "int flags"로 전달되고, 코드가 실행되는 경우
   "PyCompilerFlags *flags"로 전달됩니다. 이 경우, "from __future__
   import"는 *flags*를 수정할 수 있습니다.

   "PyCompilerFlags *flags"가 "NULL"일 때마다, "cf_flags"는 "0"과 같다
   고 취급되며, "from __future__ import"로 인한 수정은 버립니다.

   int cf_flags

      컴파일러 플래그.

   int cf_feature_version

      *cf_feature_version*은 부 파이썬 버전입니다. "PY_MINOR_VERSION"
      으로 초기화되어야 합니다.

      이 필드는 기본적으로 무시되며, "PyCF_ONLY_AST" 플래그가
      "cf_flags"에 설정된 경우에만 사용됩니다.

   버전 3.8에서 변경: *cf_feature_version* 필드를 추가했습니다.

   The available compiler flags are accessible as macros:

   PyCF_ALLOW_TOP_LEVEL_AWAIT
   PyCF_ONLY_AST
   PyCF_OPTIMIZED_AST
   PyCF_TYPE_COMMENTS

      See compiler flags in documentation of the "ast" Python module,
      which exports these constants under the same names.

   The ""PyCF"" flags above can be combined with ""CO_FUTURE"" flags
   such as "CO_FUTURE_ANNOTATIONS" to enable features normally
   selectable using future statements. See Code Object Flags for a
   complete list.


Available start symbols
=======================

int Py_eval_input

   격리된 표현식을 위한 파이썬 문법의 시작 기호; "Py_CompileString()"
   과 함께 사용합니다.

int Py_file_input

   파일이나 다른 소스에서 읽은 문장의 시퀀스를 위한 파이썬 문법의 시작
   기호; "Py_CompileString()"과 함께 사용합니다. 임의로 긴 파이썬 소스
   코드를 컴파일할 때 사용하는 기호입니다.

int Py_single_input

   단일 문장을 위한 파이썬 문법의 시작 기호; "Py_CompileString()"과 함
   께 사용합니다. 대화식 인터프리터 루프에 사용되는 기호입니다.

int Py_func_type_input

   The start symbol from the Python grammar for a function type; for
   use with "Py_CompileString()". This is used to parse "signature
   type comments" from **PEP 484**.

   This requires the "PyCF_ONLY_AST" flag to be set.

   더 보기:

     * "ast.FunctionType"

     * **PEP 484**

   Added in version 3.8.


Stack Effects
=============

더 보기: "dis.stack_effect()"

PY_INVALID_STACK_EFFECT

   Sentinel value representing an invalid stack effect.

   This is currently equivalent to "INT_MAX".

   Added in version 3.8.

int PyCompile_OpcodeStackEffect(int opcode, int oparg)

   Compute the stack effect of *opcode* with argument *oparg*.

   On success, this function returns the stack effect; on failure,
   this returns "PY_INVALID_STACK_EFFECT".

   Added in version 3.4.

int PyCompile_OpcodeStackEffectWithJump(int opcode, int oparg, int jump)

   Similar to "PyCompile_OpcodeStackEffect()", but don't include the
   stack effect of jumping if *jump* is zero.

   If *jump* is "0", this will not include the stack effect of
   jumping, but if *jump* is "1" or "-1", this will include it.

   On success, this function returns the stack effect; on failure,
   this returns "PY_INVALID_STACK_EFFECT".

   Added in version 3.8.
