Skip to content

Commit a6c3b0f

Browse files
authored
bpo-45954: Rename PyConfig.no_debug_ranges to code_debug_ranges (GH-29886)
Rename PyConfig.no_debug_ranges to PyConfig.code_debug_ranges and invert the value. Document -X no_debug_ranges and PYTHONNODEBUGRANGES env var in PyConfig.code_debug_ranges documentation.
1 parent cb2b3c8 commit a6c3b0f

File tree

8 files changed

+22
-18
lines changed

8 files changed

+22
-18
lines changed

Doc/c-api/init_config.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -596,13 +596,16 @@ PyConfig
596596
597597
.. versionadded:: 3.10
598598
599-
.. c:member:: int no_debug_ranges
599+
.. c:member:: int code_debug_ranges
600600
601-
If equals to ``1``, disables the inclusion of the end line and column
601+
If equals to ``0``, disables the inclusion of the end line and column
602602
mappings in code objects. Also disables traceback printing carets to
603603
specific error locations.
604604
605-
Default: ``0``.
605+
Set to ``0`` by the :envvar:`PYTHONNODEBUGRANGES` environment variable
606+
and by the :option:`-X no_debug_ranges <-X>` command line option.
607+
608+
Default: ``1``.
606609
607610
.. versionadded:: 3.11
608611

