Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
3fcbea56
Commit
3fcbea56
authored
Aug 26, 2007
by
Neal Norwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use unicode and remove support for some uses of str8.
parent
ed2b7397
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
11 deletions
+14
-11
Modules/arraymodule.c
Modules/arraymodule.c
+2
-3
Modules/parsermodule.c
Modules/parsermodule.c
+12
-8
No files found.
Modules/arraymodule.c
View file @
3fcbea56
...
...
@@ -1819,7 +1819,7 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if
(
!
(
initial
==
NULL
||
PyList_Check
(
initial
)
||
PyBytes_Check
(
initial
)
||
Py
String_Check
(
initial
)
||
Py
Tuple_Check
(
initial
)
||
PyTuple_Check
(
initial
)
||
(
c
==
PyArr_UNI
&&
PyUnicode_Check
(
initial
))))
{
it
=
PyObject_GetIter
(
initial
);
if
(
it
==
NULL
)
...
...
@@ -1862,8 +1862,7 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
Py_DECREF
(
v
);
}
}
else
if
(
initial
!=
NULL
&&
(
PyString_Check
(
initial
)
||
PyBytes_Check
(
initial
)))
{
}
else
if
(
initial
!=
NULL
&&
PyBytes_Check
(
initial
))
{
PyObject
*
t_initial
,
*
v
;
t_initial
=
PyTuple_Pack
(
1
,
initial
);
if
(
t_initial
==
NULL
)
{
...
...
Modules/parsermodule.c
View file @
3fcbea56
...
...
@@ -105,14 +105,14 @@ node2tuple(node *n, /* node to convert */
}
if
(
TYPE
(
n
)
==
encoding_decl
)
(
void
)
addelem
(
v
,
i
+
1
,
Py
String
_FromString
(
STR
(
n
)));
(
void
)
addelem
(
v
,
i
+
1
,
Py
Unicode
_FromString
(
STR
(
n
)));
return
(
v
);
}
else
if
(
ISTERMINAL
(
TYPE
(
n
)))
{
PyObject
*
result
=
mkseq
(
2
+
lineno
+
col_offset
);
if
(
result
!=
NULL
)
{
(
void
)
addelem
(
result
,
0
,
PyInt_FromLong
(
TYPE
(
n
)));
(
void
)
addelem
(
result
,
1
,
Py
String
_FromString
(
STR
(
n
)));
(
void
)
addelem
(
result
,
1
,
Py
Unicode
_FromString
(
STR
(
n
)));
if
(
lineno
==
1
)
(
void
)
addelem
(
result
,
2
,
PyInt_FromLong
(
n
->
n_lineno
));
if
(
col_offset
==
1
)
...
...
@@ -681,6 +681,7 @@ build_node_children(PyObject *tuple, node *root, int *line_num)
if
(
ISTERMINAL
(
type
))
{
Py_ssize_t
len
=
PyObject_Size
(
elem
);
PyObject
*
temp
;
const
char
*
temp_str
;
if
((
len
!=
2
)
&&
(
len
!=
3
))
{
err_string
(
"terminal nodes must have 2 or 3 entries"
);
...
...
@@ -689,7 +690,7 @@ build_node_children(PyObject *tuple, node *root, int *line_num)
temp
=
PySequence_GetItem
(
elem
,
1
);
if
(
temp
==
NULL
)
return
0
;
if
(
!
Py
String
_Check
(
temp
))
{
if
(
!
Py
Unicode
_Check
(
temp
))
{
PyErr_Format
(
parser_error
,
"second item in terminal node must be a string,"
" found %s"
,
...
...
@@ -716,10 +717,11 @@ build_node_children(PyObject *tuple, node *root, int *line_num)
Py_DECREF
(
o
);
}
}
len
=
PyString_GET_SIZE
(
temp
)
+
1
;
temp_str
=
PyUnicode_AsString
(
temp
);
len
=
PyUnicode_GET_SIZE
(
temp
)
+
1
;
strn
=
(
char
*
)
PyObject_MALLOC
(
len
);
if
(
strn
!=
NULL
)
(
void
)
memcpy
(
strn
,
PyString_AS_STRING
(
temp
)
,
len
);
(
void
)
memcpy
(
strn
,
temp_str
,
len
);
Py_DECREF
(
temp
);
}
else
if
(
!
ISNONTERMINAL
(
type
))
{
...
...
@@ -804,10 +806,12 @@ build_node_tree(PyObject *tuple)
}
if
(
res
&&
encoding
)
{
Py_ssize_t
len
;
len
=
PyString_GET_SIZE
(
encoding
)
+
1
;
const
char
*
temp
;
temp
=
PyUnicode_AsString
(
encoding
);
len
=
PyUnicode_GET_SIZE
(
encoding
)
+
1
;
res
->
n_str
=
(
char
*
)
PyObject_MALLOC
(
len
);
if
(
res
->
n_str
!=
NULL
)
(
void
)
memcpy
(
res
->
n_str
,
PyString_AS_STRING
(
encoding
)
,
len
);
if
(
res
->
n_str
!=
NULL
&&
temp
!=
NULL
)
(
void
)
memcpy
(
res
->
n_str
,
temp
,
len
);
Py_DECREF
(
encoding
);
Py_DECREF
(
tuple
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment