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
4a342094
Commit
4a342094
authored
Dec 19, 1996
by
Barry Warsaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. Export open(2) flag constants for every defined constant
2. Reworked error checking in initposix() and initnt().
parent
e8e9ed17
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
88 additions
and
16 deletions
+88
-16
Modules/posixmodule.c
Modules/posixmodule.c
+88
-16
No files found.
Modules/posixmodule.c
View file @
4a342094
...
...
@@ -1757,6 +1757,72 @@ static PyMethodDef posix_methods[] = {
};
static
int
ins
(
d
,
symbol
,
value
)
PyObject
*
d
;
char
*
symbol
;
long
value
;
{
PyObject
*
v
=
PyInt_FromLong
(
value
);
if
(
!
v
||
PyDict_SetItemString
(
d
,
symbol
,
v
)
<
0
)
return
-
1
;
/* triggers fatal error */
Py_DECREF
(
v
);
return
0
;
}
static
int
all_ins
(
d
)
PyObject
*
d
;
{
#ifdef WNOHANG
if
(
ins
(
d
,
"WNOHANG"
,
(
long
)
WNOHANG
))
return
-
1
;
#endif
#ifdef O_RDONLY
if
(
ins
(
d
,
"O_RDONLY"
,
(
long
)
O_RDONLY
))
return
-
1
;
#endif
#ifdef O_WRONLY
if
(
ins
(
d
,
"O_WRONLY"
,
(
long
)
O_WRONLY
))
return
-
1
;
#endif
#ifdef O_RDWR
if
(
ins
(
d
,
"O_RDWR"
,
(
long
)
O_RDWR
))
return
-
1
;
#endif
#ifdef O_NDELAY
if
(
ins
(
d
,
"O_NDELAY"
,
(
long
)
O_NDELAY
))
return
-
1
;
#endif
#ifdef O_NONBLOCK
if
(
ins
(
d
,
"O_NONBLOCK"
,
(
long
)
O_NONBLOCK
))
return
-
1
;
#endif
#ifdef O_APPEND
if
(
ins
(
d
,
"O_APPEND"
,
(
long
)
O_APPEND
))
return
-
1
;
#endif
#ifdef O_DSYNC
if
(
ins
(
d
,
"O_DSYNC"
,
(
long
)
O_DSYNC
))
return
-
1
;
#endif
#ifdef O_RSYNC
if
(
ins
(
d
,
"O_RSYNC"
,
(
long
)
O_RSYNC
))
return
-
1
;
#endif
#ifdef O_SYNC
if
(
ins
(
d
,
"O_SYNC"
,
(
long
)
O_SYNC
))
return
-
1
;
#endif
#ifdef O_NOCTTY
if
(
ins
(
d
,
"O_NOCTTY"
,
(
long
)
O_NOCTTY
))
return
-
1
;
#endif
#ifdef O_CREAT
if
(
ins
(
d
,
"O_CREAT"
,
(
long
)
O_CREAT
))
return
-
1
;
#endif
#ifdef O_EXCL
if
(
ins
(
d
,
"O_EXCL"
,
(
long
)
O_EXCL
))
return
-
1
;
#endif
#ifdef O_TRUNC
if
(
ins
(
d
,
"O_TRUNC"
,
(
long
)
O_TRUNC
))
return
-
1
;
#endif
return
0
;
}
#if defined(_MSC_VER) || defined(__WATCOMC__)
void
initnt
()
...
...
@@ -1769,14 +1835,21 @@ initnt()
/* Initialize nt.environ dictionary */
v
=
convertenviron
();
if
(
v
==
NULL
||
PyDict_SetItemString
(
d
,
"environ"
,
v
)
!=
0
)
Py_FatalError
(
"can't define nt.environ"
)
;
goto
finally
;
Py_DECREF
(
v
);
if
(
all_ins
(
d
))
goto
finally
;
/* Initialize nt.error exception */
PosixError
=
PyString_FromString
(
"nt.error"
);
if
(
PosixError
==
NULL
||
PyDict_SetItemString
(
d
,
"error"
,
PosixError
)
!=
0
)
Py_FatalError
(
"can't define nt.error"
);
PyDict_SetItemString
(
d
,
"error"
,
PosixError
);
if
(
!
PyErr_Occurred
())
return
;
finally:
Py_FatalError
(
"can't initialize NT posixmodule"
);
}
#else
/* not a PC port */
void
...
...
@@ -1790,21 +1863,20 @@ initposix()
/* Initialize posix.environ dictionary */
v
=
convertenviron
();
if
(
v
==
NULL
||
PyDict_SetItemString
(
d
,
"environ"
,
v
)
!=
0
)
Py_FatalError
(
"can't define posix.environ"
);
Py_DECREF
(
v
);
#ifdef WNOHANG
/* Export WNOHANG symbol */
v
=
PyInt_FromLong
((
long
)
WNOHANG
);
if
(
v
==
NULL
||
PyDict_SetItemString
(
d
,
"WNOHANG"
,
v
)
!=
0
)
Py_FatalError
(
"can't define posix.WNOHANG"
);
goto
finally
;
Py_DECREF
(
v
);
#endif
if
(
all_ins
(
d
))
goto
finally
;
/* Initialize posix.error exception */
PosixError
=
PyString_FromString
(
"posix.error"
);
if
(
PosixError
==
NULL
||
PyDict_SetItemString
(
d
,
"error"
,
PosixError
)
!=
0
)
Py_FatalError
(
"can't define posix.error"
);
PyDict_SetItemString
(
d
,
"error"
,
PosixError
);
if
(
!
PyErr_Occurred
())
return
;
finally:
Py_FatalError
(
"can't initialize posix module"
);
}
#endif
/* !_MSC_VER */
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