Nuitka
The Python compiler
Loading...
Searching...
No Matches
mappings.h
1// Copyright 2025, Kay Hayen, mailto:kay.hayen@gmail.com find license text at end of file
2
3#ifndef __NUITKA_MAPPINGS_H__
4#define __NUITKA_MAPPINGS_H__
5
6extern Py_ssize_t Nuitka_PyMapping_Size(PyObject *mapping);
7
8NUITKA_MAY_BE_UNUSED static int MAPPING_HAS_ITEM(PyThreadState *tstate, PyObject *mapping, PyObject *key) {
9 PyObject *result = PyObject_GetItem(mapping, key);
10
11 if (result == NULL) {
12 bool had_key_error = CHECK_AND_CLEAR_KEY_ERROR_OCCURRED(tstate);
13
14 if (had_key_error) {
15 return 0;
16 } else {
17 return -1;
18 }
19 } else {
20 Py_DECREF(result);
21 return 1;
22 }
23}
24
25#endif
26// Part of "Nuitka", an optimizing Python compiler that is compatible and
27// integrates with CPython, but also works on its own.
28//
29// Licensed under the Apache License, Version 2.0 (the "License");
30// you may not use this file except in compliance with the License.
31// You may obtain a copy of the License at
32//
33// http://www.apache.org/licenses/LICENSE-2.0
34//
35// Unless required by applicable law or agreed to in writing, software
36// distributed under the License is distributed on an "AS IS" BASIS,
37// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
38// See the License for the specific language governing permissions and
39// limitations under the License.