Mercurial > cpython-lru_cache-weakref
annotate Objects/bytes_methods.c @ 58689:514b56efd89a 3.1
Merged revisions 77962 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r77962 | r.david.murray | 2010-02-04 11:41:57 -0500 (Thu, 04 Feb 2010) | 17 lines
Merged revisions 77943,77959-77960 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77943 | r.david.murray | 2010-02-03 08:36:23 -0500 (Wed, 03 Feb 2010) | 2 lines
Explicitly mention the default value for formatdate's usegmt parameter.
........
r77959 | nick.coghlan | 2010-02-04 07:43:58 -0500 (Thu, 04 Feb 2010) | 1 line
Issue 6760: Clarify args handling for subprocess.Popen. Patch by Chris Rebert
........
r77960 | r.david.murray | 2010-02-04 11:33:31 -0500 (Thu, 04 Feb 2010) | 2 lines
Add Chris Rebert to ACKS for issue 6760 Popen doc improvements.
........
................
| author | R. David Murray <rdmurray@bitdance.com> |
|---|---|
| date | Thu, 04 Feb 2010 16:44:31 +0000 |
| parents | 67bb17c2e868 |
| children | cab14be0ada1 |
| rev | line source |
|---|---|
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
1 #include "Python.h" |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
2 #include "bytes_methods.h" |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
3 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
4 PyDoc_STRVAR_shared(_Py_isspace__doc__, |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
5 "B.isspace() -> bool\n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
6 \n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
7 Return True if all characters in B are whitespace\n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
8 and there is at least one character in B, False otherwise."); |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
9 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
10 PyObject* |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
11 _Py_bytes_isspace(const char *cptr, Py_ssize_t len) |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
12 { |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
13 register const unsigned char *p |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
14 = (unsigned char *) cptr; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
15 register const unsigned char *e; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
16 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
17 /* Shortcut for single character strings */ |
|
53543
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
18 if (len == 1 && Py_ISSPACE(*p)) |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
19 Py_RETURN_TRUE; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
20 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
21 /* Special case for empty strings */ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
22 if (len == 0) |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
23 Py_RETURN_FALSE; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
24 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
25 e = p + len; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
26 for (; p < e; p++) { |
|
53543
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
27 if (!Py_ISSPACE(*p)) |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
28 Py_RETURN_FALSE; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
29 } |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
30 Py_RETURN_TRUE; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
31 } |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
32 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
33 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
34 PyDoc_STRVAR_shared(_Py_isalpha__doc__, |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
35 "B.isalpha() -> bool\n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
36 \n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
37 Return True if all characters in B are alphabetic\n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
38 and there is at least one character in B, False otherwise."); |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
39 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
40 PyObject* |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
41 _Py_bytes_isalpha(const char *cptr, Py_ssize_t len) |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
42 { |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
43 register const unsigned char *p |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
44 = (unsigned char *) cptr; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
45 register const unsigned char *e; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
46 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
47 /* Shortcut for single character strings */ |
|
53543
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
48 if (len == 1 && Py_ISALPHA(*p)) |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
49 Py_RETURN_TRUE; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
50 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
51 /* Special case for empty strings */ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
52 if (len == 0) |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
53 Py_RETURN_FALSE; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
54 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
55 e = p + len; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
56 for (; p < e; p++) { |
|
53543
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
57 if (!Py_ISALPHA(*p)) |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
58 Py_RETURN_FALSE; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
59 } |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
60 Py_RETURN_TRUE; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
61 } |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
62 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
63 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
64 PyDoc_STRVAR_shared(_Py_isalnum__doc__, |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
65 "B.isalnum() -> bool\n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
66 \n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
67 Return True if all characters in B are alphanumeric\n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
68 and there is at least one character in B, False otherwise."); |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
69 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
70 PyObject* |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
71 _Py_bytes_isalnum(const char *cptr, Py_ssize_t len) |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
72 { |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
73 register const unsigned char *p |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
74 = (unsigned char *) cptr; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
75 register const unsigned char *e; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
76 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
77 /* Shortcut for single character strings */ |
|
53543
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
78 if (len == 1 && Py_ISALNUM(*p)) |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
79 Py_RETURN_TRUE; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
80 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
81 /* Special case for empty strings */ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
82 if (len == 0) |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
83 Py_RETURN_FALSE; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
84 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
85 e = p + len; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
86 for (; p < e; p++) { |
|
53543
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
87 if (!Py_ISALNUM(*p)) |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
88 Py_RETURN_FALSE; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
89 } |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
90 Py_RETURN_TRUE; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
91 } |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
92 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
93 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
94 PyDoc_STRVAR_shared(_Py_isdigit__doc__, |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
95 "B.isdigit() -> bool\n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
96 \n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
97 Return True if all characters in B are digits\n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
98 and there is at least one character in B, False otherwise."); |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
99 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
100 PyObject* |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
101 _Py_bytes_isdigit(const char *cptr, Py_ssize_t len) |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
102 { |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
103 register const unsigned char *p |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
104 = (unsigned char *) cptr; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
105 register const unsigned char *e; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
106 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
107 /* Shortcut for single character strings */ |
|
53543
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
108 if (len == 1 && Py_ISDIGIT(*p)) |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
109 Py_RETURN_TRUE; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
110 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
111 /* Special case for empty strings */ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
112 if (len == 0) |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
113 Py_RETURN_FALSE; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
114 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
115 e = p + len; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
116 for (; p < e; p++) { |
|
53543
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
117 if (!Py_ISDIGIT(*p)) |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
118 Py_RETURN_FALSE; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
119 } |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
120 Py_RETURN_TRUE; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
121 } |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
122 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
123 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
124 PyDoc_STRVAR_shared(_Py_islower__doc__, |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
125 "B.islower() -> bool\n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
126 \n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
127 Return True if all cased characters in B are lowercase and there is\n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
128 at least one cased character in B, False otherwise."); |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
129 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
130 PyObject* |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
131 _Py_bytes_islower(const char *cptr, Py_ssize_t len) |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
132 { |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
133 register const unsigned char *p |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
134 = (unsigned char *) cptr; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
135 register const unsigned char *e; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
136 int cased; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
137 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
138 /* Shortcut for single character strings */ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
139 if (len == 1) |
|
53543
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
140 return PyBool_FromLong(Py_ISLOWER(*p)); |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
141 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
142 /* Special case for empty strings */ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
143 if (len == 0) |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
144 Py_RETURN_FALSE; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
145 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
146 e = p + len; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
147 cased = 0; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
148 for (; p < e; p++) { |
|
53543
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
149 if (Py_ISUPPER(*p)) |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
150 Py_RETURN_FALSE; |
|
53543
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
151 else if (!cased && Py_ISLOWER(*p)) |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
152 cased = 1; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
153 } |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
154 return PyBool_FromLong(cased); |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
155 } |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
156 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
157 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
158 PyDoc_STRVAR_shared(_Py_isupper__doc__, |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
159 "B.isupper() -> bool\n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
160 \n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
161 Return True if all cased characters in B are uppercase and there is\n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
162 at least one cased character in B, False otherwise."); |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
163 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
164 PyObject* |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
165 _Py_bytes_isupper(const char *cptr, Py_ssize_t len) |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
166 { |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
167 register const unsigned char *p |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
168 = (unsigned char *) cptr; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
169 register const unsigned char *e; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
170 int cased; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
171 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
172 /* Shortcut for single character strings */ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
173 if (len == 1) |
|
53543
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
174 return PyBool_FromLong(Py_ISUPPER(*p)); |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
175 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
176 /* Special case for empty strings */ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
177 if (len == 0) |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
178 Py_RETURN_FALSE; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
179 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
180 e = p + len; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
181 cased = 0; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
182 for (; p < e; p++) { |
|
53543
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
183 if (Py_ISLOWER(*p)) |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
184 Py_RETURN_FALSE; |
|
53543
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
185 else if (!cased && Py_ISUPPER(*p)) |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
186 cased = 1; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
187 } |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
188 return PyBool_FromLong(cased); |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
189 } |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
190 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
191 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
192 PyDoc_STRVAR_shared(_Py_istitle__doc__, |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
193 "B.istitle() -> bool\n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
194 \n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
195 Return True if B is a titlecased string and there is at least one\n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
196 character in B, i.e. uppercase characters may only follow uncased\n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
197 characters and lowercase characters only cased ones. Return False\n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
198 otherwise."); |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
199 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
200 PyObject* |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
201 _Py_bytes_istitle(const char *cptr, Py_ssize_t len) |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
202 { |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
203 register const unsigned char *p |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
204 = (unsigned char *) cptr; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
205 register const unsigned char *e; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
206 int cased, previous_is_cased; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
207 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
208 /* Shortcut for single character strings */ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
209 if (len == 1) |
|
53543
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
210 return PyBool_FromLong(Py_ISUPPER(*p)); |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
211 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
212 /* Special case for empty strings */ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
213 if (len == 0) |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
214 Py_RETURN_FALSE; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
215 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
216 e = p + len; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
217 cased = 0; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
218 previous_is_cased = 0; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
219 for (; p < e; p++) { |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
220 register const unsigned char ch = *p; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
221 |
|
53543
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
222 if (Py_ISUPPER(ch)) { |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
223 if (previous_is_cased) |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
224 Py_RETURN_FALSE; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
225 previous_is_cased = 1; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
226 cased = 1; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
227 } |
|
53543
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
228 else if (Py_ISLOWER(ch)) { |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
229 if (!previous_is_cased) |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
230 Py_RETURN_FALSE; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
231 previous_is_cased = 1; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
232 cased = 1; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
233 } |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
234 else |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
235 previous_is_cased = 0; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
236 } |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
237 return PyBool_FromLong(cased); |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
238 } |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
239 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
240 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
241 PyDoc_STRVAR_shared(_Py_lower__doc__, |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
242 "B.lower() -> copy of B\n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
243 \n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
244 Return a copy of B with all ASCII characters converted to lowercase."); |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
245 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
246 void |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
247 _Py_bytes_lower(char *result, const char *cptr, Py_ssize_t len) |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
248 { |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
249 Py_ssize_t i; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
250 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
251 /* |
|
47301
23ab586c427a
Renamed PyString to PyBytes
Christian Heimes <christian@cheimes.de>
parents:
43576
diff
changeset
|
252 newobj = PyBytes_FromStringAndSize(NULL, len); |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
253 if (!newobj) |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
254 return NULL; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
255 |
|
47301
23ab586c427a
Renamed PyString to PyBytes
Christian Heimes <christian@cheimes.de>
parents:
43576
diff
changeset
|
256 s = PyBytes_AS_STRING(newobj); |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
257 */ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
258 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
259 Py_MEMCPY(result, cptr, len); |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
260 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
261 for (i = 0; i < len; i++) { |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
262 int c = Py_CHARMASK(result[i]); |
|
53543
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
263 if (Py_ISUPPER(c)) |
|
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
264 result[i] = Py_TOLOWER(c); |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
265 } |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
266 } |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
267 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
268 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
269 PyDoc_STRVAR_shared(_Py_upper__doc__, |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
270 "B.upper() -> copy of B\n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
271 \n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
272 Return a copy of B with all ASCII characters converted to uppercase."); |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
273 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
274 void |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
275 _Py_bytes_upper(char *result, const char *cptr, Py_ssize_t len) |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
276 { |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
277 Py_ssize_t i; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
278 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
279 /* |
|
47301
23ab586c427a
Renamed PyString to PyBytes
Christian Heimes <christian@cheimes.de>
parents:
43576
diff
changeset
|
280 newobj = PyBytes_FromStringAndSize(NULL, len); |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
281 if (!newobj) |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
282 return NULL; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
283 |
|
47301
23ab586c427a
Renamed PyString to PyBytes
Christian Heimes <christian@cheimes.de>
parents:
43576
diff
changeset
|
284 s = PyBytes_AS_STRING(newobj); |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
285 */ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
286 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
287 Py_MEMCPY(result, cptr, len); |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
288 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
289 for (i = 0; i < len; i++) { |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
290 int c = Py_CHARMASK(result[i]); |
|
53543
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
291 if (Py_ISLOWER(c)) |
|
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
292 result[i] = Py_TOUPPER(c); |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
293 } |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
294 } |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
295 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
296 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
297 PyDoc_STRVAR_shared(_Py_title__doc__, |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
298 "B.title() -> copy of B\n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
299 \n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
300 Return a titlecased version of B, i.e. ASCII words start with uppercase\n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
301 characters, all remaining cased characters have lowercase."); |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
302 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
303 void |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
304 _Py_bytes_title(char *result, char *s, Py_ssize_t len) |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
305 { |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
306 Py_ssize_t i; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
307 int previous_is_cased = 0; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
308 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
309 /* |
|
47301
23ab586c427a
Renamed PyString to PyBytes
Christian Heimes <christian@cheimes.de>
parents:
43576
diff
changeset
|
310 newobj = PyBytes_FromStringAndSize(NULL, len); |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
311 if (newobj == NULL) |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
312 return NULL; |
|
47301
23ab586c427a
Renamed PyString to PyBytes
Christian Heimes <christian@cheimes.de>
parents:
43576
diff
changeset
|
313 s_new = PyBytes_AsString(newobj); |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
314 */ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
315 for (i = 0; i < len; i++) { |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
316 int c = Py_CHARMASK(*s++); |
|
53543
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
317 if (Py_ISLOWER(c)) { |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
318 if (!previous_is_cased) |
|
53543
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
319 c = Py_TOUPPER(c); |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
320 previous_is_cased = 1; |
|
53543
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
321 } else if (Py_ISUPPER(c)) { |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
322 if (previous_is_cased) |
|
53543
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
323 c = Py_TOLOWER(c); |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
324 previous_is_cased = 1; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
325 } else |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
326 previous_is_cased = 0; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
327 *result++ = c; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
328 } |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
329 } |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
330 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
331 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
332 PyDoc_STRVAR_shared(_Py_capitalize__doc__, |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
333 "B.capitalize() -> copy of B\n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
334 \n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
335 Return a copy of B with only its first character capitalized (ASCII)."); |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
336 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
337 void |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
338 _Py_bytes_capitalize(char *result, char *s, Py_ssize_t len) |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
339 { |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
340 Py_ssize_t i; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
341 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
342 /* |
|
47301
23ab586c427a
Renamed PyString to PyBytes
Christian Heimes <christian@cheimes.de>
parents:
43576
diff
changeset
|
343 newobj = PyBytes_FromStringAndSize(NULL, len); |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
344 if (newobj == NULL) |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
345 return NULL; |
|
47301
23ab586c427a
Renamed PyString to PyBytes
Christian Heimes <christian@cheimes.de>
parents:
43576
diff
changeset
|
346 s_new = PyBytes_AsString(newobj); |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
347 */ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
348 if (0 < len) { |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
349 int c = Py_CHARMASK(*s++); |
|
53543
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
350 if (Py_ISLOWER(c)) |
|
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
351 *result = Py_TOUPPER(c); |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
352 else |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
353 *result = c; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
354 result++; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
355 } |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
356 for (i = 1; i < len; i++) { |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
357 int c = Py_CHARMASK(*s++); |
|
53543
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
358 if (Py_ISUPPER(c)) |
|
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
359 *result = Py_TOLOWER(c); |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
360 else |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
361 *result = c; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
362 result++; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
363 } |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
364 } |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
365 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
366 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
367 PyDoc_STRVAR_shared(_Py_swapcase__doc__, |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
368 "B.swapcase() -> copy of B\n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
369 \n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
370 Return a copy of B with uppercase ASCII characters converted\n\ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
371 to lowercase ASCII and vice versa."); |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
372 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
373 void |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
374 _Py_bytes_swapcase(char *result, char *s, Py_ssize_t len) |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
375 { |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
376 Py_ssize_t i; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
377 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
378 /* |
|
47301
23ab586c427a
Renamed PyString to PyBytes
Christian Heimes <christian@cheimes.de>
parents:
43576
diff
changeset
|
379 newobj = PyBytes_FromStringAndSize(NULL, len); |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
380 if (newobj == NULL) |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
381 return NULL; |
|
47301
23ab586c427a
Renamed PyString to PyBytes
Christian Heimes <christian@cheimes.de>
parents:
43576
diff
changeset
|
382 s_new = PyBytes_AsString(newobj); |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
383 */ |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
384 for (i = 0; i < len; i++) { |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
385 int c = Py_CHARMASK(*s++); |
|
53543
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
386 if (Py_ISLOWER(c)) { |
|
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
387 *result = Py_TOUPPER(c); |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
388 } |
|
53543
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
389 else if (Py_ISUPPER(c)) { |
|
4b4b59f278bf
Merged revisions 72040 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
53094
diff
changeset
|
390 *result = Py_TOLOWER(c); |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
391 } |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
392 else |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
393 *result = c; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
394 result++; |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
395 } |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
396 } |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
397 |
|
53094
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
398 |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
399 PyDoc_STRVAR_shared(_Py_maketrans__doc__, |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
400 "B.maketrans(frm, to) -> translation table\n\ |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
401 \n\ |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
402 Return a translation table (a bytes object of length 256)\n\ |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
403 suitable for use in bytes.translate where each byte in frm is\n\ |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
404 mapped to the byte at the same position in to.\n\ |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
405 The strings frm and to must be of the same length."); |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
406 |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
407 static Py_ssize_t |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
408 _getbuffer(PyObject *obj, Py_buffer *view) |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
409 { |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
410 PyBufferProcs *buffer = Py_TYPE(obj)->tp_as_buffer; |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
411 |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
412 if (buffer == NULL || buffer->bf_getbuffer == NULL) |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
413 { |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
414 PyErr_Format(PyExc_TypeError, |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
415 "Type %.100s doesn't support the buffer API", |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
416 Py_TYPE(obj)->tp_name); |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
417 return -1; |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
418 } |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
419 |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
420 if (buffer->bf_getbuffer(obj, view, PyBUF_SIMPLE) < 0) |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
421 return -1; |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
422 return view->len; |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
423 } |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
424 |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
425 PyObject * |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
426 _Py_bytes_maketrans(PyObject *args) |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
427 { |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
428 PyObject *frm, *to, *res = NULL; |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
429 Py_buffer bfrm, bto; |
|
56515
67bb17c2e868
Merged revisions 75404 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53543
diff
changeset
|
430 Py_ssize_t i; |
|
53094
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
431 char *p; |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
432 |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
433 bfrm.len = -1; |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
434 bto.len = -1; |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
435 |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
436 if (!PyArg_ParseTuple(args, "OO:maketrans", &frm, &to)) |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
437 return NULL; |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
438 if (_getbuffer(frm, &bfrm) < 0) |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
439 return NULL; |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
440 if (_getbuffer(to, &bto) < 0) |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
441 goto done; |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
442 if (bfrm.len != bto.len) { |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
443 PyErr_Format(PyExc_ValueError, |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
444 "maketrans arguments must have same length"); |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
445 goto done; |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
446 } |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
447 res = PyBytes_FromStringAndSize(NULL, 256); |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
448 if (!res) { |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
449 goto done; |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
450 } |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
451 p = PyBytes_AS_STRING(res); |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
452 for (i = 0; i < 256; i++) |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
453 p[i] = i; |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
454 for (i = 0; i < bfrm.len; i++) { |
|
56515
67bb17c2e868
Merged revisions 75404 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
53543
diff
changeset
|
455 p[((unsigned char *)bfrm.buf)[i]] = ((char *)bto.buf)[i]; |
|
53094
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
456 } |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
457 |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
458 done: |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
459 if (bfrm.len != -1) |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
460 PyBuffer_Release(&bfrm); |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
461 if (bto.len != -1) |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
462 PyBuffer_Release(&bto); |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
463 return res; |
|
4407e4d07084
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
Georg Brandl <georg@python.org>
parents:
47301
diff
changeset
|
464 } |