Include/cpython/initconfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ typedef struct PyConfig {
143143
int faulthandler;
144144
int tracemalloc;
145145
int import_time;
146-
int no_debug_ranges;
146+
int code_debug_ranges;
147147
int show_ref_count;
148148
int dump_refs;
149149
wchar_t *dump_refs_file;

Lib/test/_test_embed_set_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# bpo-42260: Test _PyInterpreterState_GetConfigCopy()
22
# and _PyInterpreterState_SetConfig().
33
#
4-
# Test run in a subinterpreter since set_config(get_config())
4+
# Test run in a subprocess since set_config(get_config())
55
# does reset sys attributes to their state of the Python startup
66
# (before the site module is run).
77

@@ -61,7 +61,7 @@ def test_set_invalid(self):
6161
'faulthandler',
6262
'tracemalloc',
6363
'import_time',
64-
'no_debug_ranges',
64+
'code_debug_ranges',
6565
'show_ref_count',
6666
'dump_refs',
6767
'malloc_stats',

Lib/test/support/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ def has_no_debug_ranges():
449449
except ImportError:
450450
raise unittest.SkipTest("_testinternalcapi required")
451451
config = _testinternalcapi.get_config()
452-
return bool(config['no_debug_ranges'])
452+
return not bool(config['code_debug_ranges'])
453453

454454
def requires_debug_ranges(reason='requires co_positions / debug_ranges'):
455455
return unittest.skipIf(has_no_debug_ranges(), reason)

Lib/test/test_embed.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
386386
'faulthandler': 0,
387387
'tracemalloc': 0,
388388
'import_time': 0,
389-
'no_debug_ranges': 0,
389+
'code_debug_ranges': 1,
390390
'show_ref_count': 0,
391391
'dump_refs': 0,
392392
'malloc_stats': 0,
@@ -818,7 +818,7 @@ def test_init_from_config(self):
818818
'hash_seed': 123,
819819
'tracemalloc': 2,
820820
'import_time': 1,
821-
'no_debug_ranges': 1,
821+
'code_debug_ranges': 0,
822822
'show_ref_count': 1,
823823
'malloc_stats': 1,
824824

@@ -878,7 +878,7 @@ def test_init_compat_env(self):
878878
'hash_seed': 42,
879879
'tracemalloc': 2,
880880
'import_time': 1,
881-
'no_debug_ranges': 1,
881+
'code_debug_ranges': 0,
882882
'malloc_stats': 1,
883883
'inspect': 1,
884884
'optimization_level': 2,
@@ -908,7 +908,7 @@ def test_init_python_env(self):
908908
'hash_seed': 42,
909909
'tracemalloc': 2,
910910
'import_time': 1,
911-
'no_debug_ranges': 1,
911+
'code_debug_ranges': 0,
912912
'malloc_stats': 1,
913913
'inspect': 1,
914914
'optimization_level': 2,

Objects/codeobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ _PyCode_New(struct _PyCodeConstructor *con)
381381

382382
// Discard the endlinetable and columntable if we are opted out of debug
383383
// ranges.
384-
if (_Py_GetConfig()->no_debug_ranges) {
384+
if (!_Py_GetConfig()->code_debug_ranges) {
385385
con->endlinetable = Py_None;
386386
con->columntable = Py_None;
387387
}

Programs/_testembed.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ static int test_init_from_config(void)
531531
config.import_time = 1;
532532

533533
putenv("PYTHONNODEBUGRANGES=0");
534-
config.no_debug_ranges = 1;
534+
config.code_debug_ranges = 0;
535535

536536
config.show_ref_count = 1;
537537
/* FIXME: test dump_refs: bpo-34223 */

Python/initconfig.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ config_check_consistency(const PyConfig *config)
614614
assert(config->faulthandler >= 0);
615615
assert(config->tracemalloc >= 0);
616616
assert(config->import_time >= 0);
617-
assert(config->no_debug_ranges >= 0);
617+
assert(config->code_debug_ranges >= 0);
618618
assert(config->show_ref_count >= 0);
619619
assert(config->dump_refs >= 0);
620620
assert(config->malloc_stats >= 0);
@@ -740,6 +740,7 @@ _PyConfig_InitCompatConfig(PyConfig *config)
740740
config->legacy_windows_stdio = -1;
741741
#endif
742742
config->use_frozen_modules = -1;
743+
config->code_debug_ranges = 1;
743744
}
744745

745746

@@ -904,7 +905,7 @@ _PyConfig_Copy(PyConfig *config, const PyConfig *config2)
904905
COPY_ATTR(faulthandler);
905906
COPY_ATTR(tracemalloc);
906907
COPY_ATTR(import_time);
907-
COPY_ATTR(no_debug_ranges);
908+
COPY_ATTR(code_debug_ranges);
908909
COPY_ATTR(show_ref_count);
909910
COPY_ATTR(dump_refs);
910911
COPY_ATTR(dump_refs_file);
@@ -1012,7 +1013,7 @@ _PyConfig_AsDict(const PyConfig *config)
10121013
SET_ITEM_INT(faulthandler);
10131014
SET_ITEM_INT(tracemalloc);
10141015
SET_ITEM_INT(import_time);
1015-
SET_ITEM_INT(no_debug_ranges);
1016+
SET_ITEM_INT(code_debug_ranges);
10161017
SET_ITEM_INT(show_ref_count);
10171018
SET_ITEM_INT(dump_refs);
10181019
SET_ITEM_INT(malloc_stats);
@@ -1291,7 +1292,7 @@ _PyConfig_FromDict(PyConfig *config, PyObject *dict)
12911292
GET_UINT(faulthandler);
12921293
GET_UINT(tracemalloc);
12931294
GET_UINT(import_time);
1294-
GET_UINT(no_debug_ranges);
1295+
GET_UINT(code_debug_ranges);
12951296
GET_UINT(show_ref_count);
12961297
GET_UINT(dump_refs);
12971298
GET_UINT(malloc_stats);
@@ -1853,7 +1854,7 @@ config_read_complex_options(PyConfig *config)
18531854

18541855
if (config_get_env(config, "PYTHONNODEBUGRANGES")
18551856
|| config_get_xoption(config, L"no_debug_ranges")) {
1856-
config->no_debug_ranges = 1;
1857+
config->code_debug_ranges = 0;
18571858
}
18581859

18591860
PyStatus status;

0 commit comments

Comments
 (0)