@@ -191,11 +191,16 @@ this PEP:
191
191
four-element tuples containing the full location of every instruction
192
192
(including start line, end line, start column offset and end column offset)
193
193
or ``None `` if the code object was created without the offset information.
194
- * Three new C-API functions, ``PyCode_Addr2EndLine ``, ``PyCode_Addr2StartOffset ``
195
- and ``PyCode_Addr2EndOffset `` will be added that can obtain the end line, the
196
- start column offsets and the end column offset respectively given the index
197
- of a bytecode instruction. These functions will return 0 if the information
198
- is not available.
194
+ * One new C-API function: ::
195
+
196
+ int PyCode_Addr2Location(
197
+ PyCodeObject *co, int addr,
198
+ int *startline, int *startcolumn,
199
+ int *endline, int *endcolumn)
200
+
201
+ will be added so the end line, the start column offsets and the end column
202
+ offset can be obtained given the index of a bytecode instruction. This
203
+ function will set the values to 0 if the information is not available.
199
204
200
205
The internal storage, compression and encoding of the information is left as an
201
206
implementation detail and can be changed at any point as long as the public API
@@ -311,18 +316,22 @@ storage and memory overhead and to allow third party tools and other
311
316
programs that are currently parsing tracebacks to catch up the following
312
317
methods will be provided to deactivate this feature:
313
318
314
- * A new environment variable: ``PYNODEBUGRANGES ``.
319
+ * A new environment variable: ``PYTHONNODEBUGRANGES ``.
315
320
* A new command line option for the dev mode: ``python -Xnodebugranges ``.
316
321
317
322
If any of these methods are used, the Python compiler will **not ** populate
318
323
code objects with the new information (``None `` will be used instead) and any
319
324
unmarshalled code objects that contain the extra information will have it stripped
320
- away and replaced with ``None ``). This method allows users to:
325
+ away and replaced with ``None ``). Additionally, the traceback machinery will not
326
+ show the extended location information even if the information was present.
327
+ This method allows users to:
321
328
322
329
* Create smaller ``pyc `` files by using one of the two methods when said files
323
330
are created.
324
331
* Don't load the extra information from ``pyc `` files if those were created with
325
332
the extra information in the first place.
333
+ * Deactivate the extra information when displaying tracebacks (the caret characters
334
+ indicating the location of the error).
326
335
327
336
Doing this has a **very small ** performance hit as the interpreter state needs
328
337
to be fetched when code objects are created to look up the configuration.
0 commit comments