import.c.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. /*[clinic input]
  2. preserve
  3. [clinic start generated code]*/
  4. #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
  5. # include "pycore_gc.h" // PyGC_Head
  6. # include "pycore_runtime.h" // _Py_ID()
  7. #endif
  8. PyDoc_STRVAR(_imp_lock_held__doc__,
  9. "lock_held($module, /)\n"
  10. "--\n"
  11. "\n"
  12. "Return True if the import lock is currently held, else False.\n"
  13. "\n"
  14. "On platforms without threads, return False.");
  15. #define _IMP_LOCK_HELD_METHODDEF \
  16. {"lock_held", (PyCFunction)_imp_lock_held, METH_NOARGS, _imp_lock_held__doc__},
  17. static PyObject *
  18. _imp_lock_held_impl(PyObject *module);
  19. static PyObject *
  20. _imp_lock_held(PyObject *module, PyObject *Py_UNUSED(ignored))
  21. {
  22. return _imp_lock_held_impl(module);
  23. }
  24. PyDoc_STRVAR(_imp_acquire_lock__doc__,
  25. "acquire_lock($module, /)\n"
  26. "--\n"
  27. "\n"
  28. "Acquires the interpreter\'s import lock for the current thread.\n"
  29. "\n"
  30. "This lock should be used by import hooks to ensure thread-safety when importing\n"
  31. "modules. On platforms without threads, this function does nothing.");
  32. #define _IMP_ACQUIRE_LOCK_METHODDEF \
  33. {"acquire_lock", (PyCFunction)_imp_acquire_lock, METH_NOARGS, _imp_acquire_lock__doc__},
  34. static PyObject *
  35. _imp_acquire_lock_impl(PyObject *module);
  36. static PyObject *
  37. _imp_acquire_lock(PyObject *module, PyObject *Py_UNUSED(ignored))
  38. {
  39. return _imp_acquire_lock_impl(module);
  40. }
  41. PyDoc_STRVAR(_imp_release_lock__doc__,
  42. "release_lock($module, /)\n"
  43. "--\n"
  44. "\n"
  45. "Release the interpreter\'s import lock.\n"
  46. "\n"
  47. "On platforms without threads, this function does nothing.");
  48. #define _IMP_RELEASE_LOCK_METHODDEF \
  49. {"release_lock", (PyCFunction)_imp_release_lock, METH_NOARGS, _imp_release_lock__doc__},
  50. static PyObject *
  51. _imp_release_lock_impl(PyObject *module);
  52. static PyObject *
  53. _imp_release_lock(PyObject *module, PyObject *Py_UNUSED(ignored))
  54. {
  55. return _imp_release_lock_impl(module);
  56. }
  57. PyDoc_STRVAR(_imp__fix_co_filename__doc__,
  58. "_fix_co_filename($module, code, path, /)\n"
  59. "--\n"
  60. "\n"
  61. "Changes code.co_filename to specify the passed-in file path.\n"
  62. "\n"
  63. " code\n"
  64. " Code object to change.\n"
  65. " path\n"
  66. " File path to use.");
  67. #define _IMP__FIX_CO_FILENAME_METHODDEF \
  68. {"_fix_co_filename", _PyCFunction_CAST(_imp__fix_co_filename), METH_FASTCALL, _imp__fix_co_filename__doc__},
  69. static PyObject *
  70. _imp__fix_co_filename_impl(PyObject *module, PyCodeObject *code,
  71. PyObject *path);
  72. static PyObject *
  73. _imp__fix_co_filename(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
  74. {
  75. PyObject *return_value = NULL;
  76. PyCodeObject *code;
  77. PyObject *path;
  78. if (!_PyArg_CheckPositional("_fix_co_filename", nargs, 2, 2)) {
  79. goto exit;
  80. }
  81. if (!PyObject_TypeCheck(args[0], &PyCode_Type)) {
  82. _PyArg_BadArgument("_fix_co_filename", "argument 1", (&PyCode_Type)->tp_name, args[0]);
  83. goto exit;
  84. }
  85. code = (PyCodeObject *)args[0];
  86. if (!PyUnicode_Check(args[1])) {
  87. _PyArg_BadArgument("_fix_co_filename", "argument 2", "str", args[1]);
  88. goto exit;
  89. }
  90. if (PyUnicode_READY(args[1]) == -1) {
  91. goto exit;
  92. }
  93. path = args[1];
  94. return_value = _imp__fix_co_filename_impl(module, code, path);
  95. exit:
  96. return return_value;
  97. }
  98. PyDoc_STRVAR(_imp_create_builtin__doc__,
  99. "create_builtin($module, spec, /)\n"
  100. "--\n"
  101. "\n"
  102. "Create an extension module.");
  103. #define _IMP_CREATE_BUILTIN_METHODDEF \
  104. {"create_builtin", (PyCFunction)_imp_create_builtin, METH_O, _imp_create_builtin__doc__},
  105. PyDoc_STRVAR(_imp_extension_suffixes__doc__,
  106. "extension_suffixes($module, /)\n"
  107. "--\n"
  108. "\n"
  109. "Returns the list of file suffixes used to identify extension modules.");
  110. #define _IMP_EXTENSION_SUFFIXES_METHODDEF \
  111. {"extension_suffixes", (PyCFunction)_imp_extension_suffixes, METH_NOARGS, _imp_extension_suffixes__doc__},
  112. static PyObject *
  113. _imp_extension_suffixes_impl(PyObject *module);
  114. static PyObject *
  115. _imp_extension_suffixes(PyObject *module, PyObject *Py_UNUSED(ignored))
  116. {
  117. return _imp_extension_suffixes_impl(module);
  118. }
  119. PyDoc_STRVAR(_imp_init_frozen__doc__,
  120. "init_frozen($module, name, /)\n"
  121. "--\n"
  122. "\n"
  123. "Initializes a frozen module.");
  124. #define _IMP_INIT_FROZEN_METHODDEF \
  125. {"init_frozen", (PyCFunction)_imp_init_frozen, METH_O, _imp_init_frozen__doc__},
  126. static PyObject *
  127. _imp_init_frozen_impl(PyObject *module, PyObject *name);
  128. static PyObject *
  129. _imp_init_frozen(PyObject *module, PyObject *arg)
  130. {
  131. PyObject *return_value = NULL;
  132. PyObject *name;
  133. if (!PyUnicode_Check(arg)) {
  134. _PyArg_BadArgument("init_frozen", "argument", "str", arg);
  135. goto exit;
  136. }
  137. if (PyUnicode_READY(arg) == -1) {
  138. goto exit;
  139. }
  140. name = arg;
  141. return_value = _imp_init_frozen_impl(module, name);
  142. exit:
  143. return return_value;
  144. }
  145. PyDoc_STRVAR(_imp_find_frozen__doc__,
  146. "find_frozen($module, name, /, *, withdata=False)\n"
  147. "--\n"
  148. "\n"
  149. "Return info about the corresponding frozen module (if there is one) or None.\n"
  150. "\n"
  151. "The returned info (a 2-tuple):\n"
  152. "\n"
  153. " * data the raw marshalled bytes\n"
  154. " * is_package whether or not it is a package\n"
  155. " * origname the originally frozen module\'s name, or None if not\n"
  156. " a stdlib module (this will usually be the same as\n"
  157. " the module\'s current name)");
  158. #define _IMP_FIND_FROZEN_METHODDEF \
  159. {"find_frozen", _PyCFunction_CAST(_imp_find_frozen), METH_FASTCALL|METH_KEYWORDS, _imp_find_frozen__doc__},
  160. static PyObject *
  161. _imp_find_frozen_impl(PyObject *module, PyObject *name, int withdata);
  162. static PyObject *
  163. _imp_find_frozen(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
  164. {
  165. PyObject *return_value = NULL;
  166. #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
  167. #define NUM_KEYWORDS 1
  168. static struct {
  169. PyGC_Head _this_is_not_used;
  170. PyObject_VAR_HEAD
  171. PyObject *ob_item[NUM_KEYWORDS];
  172. } _kwtuple = {
  173. .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
  174. .ob_item = { &_Py_ID(withdata), },
  175. };
  176. #undef NUM_KEYWORDS
  177. #define KWTUPLE (&_kwtuple.ob_base.ob_base)
  178. #else // !Py_BUILD_CORE
  179. # define KWTUPLE NULL
  180. #endif // !Py_BUILD_CORE
  181. static const char * const _keywords[] = {"", "withdata", NULL};
  182. static _PyArg_Parser _parser = {
  183. .keywords = _keywords,
  184. .fname = "find_frozen",
  185. .kwtuple = KWTUPLE,
  186. };
  187. #undef KWTUPLE
  188. PyObject *argsbuf[2];
  189. Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
  190. PyObject *name;
  191. int withdata = 0;
  192. args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
  193. if (!args) {
  194. goto exit;
  195. }
  196. if (!PyUnicode_Check(args[0])) {
  197. _PyArg_BadArgument("find_frozen", "argument 1", "str", args[0]);
  198. goto exit;
  199. }
  200. if (PyUnicode_READY(args[0]) == -1) {
  201. goto exit;
  202. }
  203. name = args[0];
  204. if (!noptargs) {
  205. goto skip_optional_kwonly;
  206. }
  207. withdata = PyObject_IsTrue(args[1]);
  208. if (withdata < 0) {
  209. goto exit;
  210. }
  211. skip_optional_kwonly:
  212. return_value = _imp_find_frozen_impl(module, name, withdata);
  213. exit:
  214. return return_value;
  215. }
  216. PyDoc_STRVAR(_imp_get_frozen_object__doc__,
  217. "get_frozen_object($module, name, data=None, /)\n"
  218. "--\n"
  219. "\n"
  220. "Create a code object for a frozen module.");
  221. #define _IMP_GET_FROZEN_OBJECT_METHODDEF \
  222. {"get_frozen_object", _PyCFunction_CAST(_imp_get_frozen_object), METH_FASTCALL, _imp_get_frozen_object__doc__},
  223. static PyObject *
  224. _imp_get_frozen_object_impl(PyObject *module, PyObject *name,
  225. PyObject *dataobj);
  226. static PyObject *
  227. _imp_get_frozen_object(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
  228. {
  229. PyObject *return_value = NULL;
  230. PyObject *name;
  231. PyObject *dataobj = Py_None;
  232. if (!_PyArg_CheckPositional("get_frozen_object", nargs, 1, 2)) {
  233. goto exit;
  234. }
  235. if (!PyUnicode_Check(args[0])) {
  236. _PyArg_BadArgument("get_frozen_object", "argument 1", "str", args[0]);
  237. goto exit;
  238. }
  239. if (PyUnicode_READY(args[0]) == -1) {
  240. goto exit;
  241. }
  242. name = args[0];
  243. if (nargs < 2) {
  244. goto skip_optional;
  245. }
  246. dataobj = args[1];
  247. skip_optional:
  248. return_value = _imp_get_frozen_object_impl(module, name, dataobj);
  249. exit:
  250. return return_value;
  251. }
  252. PyDoc_STRVAR(_imp_is_frozen_package__doc__,
  253. "is_frozen_package($module, name, /)\n"
  254. "--\n"
  255. "\n"
  256. "Returns True if the module name is of a frozen package.");
  257. #define _IMP_IS_FROZEN_PACKAGE_METHODDEF \
  258. {"is_frozen_package", (PyCFunction)_imp_is_frozen_package, METH_O, _imp_is_frozen_package__doc__},
  259. static PyObject *
  260. _imp_is_frozen_package_impl(PyObject *module, PyObject *name);
  261. static PyObject *
  262. _imp_is_frozen_package(PyObject *module, PyObject *arg)
  263. {
  264. PyObject *return_value = NULL;
  265. PyObject *name;
  266. if (!PyUnicode_Check(arg)) {
  267. _PyArg_BadArgument("is_frozen_package", "argument", "str", arg);
  268. goto exit;
  269. }
  270. if (PyUnicode_READY(arg) == -1) {
  271. goto exit;
  272. }
  273. name = arg;
  274. return_value = _imp_is_frozen_package_impl(module, name);
  275. exit:
  276. return return_value;
  277. }
  278. PyDoc_STRVAR(_imp_is_builtin__doc__,
  279. "is_builtin($module, name, /)\n"
  280. "--\n"
  281. "\n"
  282. "Returns True if the module name corresponds to a built-in module.");
  283. #define _IMP_IS_BUILTIN_METHODDEF \
  284. {"is_builtin", (PyCFunction)_imp_is_builtin, METH_O, _imp_is_builtin__doc__},
  285. static PyObject *
  286. _imp_is_builtin_impl(PyObject *module, PyObject *name);
  287. static PyObject *
  288. _imp_is_builtin(PyObject *module, PyObject *arg)
  289. {
  290. PyObject *return_value = NULL;
  291. PyObject *name;
  292. if (!PyUnicode_Check(arg)) {
  293. _PyArg_BadArgument("is_builtin", "argument", "str", arg);
  294. goto exit;
  295. }
  296. if (PyUnicode_READY(arg) == -1) {
  297. goto exit;
  298. }
  299. name = arg;
  300. return_value = _imp_is_builtin_impl(module, name);
  301. exit:
  302. return return_value;
  303. }
  304. PyDoc_STRVAR(_imp_is_frozen__doc__,
  305. "is_frozen($module, name, /)\n"
  306. "--\n"
  307. "\n"
  308. "Returns True if the module name corresponds to a frozen module.");
  309. #define _IMP_IS_FROZEN_METHODDEF \
  310. {"is_frozen", (PyCFunction)_imp_is_frozen, METH_O, _imp_is_frozen__doc__},
  311. static PyObject *
  312. _imp_is_frozen_impl(PyObject *module, PyObject *name);
  313. static PyObject *
  314. _imp_is_frozen(PyObject *module, PyObject *arg)
  315. {
  316. PyObject *return_value = NULL;
  317. PyObject *name;
  318. if (!PyUnicode_Check(arg)) {
  319. _PyArg_BadArgument("is_frozen", "argument", "str", arg);
  320. goto exit;
  321. }
  322. if (PyUnicode_READY(arg) == -1) {
  323. goto exit;
  324. }
  325. name = arg;
  326. return_value = _imp_is_frozen_impl(module, name);
  327. exit:
  328. return return_value;
  329. }
  330. PyDoc_STRVAR(_imp__frozen_module_names__doc__,
  331. "_frozen_module_names($module, /)\n"
  332. "--\n"
  333. "\n"
  334. "Returns the list of available frozen modules.");
  335. #define _IMP__FROZEN_MODULE_NAMES_METHODDEF \
  336. {"_frozen_module_names", (PyCFunction)_imp__frozen_module_names, METH_NOARGS, _imp__frozen_module_names__doc__},
  337. static PyObject *
  338. _imp__frozen_module_names_impl(PyObject *module);
  339. static PyObject *
  340. _imp__frozen_module_names(PyObject *module, PyObject *Py_UNUSED(ignored))
  341. {
  342. return _imp__frozen_module_names_impl(module);
  343. }
  344. PyDoc_STRVAR(_imp__override_frozen_modules_for_tests__doc__,
  345. "_override_frozen_modules_for_tests($module, override, /)\n"
  346. "--\n"
  347. "\n"
  348. "(internal-only) Override PyConfig.use_frozen_modules.\n"
  349. "\n"
  350. "(-1: \"off\", 1: \"on\", 0: no override)\n"
  351. "See frozen_modules() in Lib/test/support/import_helper.py.");
  352. #define _IMP__OVERRIDE_FROZEN_MODULES_FOR_TESTS_METHODDEF \
  353. {"_override_frozen_modules_for_tests", (PyCFunction)_imp__override_frozen_modules_for_tests, METH_O, _imp__override_frozen_modules_for_tests__doc__},
  354. static PyObject *
  355. _imp__override_frozen_modules_for_tests_impl(PyObject *module, int override);
  356. static PyObject *
  357. _imp__override_frozen_modules_for_tests(PyObject *module, PyObject *arg)
  358. {
  359. PyObject *return_value = NULL;
  360. int override;
  361. override = _PyLong_AsInt(arg);
  362. if (override == -1 && PyErr_Occurred()) {
  363. goto exit;
  364. }
  365. return_value = _imp__override_frozen_modules_for_tests_impl(module, override);
  366. exit:
  367. return return_value;
  368. }
  369. PyDoc_STRVAR(_imp__override_multi_interp_extensions_check__doc__,
  370. "_override_multi_interp_extensions_check($module, override, /)\n"
  371. "--\n"
  372. "\n"
  373. "(internal-only) Override PyInterpreterConfig.check_multi_interp_extensions.\n"
  374. "\n"
  375. "(-1: \"never\", 1: \"always\", 0: no override)");
  376. #define _IMP__OVERRIDE_MULTI_INTERP_EXTENSIONS_CHECK_METHODDEF \
  377. {"_override_multi_interp_extensions_check", (PyCFunction)_imp__override_multi_interp_extensions_check, METH_O, _imp__override_multi_interp_extensions_check__doc__},
  378. static PyObject *
  379. _imp__override_multi_interp_extensions_check_impl(PyObject *module,
  380. int override);
  381. static PyObject *
  382. _imp__override_multi_interp_extensions_check(PyObject *module, PyObject *arg)
  383. {
  384. PyObject *return_value = NULL;
  385. int override;
  386. override = _PyLong_AsInt(arg);
  387. if (override == -1 && PyErr_Occurred()) {
  388. goto exit;
  389. }
  390. return_value = _imp__override_multi_interp_extensions_check_impl(module, override);
  391. exit:
  392. return return_value;
  393. }
  394. #if defined(HAVE_DYNAMIC_LOADING)
  395. PyDoc_STRVAR(_imp_create_dynamic__doc__,
  396. "create_dynamic($module, spec, file=<unrepresentable>, /)\n"
  397. "--\n"
  398. "\n"
  399. "Create an extension module.");
  400. #define _IMP_CREATE_DYNAMIC_METHODDEF \
  401. {"create_dynamic", _PyCFunction_CAST(_imp_create_dynamic), METH_FASTCALL, _imp_create_dynamic__doc__},
  402. static PyObject *
  403. _imp_create_dynamic_impl(PyObject *module, PyObject *spec, PyObject *file);
  404. static PyObject *
  405. _imp_create_dynamic(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
  406. {
  407. PyObject *return_value = NULL;
  408. PyObject *spec;
  409. PyObject *file = NULL;
  410. if (!_PyArg_CheckPositional("create_dynamic", nargs, 1, 2)) {
  411. goto exit;
  412. }
  413. spec = args[0];
  414. if (nargs < 2) {
  415. goto skip_optional;
  416. }
  417. file = args[1];
  418. skip_optional:
  419. return_value = _imp_create_dynamic_impl(module, spec, file);
  420. exit:
  421. return return_value;
  422. }
  423. #endif /* defined(HAVE_DYNAMIC_LOADING) */
  424. #if defined(HAVE_DYNAMIC_LOADING)
  425. PyDoc_STRVAR(_imp_exec_dynamic__doc__,
  426. "exec_dynamic($module, mod, /)\n"
  427. "--\n"
  428. "\n"
  429. "Initialize an extension module.");
  430. #define _IMP_EXEC_DYNAMIC_METHODDEF \
  431. {"exec_dynamic", (PyCFunction)_imp_exec_dynamic, METH_O, _imp_exec_dynamic__doc__},
  432. static int
  433. _imp_exec_dynamic_impl(PyObject *module, PyObject *mod);
  434. static PyObject *
  435. _imp_exec_dynamic(PyObject *module, PyObject *mod)
  436. {
  437. PyObject *return_value = NULL;
  438. int _return_value;
  439. _return_value = _imp_exec_dynamic_impl(module, mod);
  440. if ((_return_value == -1) && PyErr_Occurred()) {
  441. goto exit;
  442. }
  443. return_value = PyLong_FromLong((long)_return_value);
  444. exit:
  445. return return_value;
  446. }
  447. #endif /* defined(HAVE_DYNAMIC_LOADING) */
  448. PyDoc_STRVAR(_imp_exec_builtin__doc__,
  449. "exec_builtin($module, mod, /)\n"
  450. "--\n"
  451. "\n"
  452. "Initialize a built-in module.");
  453. #define _IMP_EXEC_BUILTIN_METHODDEF \
  454. {"exec_builtin", (PyCFunction)_imp_exec_builtin, METH_O, _imp_exec_builtin__doc__},
  455. static int
  456. _imp_exec_builtin_impl(PyObject *module, PyObject *mod);
  457. static PyObject *
  458. _imp_exec_builtin(PyObject *module, PyObject *mod)
  459. {
  460. PyObject *return_value = NULL;
  461. int _return_value;
  462. _return_value = _imp_exec_builtin_impl(module, mod);
  463. if ((_return_value == -1) && PyErr_Occurred()) {
  464. goto exit;
  465. }
  466. return_value = PyLong_FromLong((long)_return_value);
  467. exit:
  468. return return_value;
  469. }
  470. PyDoc_STRVAR(_imp_source_hash__doc__,
  471. "source_hash($module, /, key, source)\n"
  472. "--\n"
  473. "\n");
  474. #define _IMP_SOURCE_HASH_METHODDEF \
  475. {"source_hash", _PyCFunction_CAST(_imp_source_hash), METH_FASTCALL|METH_KEYWORDS, _imp_source_hash__doc__},
  476. static PyObject *
  477. _imp_source_hash_impl(PyObject *module, long key, Py_buffer *source);
  478. static PyObject *
  479. _imp_source_hash(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
  480. {
  481. PyObject *return_value = NULL;
  482. #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
  483. #define NUM_KEYWORDS 2
  484. static struct {
  485. PyGC_Head _this_is_not_used;
  486. PyObject_VAR_HEAD
  487. PyObject *ob_item[NUM_KEYWORDS];
  488. } _kwtuple = {
  489. .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
  490. .ob_item = { &_Py_ID(key), &_Py_ID(source), },
  491. };
  492. #undef NUM_KEYWORDS
  493. #define KWTUPLE (&_kwtuple.ob_base.ob_base)
  494. #else // !Py_BUILD_CORE
  495. # define KWTUPLE NULL
  496. #endif // !Py_BUILD_CORE
  497. static const char * const _keywords[] = {"key", "source", NULL};
  498. static _PyArg_Parser _parser = {
  499. .keywords = _keywords,
  500. .fname = "source_hash",
  501. .kwtuple = KWTUPLE,
  502. };
  503. #undef KWTUPLE
  504. PyObject *argsbuf[2];
  505. long key;
  506. Py_buffer source = {NULL, NULL};
  507. args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);
  508. if (!args) {
  509. goto exit;
  510. }
  511. key = PyLong_AsLong(args[0]);
  512. if (key == -1 && PyErr_Occurred()) {
  513. goto exit;
  514. }
  515. if (PyObject_GetBuffer(args[1], &source, PyBUF_SIMPLE) != 0) {
  516. goto exit;
  517. }
  518. if (!PyBuffer_IsContiguous(&source, 'C')) {
  519. _PyArg_BadArgument("source_hash", "argument 'source'", "contiguous buffer", args[1]);
  520. goto exit;
  521. }
  522. return_value = _imp_source_hash_impl(module, key, &source);
  523. exit:
  524. /* Cleanup for source */
  525. if (source.obj) {
  526. PyBuffer_Release(&source);
  527. }
  528. return return_value;
  529. }
  530. #ifndef _IMP_CREATE_DYNAMIC_METHODDEF
  531. #define _IMP_CREATE_DYNAMIC_METHODDEF
  532. #endif /* !defined(_IMP_CREATE_DYNAMIC_METHODDEF) */
  533. #ifndef _IMP_EXEC_DYNAMIC_METHODDEF
  534. #define _IMP_EXEC_DYNAMIC_METHODDEF
  535. #endif /* !defined(_IMP_EXEC_DYNAMIC_METHODDEF) */
  536. /*[clinic end generated code: output=b18d46e0036eff49 input=a9049054013a1b77]*/