FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-119127: functools.partial placeholders by dg-pb · Pull Request #119303 · python/cpython · GitHub

Repository navigation

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
ee7333c
Initial Implementation
dg-pb May 21, 2024
8bcc462
serialization fix
dg-pb May 21, 2024
c67c9b4
bug fix
dg-pb May 21, 2024
680d900
Bug 2 fix
dg-pb May 21, 2024
9591ff5
Py_TPFLAGS_IMMUTABLETYPE added
dg-pb May 21, 2024
067e938
placeholder added to state as opposed to being used as global constant
dg-pb May 23, 2024
8af20b3
static removed
dg-pb May 23, 2024
607a0b1
creating sentinel via PyType_Spec
dg-pb May 23, 2024
f55801e
more accurate variable name
dg-pb May 23, 2024
5894145
trailing trim bug and tests
dg-pb May 24, 2024
3722e07
Updated docs
dg-pb May 24, 2024
a79c2af
blurb
dg-pb May 24, 2024
12aaa72
Merge branch 'main' into implement-119127
May 24, 2024
92c767b
minor edit
dg-pb May 24, 2024
496a9d2
doc fix
dg-pb May 24, 2024
84be524
gh-119180: Update the magic number (#119397)
JelleZijlstra May 25, 2024
de19694
gh-119105: Differ.compare is too slow [for degenerate cases] (#119492)
tim-one May 25, 2024
08e6543
gh-111999: Fix the signature of str.format_map() (#119540)
serhiy-storchaka May 25, 2024
a531fd7
FAQ: Add reference to Python version numbering scheme (#119225)
hugovk May 25, 2024
e3bac04
gh-119548: Add a 'clear' command to the REPL (#119549)
pablogsal May 25, 2024
6b6c1a9
Add codeowners for PYREPL (#119550)
pablogsal May 25, 2024
4b7eb32
gh-99180: Make `StackSummary.should_show_carets` private (#119554)
AlexWaygood May 25, 2024
0c5ebe1
gh-119560: Drop an Invalid Assert in PyState_FindModule() (gh-119561)
ericsnowcurrently May 25, 2024
e418fc3
GH-82805: Fix handling of single-dot file extensions in pathlib (#118…
barneygale May 25, 2024
d25954d
docs: fix a few typos identified by codespell (#119516)
nedbat May 26, 2024
b5b7dc9
Update README and layout.html from 3.13 to 3.14 (#119539)
Wulian233 May 26, 2024
008bc04
gh-119562: Remove AST nodes deprecated since Python 3.8 (#119563)
AlexWaygood May 26, 2024
70b07aa
gh-111997: Fix argument count for LINE event and clarify type of argu…
scoder May 26, 2024
0220663
gh-119562: Remove unused private string constants from `ast.py` (#119…
AlexWaygood May 26, 2024
5d04cc5
gh-102864: Add switching frame test for pdb (#119564)
gaogaotiantian May 26, 2024
5482a93
Re-order imports to align with zipp 3.18.2 (#119587)
jaraco May 27, 2024
5ef5622
Fix typos in HISTORY documentation (#119453)
xyb May 27, 2024
c7a5e1e
``Include/internal/pycore_import.h``: Fix typo (#119586)
Eclips4 May 27, 2024
3b26cd8
gh-119467: Fix Py_buffer.format type and correct documentation typo (…
adiaholic May 27, 2024
041a566
GH-117283: Add doc warning for `PyTuple_SetItem` refcount > 1 (#117916)
savannahostrowski May 27, 2024
59630f9
Docs: Add class role for IPV{4,6}Address and fix a typo (#118059)
rffontenelle May 27, 2024
88e3fee
Docs: Only install sphinx-autobuild for `make htmllive` (#119607)
hugovk May 27, 2024
3dfa364
gh-119580: Improve version added section for convenience variable (#1…
gaogaotiantian May 27, 2024
eea26c4
Docs: Move inline JavaScript to own file to reduce duplication (#119541)
hugovk May 27, 2024
3ff06eb
Withdraw most of my ownership in favor of Mark (#119611)
gvanrossum May 27, 2024
0bd0d40
Misc cleanups and wording improvements for the itertools docs (gh-119…
rhettinger May 27, 2024
ae7b176
gh-119584: Fix test_import Failed Assertion (gh-119623)
ericsnowcurrently May 27, 2024
3e8b609
gh-117398: Add multiphase support to _datetime (gh-119373)
erlend-aasland May 27, 2024
a9a74da
gh-119311: Fix name mangling with PEP 695 generic classes (#119464)
JelleZijlstra May 28, 2024
bf08f0a
Fix typos in comments (#119645)
xyb May 28, 2024
b313cc6
gh-117557: Improve error messages when a string, bytes or bytearray o…
serhiy-storchaka May 28, 2024
669175b
gh-116860: Remove outdated `test_parserhack` from `test_future` (#116…
sobolevn May 28, 2024
b407ad3
[doc] Clarify the nature of the root logger in the `logging` document…
jkunimune May 28, 2024
f912e5a
gh-118824: Remove deprecated `master_open` and `slave_open` from `pty…
sobolevn May 28, 2024
2da0dc0
gh-119659: Move `@no_rerun` to `test.support` (#119660)
sobolevn May 28, 2024
0518edc
gh-119396: Optimize unicode_repr() (#119617)
vstinner May 28, 2024
6ec3712
gh-119581: Add a test of InitVar with name shadowing (#119582)
stroxler May 28, 2024
a89fc26
gh-117398: gh-119655: datetime: Init static state once & don't free i…
encukou May 28, 2024
ae11d68
gh-117865: Defer import of re in ast (#119546)
JelleZijlstra May 28, 2024
6b240c2
gh-119011: `type.__type_params__` now return an empty tuple (#119296)
sobolevn May 28, 2024
ae9140f
gh-119676: remove several pseudo instructions which are use only in c…
iritkatriel May 28, 2024
d87b015
gh-119118: Fix performance regression in tokenize module (#119615)
lysnikolaou May 28, 2024
cfcc054
GH-119476: Split _CHECK_FUNCTION_VERSION out of _CHECK_FUNCTION_EXACT…
brandtbucher May 28, 2024
5cd3ffd
GH-119258: Handle STORE_ATTR_WITH_HINT in tier two (GH-119481)
brandtbucher May 28, 2024
606be66
gh-119538: Add missing expat build dependencies (#119647)
erlend-aasland May 28, 2024
548a11d
gh-117398: Convert datetime.IsoCalendarDate To A Heap Type (gh-119637)
ericsnowcurrently May 28, 2024
a8e35e8
gh-119443: Turn off from __future__ import annotations in REPL (#119493)
JelleZijlstra May 29, 2024
c0faade
gh-119704: Fix reference leak in the ``Python/Python-tokenize.c`` (#1…
Eclips4 May 29, 2024
86d1a1a
gh-119555: catch SyntaxError from compile() in the InteractiveColored…
skirpichev May 29, 2024
cd11ff1
gh-119613: Use C99+ functions instead of Py_IS_NAN/INFINITY/FINITE (#…
skirpichev May 29, 2024
7ca74a7
gh-119661: Add _Py_SINGLETON() include in Argumenet Clinic (#119712)
vstinner May 29, 2024
c1e9647
gh-119689: generate stack effect metadata for pseudo instructions (#1…
iritkatriel May 29, 2024
18c1a8d
gh-97588: Align ctypes struct layout to GCC/MSVC (GH-97702)
matthiasgoergens May 29, 2024
016a46a
gh-93554: add test for quickening of code in loops ending with condit…
iritkatriel May 29, 2024
0cdc5c8
gh-119613: Soft deprecate Py_IS_NAN/INFINITY/FINITE (#119701)
skirpichev May 29, 2024
055c739
CI: set correct working directory for Hypothesis cache (GH-119345)
Zac-HD May 29, 2024
1f481fd
gh-119273: Don't run test_ioctl in a process group (#119275)
vstinner May 29, 2024
34f9b3e
gh-119655: Fix reference leak in the ``_datetimemodule.c`` (gh-119713)
Eclips4 May 29, 2024
78d697b
gh-119690: Adds Unicode support for named pipes in _winapi (GH-119717)
zooba May 29, 2024
659cb7e
gh-119721: Integrate documentation fixes into heapq module docstring.…
filiplajszczak May 29, 2024
c8b45a3
gh-118673: Remove shebang and executable bits from stdlib modules. (#…
jaraco May 29, 2024
0751511
gh-93963: Remove deprecated names from importlib.abc (#119720)
hugovk May 29, 2024
bf4ff3a
gh-119260: Clarify is_dataclass Behavior for Subclasses in Documentat…
adiaholic May 29, 2024
fcca08e
gh-119594: Improve pow(fraction.Fraction(), b, modulo) error message …
wimglenn May 29, 2024
df93f5d
gh-119070: Fix py.exe handling of /usr/bin/env commands missing exten…
zooba May 29, 2024
c22323c
gh-119525: Fix deadlock with `_PyType_Lookup` and the GIL (#119527)
colesbury May 29, 2024
a150679
GH-89727: Partially fix `shutil.rmtree()` recursion error on deep tre…
barneygale May 29, 2024
7ff61f5
GH-119169: Implement `pathlib.Path.walk()` using `os.walk()` (#119573)
barneygale May 29, 2024
2cc3502
subprocess docs: Fix semantically important typo (GH-119752)
zware May 29, 2024
3c890b5
GH-89727: Fix `os.fwalk()` recursion error on deep trees (#119638)
barneygale May 30, 2024
a5fef80
GH-89727: Fix FD leak on `os.fwalk()` generator finalization. (#119766)
barneygale May 30, 2024
48f21b3
gh-118235: Move RAISE_SYNTAX_ERROR actions to invalid rules and make …
encukou May 30, 2024
db00934
gh-118055: Update the finder glossary entry (GH-118278)
Lincoln-developer May 30, 2024
b1374aa
gh-110383: Remove references to removed popen[234] (GH-112783)
shenanigansd May 30, 2024
e50fac9
gh-119336: Restore removed _PyLong_NumBits() function (#119418)
emmatyping May 30, 2024
6fb191b
gh-119779: Fix pyporting howto docs (#119785)
SweetyAngel May 30, 2024
e91fc11
gh-119786: create folder in cpython repo for internals documentation …
iritkatriel May 30, 2024
e875c2d
gh-119791: Fix new Tkinter tests for wantobjects=0 (GH-119792)
serhiy-storchaka May 30, 2024
bf098d4
gh-109218: Refactor tests for the complex() constructor (GH-119635)
serhiy-storchaka May 30, 2024
1c04c63
gh-119729: Use 't' in pkg-config file name for free-threaded build (#…
colesbury May 30, 2024
ec1ba26
gh-109218: Improve documentation for the complex() constructor (GH-11…
serhiy-storchaka May 30, 2024
deda857
Docs: `shutil.rmtree`'s `onerror` has no pending removal version (#11…
hugovk May 30, 2024
ef01e95
gh-109218: Deprecate weird cases in the complex() constructor (GH-119…
serhiy-storchaka May 30, 2024
9732ed5
gh-107262: Update Tkinter tests for Tcl/Tk 8.6.14 (GH-119322)
DBJim May 30, 2024
13a5fdc
gh-119744: move a few functions from compile.c to flowgraph.c (#119745)
iritkatriel May 30, 2024
38d9c11
better variable names and mini corrections
dg-pb May 31, 2024
39a18f8
Initial Implementation
dg-pb May 21, 2024
ee0e1f3
serialization fix
dg-pb May 21, 2024
353ac4d
bug fix
dg-pb May 21, 2024
d287026
Bug 2 fix
dg-pb May 21, 2024
df8ea4c
Py_TPFLAGS_IMMUTABLETYPE added
dg-pb May 21, 2024
0081cbd
placeholder added to state as opposed to being used as global constant
dg-pb May 23, 2024
4b329cd
static removed
dg-pb May 23, 2024
1669ca7
creating sentinel via PyType_Spec
dg-pb May 23, 2024
becd259
more accurate variable name
dg-pb May 23, 2024
6953ab7
trailing trim bug and tests
dg-pb May 24, 2024
544f774
Updated docs
dg-pb May 24, 2024
ce45640
blurb
dg-pb May 24, 2024
38e0ab7
minor edit
dg-pb May 24, 2024
1a5d45f
doc fix
dg-pb May 24, 2024
f5118bd
better variable names and mini corrections. Rebase
dg-pb May 31, 2024
73531ea
merge to main
dg-pb May 31, 2024
980383f
Merge remote-tracking branch 'origin/implement-119127' into implement…
dg-pb May 31, 2024
5a3c478
..
dg-pb May 31, 2024
File filter

Filter by extension

Filter by extension .c  (1) .h  (1) .in  (1) .py  (1) All 4 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
Prev Previous commit
Next Next commit
gh-119396: Optimize unicode_repr() (#119617)
Use stringlib to specialize unicode_repr() for each string kind
(UCS1, UCS2, UCS4).

Benchmark:

+-------------------------------------+---------+----------------------+
| Benchmark                           | ref     | change2              |
+=====================================+=========+======================+
| repr('abc')                         | 100 ns  | 103 ns: 1.02x slower |
+-------------------------------------+---------+----------------------+
| repr('a' * 100)                     | 369 ns  | 369 ns: 1.00x slower |
+-------------------------------------+---------+----------------------+
| repr(('a' + squote) * 100)          | 1.21 us | 946 ns: 1.27x faster |
+-------------------------------------+---------+----------------------+
| repr(('a' + nl) * 100)              | 1.23 us | 907 ns: 1.36x faster |
+-------------------------------------+---------+----------------------+
| repr(dquote + ('a' + squote) * 100) | 1.08 us | 858 ns: 1.25x faster |
+-------------------------------------+---------+----------------------+
| Geometric mean                      | (ref)   | 1.16x faster         |
+-------------------------------------+---------+----------------------+
  • Loading branch information
vstinner authored May 28, 2024
commit 0518edc17049a2f474b049b7d7fe3ef4339ceb83
1 change: 1 addition & 0 deletions Makefile.pre.in
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1841,6 +1841,7 @@ UNICODE_DEPS = \
$(srcdir)/Objects/stringlib/localeutil.h \
$(srcdir)/Objects/stringlib/partition.h \
$(srcdir)/Objects/stringlib/replace.h \
$(srcdir)/Objects/stringlib/repr.h \
$(srcdir)/Objects/stringlib/split.h \
$(srcdir)/Objects/stringlib/ucs1lib.h \
$(srcdir)/Objects/stringlib/ucs2lib.h \
Expand Down
95 changes: 95 additions & 0 deletions Objects/stringlib/repr.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/* stringlib: repr() implementation */

#ifndef STRINGLIB_FASTSEARCH_H
#error must include "stringlib/fastsearch.h" before including this module
#endif


static void
STRINGLIB(repr)(PyObject *unicode, Py_UCS4 quote,
STRINGLIB_CHAR *odata)
{
Py_ssize_t isize = PyUnicode_GET_LENGTH(unicode);
const void *idata = PyUnicode_DATA(unicode);
int ikind = PyUnicode_KIND(unicode);

*odata++ = quote;
for (Py_ssize_t i = 0; i < isize; i++) {
Py_UCS4 ch = PyUnicode_READ(ikind, idata, i);

/* Escape quotes and backslashes */
if ((ch == quote) || (ch == '\\')) {
*odata++ = '\\';
*odata++ = ch;
continue;
}

/* Map special whitespace to '\t', \n', '\r' */
if (ch == '\t') {
*odata++ = '\\';
*odata++ = 't';
}
else if (ch == '\n') {
*odata++ = '\\';
*odata++ = 'n';
}
else if (ch == '\r') {
*odata++ = '\\';
*odata++ = 'r';
}

/* Map non-printable US ASCII to '\xhh' */
else if (ch < ' ' || ch == 0x7F) {
*odata++ = '\\';
*odata++ = 'x';
*odata++ = Py_hexdigits[(ch >> 4) & 0x000F];
*odata++ = Py_hexdigits[ch & 0x000F];
}

/* Copy ASCII characters as-is */
else if (ch < 0x7F) {
*odata++ = ch;
}

/* Non-ASCII characters */
else {
/* Map Unicode whitespace and control characters
(categories Z* and C* except ASCII space)
*/
if (!Py_UNICODE_ISPRINTABLE(ch)) {
*odata++ = '\\';
/* Map 8-bit characters to '\xhh' */
if (ch <= 0xff) {
*odata++ = 'x';
*odata++ = Py_hexdigits[(ch >> 4) & 0x000F];
*odata++ = Py_hexdigits[ch & 0x000F];
}
/* Map 16-bit characters to '\uxxxx' */
else if (ch <= 0xffff) {
*odata++ = 'u';
*odata++ = Py_hexdigits[(ch >> 12) & 0xF];
*odata++ = Py_hexdigits[(ch >> 8) & 0xF];
*odata++ = Py_hexdigits[(ch >> 4) & 0xF];
*odata++ = Py_hexdigits[ch & 0xF];
}
/* Map 21-bit characters to '\U00xxxxxx' */
else {
*odata++ = 'U';
*odata++ = Py_hexdigits[(ch >> 28) & 0xF];
*odata++ = Py_hexdigits[(ch >> 24) & 0xF];
*odata++ = Py_hexdigits[(ch >> 20) & 0xF];
*odata++ = Py_hexdigits[(ch >> 16) & 0xF];
*odata++ = Py_hexdigits[(ch >> 12) & 0xF];
*odata++ = Py_hexdigits[(ch >> 8) & 0xF];
*odata++ = Py_hexdigits[(ch >> 4) & 0xF];
*odata++ = Py_hexdigits[ch & 0xF];
}
}
/* Copy characters as-is */
else {
*odata++ = ch;
}
}
}
*odata = quote;
}
136 changes: 34 additions & 102 deletions Objects/unicodeobject.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,7 @@ ensure_unicode(PyObject *obj)
#include "stringlib/count.h"
#include "stringlib/find.h"
#include "stringlib/replace.h"
#include "stringlib/repr.h"
#include "stringlib/find_max_char.h"
#include "stringlib/undef.h"

Expand All @@ -909,6 +910,7 @@ ensure_unicode(PyObject *obj)
#include "stringlib/count.h"
#include "stringlib/find.h"
#include "stringlib/replace.h"
#include "stringlib/repr.h"
#include "stringlib/find_max_char.h"
#include "stringlib/undef.h"

Expand All @@ -919,6 +921,7 @@ ensure_unicode(PyObject *obj)
#include "stringlib/count.h"
#include "stringlib/find.h"
#include "stringlib/replace.h"
#include "stringlib/repr.h"
#include "stringlib/find_max_char.h"
#include "stringlib/undef.h"

Expand Down Expand Up @@ -12336,24 +12339,17 @@ unicode_removesuffix_impl(PyObject *self, PyObject *suffix)
static PyObject *
unicode_repr(PyObject *unicode)
{
PyObject *repr;
Py_ssize_t isize;
Py_ssize_t osize, squote, dquote, i, o;
Py_UCS4 max, quote;
int ikind, okind, unchanged;
const void *idata;
void *odata;

isize = PyUnicode_GET_LENGTH(unicode);
idata = PyUnicode_DATA(unicode);
Py_ssize_t isize = PyUnicode_GET_LENGTH(unicode);
const void *idata = PyUnicode_DATA(unicode);

/* Compute length of output, quote characters, and
maximum character */
osize = 0;
max = 127;
squote = dquote = 0;
ikind = PyUnicode_KIND(unicode);
for (i = 0; i < isize; i++) {
Py_ssize_t osize = 0;
Py_UCS4 maxch = 127;
Py_ssize_t squote = 0;
Py_ssize_t dquote = 0;
int ikind = PyUnicode_KIND(unicode);
for (Py_ssize_t i = 0; i < isize; i++) {
Py_UCS4 ch = PyUnicode_READ(ikind, idata, i);
Py_ssize_t incr = 1;
switch (ch) {
Expand All @@ -12369,7 +12365,7 @@ unicode_repr(PyObject *unicode)
else if (ch < 0x7f)
;
else if (Py_UNICODE_ISPRINTABLE(ch))
max = ch > max ? ch : max;
maxch = (ch > maxch) ? ch : maxch;
else if (ch < 0x100)
incr = 4; /* \xHH */
else if (ch < 0x10000)
Expand All @@ -12385,10 +12381,10 @@ unicode_repr(PyObject *unicode)
osize += incr;
}

quote = '\'';
unchanged = (osize == isize);
Py_UCS4 quote = '\'';
int changed = (osize != isize);
if (squote) {
unchanged = 0;
changed = 1;
if (dquote)
/* Both squote and dquote present. Use squote,
and escape them */
Expand All @@ -12398,99 +12394,35 @@ unicode_repr(PyObject *unicode)
}
osize += 2; /* quotes */

repr = PyUnicode_New(osize, max);
PyObject *repr = PyUnicode_New(osize, maxch);
if (repr == NULL)
return NULL;
okind = PyUnicode_KIND(repr);
odata = PyUnicode_DATA(repr);
int okind = PyUnicode_KIND(repr);
void *odata = PyUnicode_DATA(repr);

if (!changed) {
PyUnicode_WRITE(okind, odata, 0, quote);

PyUnicode_WRITE(okind, odata, 0, quote);
PyUnicode_WRITE(okind, odata, osize-1, quote);
if (unchanged) {
_PyUnicode_FastCopyCharacters(repr, 1,
unicode, 0,
isize);

PyUnicode_WRITE(okind, odata, osize-1, quote);
}
else {
for (i = 0, o = 1; i < isize; i++) {
Py_UCS4 ch = PyUnicode_READ(ikind, idata, i);

/* Escape quotes and backslashes */
if ((ch == quote) || (ch == '\\')) {
PyUnicode_WRITE(okind, odata, o++, '\\');
PyUnicode_WRITE(okind, odata, o++, ch);
continue;
}

/* Map special whitespace to '\t', \n', '\r' */
if (ch == '\t') {
PyUnicode_WRITE(okind, odata, o++, '\\');
PyUnicode_WRITE(okind, odata, o++, 't');
}
else if (ch == '\n') {
PyUnicode_WRITE(okind, odata, o++, '\\');
PyUnicode_WRITE(okind, odata, o++, 'n');
}
else if (ch == '\r') {
PyUnicode_WRITE(okind, odata, o++, '\\');
PyUnicode_WRITE(okind, odata, o++, 'r');
}

/* Map non-printable US ASCII to '\xhh' */
else if (ch < ' ' || ch == 0x7F) {
PyUnicode_WRITE(okind, odata, o++, '\\');
PyUnicode_WRITE(okind, odata, o++, 'x');
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[(ch >> 4) & 0x000F]);
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[ch & 0x000F]);
}

/* Copy ASCII characters as-is */
else if (ch < 0x7F) {
PyUnicode_WRITE(okind, odata, o++, ch);
}

/* Non-ASCII characters */
else {
/* Map Unicode whitespace and control characters
(categories Z* and C* except ASCII space)
*/
if (!Py_UNICODE_ISPRINTABLE(ch)) {
PyUnicode_WRITE(okind, odata, o++, '\\');
/* Map 8-bit characters to '\xhh' */
if (ch <= 0xff) {
PyUnicode_WRITE(okind, odata, o++, 'x');
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[(ch >> 4) & 0x000F]);
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[ch & 0x000F]);
}
/* Map 16-bit characters to '\uxxxx' */
else if (ch <= 0xffff) {
PyUnicode_WRITE(okind, odata, o++, 'u');
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[(ch >> 12) & 0xF]);
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[(ch >> 8) & 0xF]);
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[(ch >> 4) & 0xF]);
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[ch & 0xF]);
}
/* Map 21-bit characters to '\U00xxxxxx' */
else {
PyUnicode_WRITE(okind, odata, o++, 'U');
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[(ch >> 28) & 0xF]);
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[(ch >> 24) & 0xF]);
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[(ch >> 20) & 0xF]);
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[(ch >> 16) & 0xF]);
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[(ch >> 12) & 0xF]);
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[(ch >> 8) & 0xF]);
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[(ch >> 4) & 0xF]);
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[ch & 0xF]);
}
}
/* Copy characters as-is */
else {
PyUnicode_WRITE(okind, odata, o++, ch);
}
}
switch (okind) {
case PyUnicode_1BYTE_KIND:
ucs1lib_repr(unicode, quote, odata);
break;
case PyUnicode_2BYTE_KIND:
ucs2lib_repr(unicode, quote, odata);
break;
default:
assert(okind == PyUnicode_4BYTE_KIND);
ucs4lib_repr(unicode, quote, odata);
}
}
/* Closing quote already added at the beginning */

assert(_PyUnicode_CheckConsistency(repr, 1));
return repr;
}
Expand Down
1 change: 1 addition & 0 deletions Tools/c-analyzer/cpython/_parser.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def clean_lines(text):
Objects/stringlib/find.h Objects/stringlib/fastsearch.h
Objects/stringlib/partition.h Objects/stringlib/fastsearch.h
Objects/stringlib/replace.h Objects/stringlib/fastsearch.h
Objects/stringlib/repr.h Objects/stringlib/fastsearch.h
Objects/stringlib/split.h Objects/stringlib/fastsearch.h

# @end=tsv@
Expand Down

Back | FazBrowse Home | New Git URL