Skip to content

Commit b617993

Browse files
authored
bpo-40602: Rename hashtable.h to pycore_hashtable.h (GH-20044)
* Move Modules/hashtable.h to Include/internal/pycore_hashtable.h * Move Modules/hashtable.c to Python/hashtable.c * Python is now linked to hashtable.c. _tracemalloc is no longer linked to hashtable.c. Previously, marshal.c got hashtable.c via _tracemalloc.c which is built as a builtin module.
1 parent 21cdb71 commit b617993

File tree

8 files changed

+26
-13
lines changed

8 files changed

+26
-13
lines changed

Modules/hashtable.h renamed to Include/internal/pycore_hashtable.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
#ifndef Py_HASHTABLE_H
2-
#define Py_HASHTABLE_H
3-
/* The whole API is private */
4-
#ifndef Py_LIMITED_API
1+
#ifndef Py_INTERNAL_HASHTABLE_H
2+
#define Py_INTERNAL_HASHTABLE_H
3+
#ifdef __cplusplus
4+
extern "C" {
5+
#endif
6+
7+
#ifndef Py_BUILD_CORE
8+
# error "this header requires Py_BUILD_CORE define"
9+
#endif
510

611
/* Single linked list */
712

@@ -207,5 +212,7 @@ PyAPI_FUNC(int) _Py_hashtable_pop(
207212
_Py_hashtable_pop(TABLE, sizeof(KEY), &(KEY), sizeof(DATA), &(DATA))
208213

209214

210-
#endif /* Py_LIMITED_API */
215+
#ifdef __cplusplus
216+
}
211217
#endif
218+
#endif /* !Py_INTERNAL_HASHTABLE_H */

Makefile.pre.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ PYTHON_OBJS= \
351351
Python/getversion.o \
352352
Python/graminit.o \
353353
Python/hamt.o \
354+
Python/hashtable.o \
354355
Python/import.o \
355356
Python/importdl.o \
356357
Python/initconfig.o \
@@ -1131,6 +1132,7 @@ PYTHON_HEADERS= \
11311132
$(srcdir)/Include/internal/pycore_getopt.h \
11321133
$(srcdir)/Include/internal/pycore_gil.h \
11331134
$(srcdir)/Include/internal/pycore_hamt.h \
1135+
$(srcdir)/Include/internal/pycore_hashtable.h \
11341136
$(srcdir)/Include/internal/pycore_import.h \
11351137
$(srcdir)/Include/internal/pycore_initconfig.h \
11361138
$(srcdir)/Include/internal/pycore_interp.h \

Modules/Setup

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ faulthandler faulthandler.c
132132
#
133133
# bpo-35053: The module must be builtin since _Py_NewReference()
134134
# can call _PyTraceMalloc_NewReference().
135-
_tracemalloc _tracemalloc.c hashtable.c
135+
_tracemalloc _tracemalloc.c
136136

137137
# PEG-based parser module -- slated to be *the* parser
138138
_peg_parser _peg_parser.c

Modules/_tracemalloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "pycore_gc.h" // PyGC_Head
33
#include "pycore_pymem.h" // _Py_tracemalloc_config
44
#include "pycore_traceback.h"
5-
#include "hashtable.h"
5+
#include "pycore_hashtable.h"
66
#include "frameobject.h" // PyFrame_GetBack()
77

88
#include "clinic/_tracemalloc.c.h"

PCbuild/pythoncore.vcxproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@
181181
<ClInclude Include="..\Include\internal\pycore_getopt.h" />
182182
<ClInclude Include="..\Include\internal\pycore_gil.h" />
183183
<ClInclude Include="..\Include\internal\pycore_hamt.h" />
184+
<ClInclude Include="..\Include\internal\pycore_hashtable.h" />
184185
<ClInclude Include="..\Include\internal\pycore_import.h" />
185186
<ClInclude Include="..\Include\internal\pycore_initconfig.h" />
186187
<ClInclude Include="..\Include\internal\pycore_interp.h" />
@@ -335,7 +336,6 @@
335336
<ClCompile Include="..\Modules\errnomodule.c" />
336337
<ClCompile Include="..\Modules\faulthandler.c" />
337338
<ClCompile Include="..\Modules\gcmodule.c" />
338-
<ClCompile Include="..\Modules\hashtable.c" />
339339
<ClCompile Include="..\Modules\itertoolsmodule.c" />
340340
<ClCompile Include="..\Modules\main.c" />
341341
<ClCompile Include="..\Modules\mathmodule.c" />
@@ -462,6 +462,7 @@
462462
<ClCompile Include="..\Python\getversion.c" />
463463
<ClCompile Include="..\Python\graminit.c" />
464464
<ClCompile Include="..\Python\hamt.c" />
465+
<ClCompile Include="..\Python\hashtable.c" />
465466
<ClCompile Include="..\Python\import.c" />
466467
<ClCompile Include="..\Python\importdl.c" />
467468
<ClCompile Include="..\Python\initconfig.c" />

PCbuild/pythoncore.vcxproj.filters

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,9 @@
237237
<ClInclude Include="..\Include\internal\pycore_hamt.h">
238238
<Filter>Include</Filter>
239239
</ClInclude>
240+
<ClInclude Include="..\Include\internal\pycore_hashtable.h">
241+
<Filter>Include</Filter>
242+
</ClInclude>
240243
<ClInclude Include="..\Include\internal\pycore_import.h">
241244
<Filter>Include</Filter>
242245
</ClInclude>
@@ -1034,6 +1037,9 @@
10341037
<ClCompile Include="..\Python\hamt.h">
10351038
<Filter>Python</Filter>
10361039
</ClCompile>
1040+
<ClCompile Include="..\Python\hashtable.c">
1041+
<Filter>Modules</Filter>
1042+
</ClCompile>
10371043
<ClCompile Include="..\Python\import.c">
10381044
<Filter>Python</Filter>
10391045
</ClCompile>
@@ -1142,9 +1148,6 @@
11421148
<ClCompile Include="..\Modules\_tracemalloc.c">
11431149
<Filter>Modules</Filter>
11441150
</ClCompile>
1145-
<ClCompile Include="..\Modules\hashtable.c">
1146-
<Filter>Modules</Filter>
1147-
</ClCompile>
11481151
<ClCompile Include="..\PC\invalid_parameter_handler.c">
11491152
<Filter>PC</Filter>
11501153
</ClCompile>

Modules/hashtable.c renamed to Python/hashtable.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
*/
4646

4747
#include "Python.h"
48-
#include "hashtable.h"
48+
#include "pycore_hashtable.h"
4949

5050
#define HASHTABLE_MIN_SIZE 16
5151
#define HASHTABLE_HIGH 0.50

Python/marshal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "longintrepr.h"
1313
#include "code.h"
1414
#include "marshal.h"
15-
#include "../Modules/hashtable.h"
15+
#include "pycore_hashtable.h"
1616

1717
/*[clinic input]
1818
module marshal

0 commit comments

Comments
 (0)