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
a3552c64
Commit
a3552c64
authored
Aug 19, 2010
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Decode NIS data to fs encoding, using the surrogate error handler.
parent
a9d2aacf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
9 deletions
+20
-9
Misc/NEWS
Misc/NEWS
+2
-1
Modules/nismodule.c
Modules/nismodule.c
+18
-8
No files found.
Misc/NEWS
View file @
a3552c64
...
...
@@ -69,7 +69,8 @@ Extensions
- Issue #5737: Add Solaris-specific mnemonics in the errno module. Patch by
Matthew Ahrens.
- Restore GIL in nis_cat in case of error.
- Restore GIL in nis_cat in case of error. Decode NIS data to fs encoding,
using the surrogate error handler.
- Issue #665761: ``functools.reduce()`` will no longer mask exceptions
other than ``TypeError`` raised by the iterator argument.
...
...
Modules/nismodule.c
View file @
a3552c64
...
...
@@ -117,8 +117,8 @@ nis_foreach (int instatus, char *inkey, int inkeylen, char *inval,
if
(
invallen
>
0
&&
inval
[
invallen
-
1
]
==
'\0'
)
invallen
--
;
}
key
=
PyUnicode_
FromString
AndSize
(
inkey
,
inkeylen
);
val
=
PyUnicode_
FromString
AndSize
(
inval
,
invallen
);
key
=
PyUnicode_
DecodeFSDefault
AndSize
(
inkey
,
inkeylen
);
val
=
PyUnicode_
DecodeFSDefault
AndSize
(
inval
,
invallen
);
if
(
key
==
NULL
||
val
==
NULL
)
{
/* XXX error -- don't know how to handle */
PyErr_Clear
();
...
...
@@ -159,30 +159,40 @@ nis_match (PyObject *self, PyObject *args, PyObject *kwdict)
{
char
*
match
;
char
*
domain
=
NULL
;
int
keylen
,
len
;
Py_ssize_t
keylen
;
int
len
;
char
*
key
,
*
map
;
int
err
;
PyObject
*
res
;
PyObject
*
ukey
,
*
bkey
,
*
res
;
int
fix
;
static
char
*
kwlist
[]
=
{
"key"
,
"map"
,
"domain"
,
NULL
};
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwdict
,
"
s#
s|s:match"
,
kwlist
,
&
key
,
&
keylen
,
&
map
,
&
domain
))
"
U
s|s:match"
,
kwlist
,
&
ukey
,
&
map
,
&
domain
))
return
NULL
;
if
(
!
domain
&&
((
err
=
yp_get_default_domain
(
&
domain
))
!=
0
))
if
((
bkey
=
PyUnicode_EncodeFSDefault
(
ukey
))
==
NULL
)
return
NULL
;
if
(
PyBytes_AsStringAndSize
(
bkey
,
&
key
,
&
keylen
)
==
-
1
)
{
Py_DECREF
(
bkey
);
return
NULL
;
}
if
(
!
domain
&&
((
err
=
yp_get_default_domain
(
&
domain
))
!=
0
))
{
Py_DECREF
(
bkey
);
return
nis_error
(
err
);
}
map
=
nis_mapname
(
map
,
&
fix
);
if
(
fix
)
keylen
++
;
Py_BEGIN_ALLOW_THREADS
err
=
yp_match
(
domain
,
map
,
key
,
keylen
,
&
match
,
&
len
);
Py_END_ALLOW_THREADS
Py_DECREF
(
bkey
);
if
(
fix
)
len
--
;
if
(
err
!=
0
)
return
nis_error
(
err
);
res
=
PyUnicode_
FromStringAndSize
(
match
,
len
);
res
=
PyUnicode_
DecodeFSDefaultAndSize
(
match
,
len
);
free
(
match
);
return
res
;
}
...
...
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