Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0ed6634

Browse files
committed
really scream out that people should use the file objects instead of
file descriptor operations for normal applications
1 parent c00fc84 commit 0ed6634

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

Doc/lib/libos.tex

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -399,11 +399,13 @@ \subsection{File Descriptor Operations \label{os-fd-ops}}
399399
Close file descriptor \var{fd}.
400400
Availability: Macintosh, \UNIX, Windows.
401401

402-
Note: this function is intended for low-level I/O and must be applied
402+
\begin{notice}
403+
This function is intended for low-level I/O and must be applied
403404
to a file descriptor as returned by \function{open()} or
404405
\function{pipe()}. To close a ``file object'' returned by the
405406
built-in function \function{open()} or by \function{popen()} or
406407
\function{fdopen()}, use its \method{close()} method.
408+
\end{notice}
407409
\end{funcdesc}
408410

409411
\begin{funcdesc}{dup}{fd}
@@ -498,10 +500,12 @@ \subsection{File Descriptor Operations \label{os-fd-ops}}
498500
documentation; flag constants (like \constant{O_RDONLY} and
499501
\constant{O_WRONLY}) are defined in this module too (see below).
500502

501-
Note: this function is intended for low-level I/O. For normal usage,
503+
\begin{notice}
504+
This function is intended for low-level I/O. For normal usage,
502505
use the built-in function \function{open()}, which returns a ``file
503506
object'' with \method{read()} and \method{write()} methods (and many
504507
more).
508+
\end{notice}
505509
\end{funcdesc}
506510

507511
\begin{funcdesc}{openpty}{}
@@ -525,12 +529,14 @@ \subsection{File Descriptor Operations \label{os-fd-ops}}
525529
returned.
526530
Availability: Macintosh, \UNIX, Windows.
527531

528-
Note: this function is intended for low-level I/O and must be applied
532+
\begin{notice}
533+
This function is intended for low-level I/O and must be applied
529534
to a file descriptor as returned by \function{open()} or
530535
\function{pipe()}. To read a ``file object'' returned by the
531536
built-in function \function{open()} or by \function{popen()} or
532537
\function{fdopen()}, or \code{sys.stdin}, use its
533538
\method{read()} or \method{readline()} methods.
539+
\end{notice}
534540
\end{funcdesc}
535541

536542
\begin{funcdesc}{tcgetpgrp}{fd}
@@ -558,12 +564,14 @@ \subsection{File Descriptor Operations \label{os-fd-ops}}
558564
Return the number of bytes actually written.
559565
Availability: Macintosh, \UNIX, Windows.
560566

561-
Note: this function is intended for low-level I/O and must be applied
567+
\begin{notice}
568+
This function is intended for low-level I/O and must be applied
562569
to a file descriptor as returned by \function{open()} or
563570
\function{pipe()}. To write a ``file object'' returned by the
564571
built-in function \function{open()} or by \function{popen()} or
565572
\function{fdopen()}, or \code{sys.stdout} or \code{sys.stderr}, use
566573
its \method{write()} method.
574+
\end{notice}
567575
\end{funcdesc}
568576

569577

@@ -874,10 +882,12 @@ \subsection{Files and Directories \label{os-file-dir}}
874882
directories needed to make the new pathname good is attempted first.
875883
After the rename, directories corresponding to rightmost path segments
876884
of the old name will be pruned away using \function{removedirs()}.
885+
\versionadded{1.5.2}
877886

878-
Note: this function can fail with the new directory structure made if
887+
\begin{notice}
888+
This function can fail with the new directory structure made if
879889
you lack permissions needed to remove the leaf directory or file.
880-
\versionadded{1.5.2}
890+
\end{notice}
881891
\end{funcdesc}
882892

883893
\begin{funcdesc}{rmdir}{path}
@@ -1228,9 +1238,11 @@ \subsection{Process Management \label{os-process}}
12281238
handlers, flushing stdio buffers, etc.
12291239
Availability: \UNIX, Windows.
12301240

1231-
Note: the standard way to exit is \code{sys.exit(\var{n})}.
1241+
\begin{notice}
1242+
The standard way to exit is \code{sys.exit(\var{n})}.
12321243
\function{_exit()} should normally only be used in the child process
12331244
after a \function{fork()}.
1245+
\end{notice}
12341246
\end{funcdesc}
12351247

12361248
The following exit codes are a defined, and can be used with

0 commit comments

Comments
 (0)