Commit Graph

133 Commits

Author SHA1 Message Date
Johannes Gijsbers
9fc9789a0d Document that on Unix, the 'cmd' argument to the os.popen2/3/4 and
popen2.popen2/3/4 functions can be a sequence. All texts are a variation on the
following:

On \UNIX, \var{cmd} may be a sequence, in which case arguments will be passed
directly to the program without shell intervention (as with
\function{os.spawnv()}). If \var{cmd} is a string it will be passed to the shell
(as with \function{os.system()}).
2004-10-11 18:12:20 +00:00
Martin v. Löwis
725f8c83a2 Patch #1021596: Check for None to determine whether _urandomfd is
uninitialized.
2004-09-18 16:07:58 +00:00
Tim Peters
3b2cdad4fd Whitespace normalization. 2004-09-01 13:10:32 +00:00
Andrew M. Kuchling
33ad28b68d Use multi-line import 2004-08-31 11:38:12 +00:00
Tim Peters
45e77c55ff Whitespace normalization. 2004-08-29 18:47:31 +00:00
Martin v. Löwis
dc3883f671 Patch #934711: Expose platform-specific entropy. 2004-08-29 15:46:35 +00:00
Martin v. Löwis
bdec50f027 Feature request #935915: Add os.path.devnull. 2004-06-08 08:29:33 +00:00
Andrew MacIntyre
69e18c9344 OS/2 has support for spawnvp() and spawnvpe() in the C libraries supplied
with major C compilers (VACPP, EMX+gcc and [Open]Watcom).

Also tidy up the export of spawn*() symbols in the os module to match what
is found/implemented.
2004-04-04 07:11:43 +00:00
Raymond Hettinger
31017aed36 SF #904720: dict.update should take a 2-tuple sequence like dict.__init_
(Championed by Bob Ippolito.)

The update() method for mappings now accepts all the same argument forms
as the dict() constructor.  This includes item lists and/or keyword
arguments.
2004-03-04 08:25:44 +00:00
Andrew M. Kuchling
6fccc8a9ec [Bug #829532] Invoking os.makedirs() with an argument that contains a
directory name with a single dot fails.  The patch skips creating
    directories named os.curdir. (Patch by Bram Moolenaar)

2.3 bugfix candidate.
2003-12-23 16:33:28 +00:00
Andrew MacIntyre
89f9865b91 OS/2+EMX: make the link() emulation available as os.link() 2003-12-02 12:33:01 +00:00
Neal Norwitz
b7f6810a1f SF #764121, docstring for spawnlp incorrect 2003-07-02 02:49:33 +00:00
Guido van Rossum
bf1bef820c Add optional 'onerror' argument to os.walk(), to control error
handling.
2003-05-13 18:01:19 +00:00
Tim Peters
c4e0940042 New generator os.walk() does a bit more than os.path.walk() does, and
seems much easier to use.  Code, docs, NEWS, and additions to test_os.py
(testing this sucker is a bitch!).
2003-04-25 07:11:48 +00:00
Guido van Rossum
68468eba63 Get rid of many apply() calls. 2003-02-27 20:14:51 +00:00
Tim Peters
f2715e0764 Whitespace normalization. 2003-02-19 02:35:07 +00:00
Skip Montanaro
117910dc44 Migrate definitions of several platform-dependent path-related variables
into the relevant path modules.  See patch #686397.
2003-02-14 19:35:31 +00:00
Tim Peters
2c60f7a136 Whitespace normalization. 2003-01-29 03:49:43 +00:00
Tim Peters
6757c1e856 SF patch 661583: Remove old code from lib\os.py
A patch from Andrew Wilkinson to change some bizarre old exec statements
specific to NT and CE.
2003-01-08 21:20:57 +00:00
Jack Jansen
b11ce9b96c Always define getenv(), as suggested by Guido. This means that os.getenv() is also defined for MacPython-OS9 (even though it doesn't actually do anything useful), and it shouldn't hurt on other platforms. 2003-01-08 16:33:40 +00:00
Martin v. Löwis
8b10f8988f Remove more DOS support. 2002-10-09 17:23:29 +00:00
Raymond Hettinger
05212fc7f3 Change UserDict to IterableUserDict 2002-09-07 04:48:03 +00:00
Raymond Hettinger
ca2f537e32 Have os.environ() inherit from the iterable version of UserDict.
Closes SF bug 605731.
2002-09-06 19:36:31 +00:00
Guido van Rossum
683c0fe414 Fix for SF bug 601077 by Zack Weinberg.
The new execvpe code would sometimes do the wrong thing when a
non-executable file existed earlier in the path and an executable file
of the same name existed later in the path.  This patch restores the
proper behavior (which is to execute the second file).  When only a
non-executable file exists, the correct error is still reported.
2002-09-03 16:36:17 +00:00
Guido van Rossum
aed51d8121 SF patch 590294: os._execvpe security fix (Zack Weinberg).
1) Do not attempt to exec a file which does not exist
just to find out what error the operating system
returns. This is an exploitable race on all platforms
that support symbolic links.

2) Immediately re-raise the exception if we get an
error other than errno.ENOENT or errno.ENOTDIR. This
may need to be adapted for other platforms.

(As a security issue, this should be considered for 2.1
and 2.2 as well as 2.3.)
2002-08-05 16:13:24 +00:00
Fred Drake
cadb9eb8f6 Be consistent with the functions in the posix/nt module: docstrings
don't include a " -> None" for functions that have no return value.
2002-07-02 21:28:04 +00:00
Raymond Hettinger
54f0222547 SF 563203. Replaced 'has_key()' with 'in'. 2002-06-01 14:18:47 +00:00
Martin v. Löwis
a066f46b9b Patch 550804: Make os.environ.copy() return a copy. 2002-05-02 17:39:19 +00:00
Tim Peters
bc0e910826 Convert a pile of obvious "yes/no" functions to return bool. 2002-04-04 22:55:58 +00:00
Michael W. Hudson
e5363b7de5 .... 2002-03-15 10:21:59 +00:00
Michael W. Hudson
ce00b735cd Fix
[ 530236 ] os.py assumes existence of statvfs_resul

This was pretty dense of me.  Sorry.

2.2.1 candidate.
2002-03-15 10:18:58 +00:00
Michael W. Hudson
0e02530a79 Special support for pickling os.stat and os.stat_vfs results portably
(the types come from different modules on different platforms).

Added tests for pickling these types.

May be a bugfix candidate.
2002-03-06 17:11:18 +00:00
Andrew MacIntyre
5cef57131f OS/2 EMX port Library and regression test changes:
Lib/
    os.py
    os2emxpath.py   // added - OS/2 EMX specific path manipulation routines
    popen2.py
    site.py
  Lib/test/
    test_fcntl.py
    test_longexp.py
2002-02-24 05:32:32 +00:00
Tim Peters
1633a2e345 Whitespace normalization. 2001-10-30 05:56:40 +00:00
Guido van Rossum
e2ae77b8b8 SF patch #474590 -- RISC OS support 2001-10-24 20:42:55 +00:00
Guido van Rossum
c524d952da SF patch #460805 by Chris Gonnerman: Support for unsetenv()
This adds unsetenv to posix, and uses it in the __delitem__ method of
os.environ.

(XXX Should we change the preferred name for putenv to setenv, for
consistency?)
2001-10-19 01:31:59 +00:00
Martin v. Löwis
a90f438d4a Unify _Environ processing on riscos with other platforms. 2001-03-07 09:05:45 +00:00
Skip Montanaro
81e4b1c5c8 fix typo in extending __all__ for riscos platform - closes bug 406296 2001-03-06 15:26:07 +00:00
Ka-Ping Yee
feb6719851 Use r""" instead of """ for the docstring so that backslashes are preserved. 2001-03-02 23:31:43 +00:00
Guido van Rossum
b7fe432a88 Fix by Donn Cave for BeOS (SF #403642):
UNIX style fork/execve/wait are not fully compatible with thread
  support on BeOS.  For Python, that means neither fork() from import
  nor import from a fork work reliably. os._execvpe() does the latter,
  importing tempfile to set up a tantalizing target for hackers. This
  patch replaces both the tempfile name generation and the exec that
  uses it, in case we're on BeOS. Need this for
  setup:distutils:execvp(); symptoms are random crashes and internal
  BeOS error messages about th name, in case we're on BeOS. It's an
  issue because setup.py + distutils calls os.execvp(); symptoms are
  random crashes during setup.py, and internal BeOS error messages
  about thread IDs.
2001-03-02 07:04:51 +00:00
Guido van Rossum
d74fb6b12a RISCOS changes by dschwertberger. 2001-03-02 06:43:49 +00:00
Skip Montanaro
6c0a0e1538 added some elements missing from __all__ 2001-02-28 01:00:58 +00:00
Skip Montanaro
269b83bc05 added several more __all__ lists 2001-02-06 01:07:02 +00:00
Tim Peters
2344fae6d0 Whitespace normalization. 2001-01-15 00:50:52 +00:00
Fred Drake
20af3172ce popen4(): Added for Unix.
Fixed a typo in a docstring.
2000-09-28 19:10:56 +00:00
Guido van Rossum
d9a8e96543 Only supply popen2, popen3 when fork exists.
(This avoids defining non-working versions of these on the Mac.)
2000-09-19 03:04:52 +00:00
Fred Drake
31f182e830 Added os.popen2() and os.popen3() for non-Windows platforms. 2000-08-28 17:20:05 +00:00
Fred Drake
9f2550f581 makedirs(), removedirs(): If the tail of the path is empty, do a second
split so the logic does not fail in corner cases.

This closes bug #407.
2000-07-25 15:16:40 +00:00
Thomas Wouters
7e47402264 Spelling fixes supplied by Rob W. W. Hooft. All these are fixes in either
comments, docstrings or error messages. I fixed two minor things in
test_winreg.py ("didn't" -> "Didn't" and "Didnt" -> "Didn't").

There is a minor style issue involved: Guido seems to have preferred English
grammar (behaviour, honour) in a couple places. This patch changes that to
American, which is the more prominent style in the source. I prefer English
myself, so if English is preferred, I'd be happy to supply a patch myself ;)
2000-07-16 12:04:32 +00:00
Guido van Rossum
868b50af17 Michael Hudson fixes a case where execv() is called (for a test) with
an empty argument list -- another patch he's checking in will make
this illegal (the first argument should always be the program name).
2000-04-26 20:32:08 +00:00
Guido van Rossum
7da3cc5dfb Michael Hudson:
I think that after this patch, all objects in the os module (with names
that don't start with "_") that can have docstrings, do, on Linux at
least.

Also fix a nit in one of my spawn* docstrings.
2000-04-25 10:53:22 +00:00
Guido van Rossum
e0cd291b81 Doc strings for the spawn* functions, by Michael Hudson. 2000-04-21 18:35:36 +00:00
Guido van Rossum
965fdae40e Patch by Fred Gansevles.
This patch solves 2 problems of the os module.
1) Bug ID #50 (case-mismatch wiht "environ.get(..,..)" and "del environ[..]")
2) os.environ.update (dict) doesn't propagate changes to the 'real'
   environment (i.e doesn't call putenv)

This patches also has minor changes specific for 1.6a
The string module isn't used anymore, instead the strings own methods are
used.
2000-04-04 19:50:04 +00:00
Guido van Rossum
4b8c6eaf8b Actually, the previous batch's comment should have been different;
*this* set of patches is Ka-Ping's final sweep:

The attached patches update the standard library so that all modules
have docstrings beginning with one-line summaries.

A new docstring was added to formatter.  The docstring for os.py
was updated to mention nt, os2, ce in addition to posix, dos, mac.
2000-02-04 15:39:30 +00:00
Guido van Rossum
54f22ed30b More trivial comment -> docstring transformations by Ka-Ping Yee,
who writes:

Here is batch 2, as a big collection of CVS context diffs.
Along with moving comments into docstrings, i've added a
couple of missing docstrings and attempted to make sure more
module docstrings begin with a one-line summary.

I did not add docstrings to the methods in profile.py for
fear of upsetting any careful optimizations there, though
i did move class documentation into class docstrings.

The convention i'm using is to leave credits/version/copyright
type of stuff in # comments, and move the rest of the descriptive
stuff about module usage into module docstrings.  Hope this is
okay.
2000-02-04 15:10:34 +00:00
Guido van Rossum
dd7cbbf4d3 Oops. spawnl() and spawnle() should be implemented on Windows too.
Also added a comment that the 'p' variants (spawnvp() etc.) are *not*
supported on Windows.  (They could be by adding them to posixmodule.c)
1999-11-02 20:44:07 +00:00
Guido van Rossum
5a2ca9328d Checking in a bunch of spawn functions. These are only defined if we
have fork and execv (and friends) but not spawnv.  They operate
exactly like the spawn functions on Windows.  A limited set of needed
constants is also defined (P_WAIT, P_NOWAIT etc.).

Also add getenv() as a familiar alias for environ.get().
1999-11-02 13:27:32 +00:00
Guido van Rossum
18df5d479c Mark Hammond: patch for Windows/CE. 1999-06-11 01:37:27 +00:00
Guido van Rossum
b46413f274 The case-insensitive _Environ class was lacking a case-insensitive has_key(). 1999-05-03 15:23:24 +00:00
Guido van Rossum
fb801e7d33 As Finn Bock points out, _P_WAIT etc. don't have a leading underscore
so they don't need to be treated specially here.
1999-02-22 15:40:34 +00:00
Guido van Rossum
67c65b2954 Special-case _P_WAIT etc. for NT. 1999-02-01 23:52:29 +00:00
Fred Drake
0237909e42 Enable os.path as a mostly-normal submodule, including "from os.path
import isfile" and "import os.path".
1999-01-19 16:05:13 +00:00
Guido van Rossum
da4d6daa4a Support case insensitive treatment of os.environ keys on Windows and
DOS (as well as OS/2).  I presume that making a call to putenv() with
a lowercase key will actually do the right thing.  I know this is so
on Windows/DOS, and I expect it is so OS/2 -- but the old OS/2 code
didn't assume this.  (I don't know if the person who provided the OS/2
patch was clueless or just didn't care about DOS and Windows.)

Also ripped out the support for pickling -- as of 1.5, this is no
longer needed to make pickling work.
1998-08-04 16:01:23 +00:00
Guido van Rossum
4def7de7c6 Add makedirs(), removedirs(), renames() -- ESR-inspired super-versions
of mkdir(), rmdir() and rename() that make or remove intermediate
directories as well.
1998-07-24 20:48:03 +00:00
Guido van Rossum
e9387ea773 introduce a new platform-specific variable: os.linesep is the
platform's line separator.  \n on Unix, \r\n on DOS, OS/2 and Windows,
\r on Macs.
1998-05-22 15:26:04 +00:00
Guido van Rossum
61de0ac4bb Reindented according to new standard, without tabs.
Also added one more os2 specific piece of code, by Jeff Rush.
1997-12-05 21:24:30 +00:00
Barry Warsaw
58a88b3e34 _Environ(): Added __getinitargs__() method so os.environ.copy() works,
as does unpickling, as in: pickle.loads(pickle.dumps(os.environ)).

Hope this is right!  Don't shoot me Guido. :-)
1997-12-01 04:30:19 +00:00
Guido van Rossum
8e9ebfd337 os2 patch by Jeff Rush 1997-11-22 21:53:48 +00:00
Guido van Rossum
a28dab5ea2 Write out the dynamic OS choice, to avoid exec statements.
Adding support for a new OS is now a bit more work, but I bet that
'dos' or 'nt' will cover most situations...
1997-08-29 22:36:47 +00:00
Guido van Rossum
3b8e20d2c2 Added hook to os.environ to call putenv(), if it exists. 1996-07-24 00:55:17 +00:00
Guido van Rossum
b7677095d4 make sure os.environ exists (maybe empty) 1995-08-07 20:15:23 +00:00
Guido van Rossum
4c7fa4b774 set mac path separator to newline 1995-03-14 17:53:54 +00:00
Guido van Rossum
030afb1d3a add execvpe -- mix of execvp and execve 1995-03-14 17:27:18 +00:00
Guido van Rossum
ca9321e6d0 Import posixpath for freeze script 1994-10-05 15:17:55 +00:00
Guido van Rossum
a28f2dc321 do fake "import posix" for freeze.py script 1994-08-17 12:33:28 +00:00
Guido van Rossum
2979b01ff8 Merge changes 1994-08-01 11:18:30 +00:00
Guido van Rossum
dd8cb446e1 Some minute changes. 1993-12-29 15:33:08 +00:00
Guido van Rossum
e65cce5eec * string.py: added rindex(), rfind(); changed index() to interpret
negative start indices starting from the right.
* ftplib.py: debug() -> set_debuglevel(); change demo to use __init__().
* os.py: added execl, execlp, and execvp.
* lambda.py: removed (now that we have built-in map, reduce, bagof, lambda)
* test_b{1,2}.py, testall.out: added tests for bagof, lambda, map, reduce
* commands.py: use os, not posix
* test_grammar.py: make it easy to disable non-portable int overflow tests
* dis.py: don't abuse range()
1993-11-08 15:05:21 +00:00
Guido van Rossum
35fb82a33f * os.py: _exit doesn't exist in all variations of posix
* Added fcmp() to test_support.py and use it in test*.py
1993-01-26 13:04:43 +00:00
Guido van Rossum
7a461e5aaf New module regsub contains sub(), gsub() and split() as in nawk.
string.splitfields(s, '') now returns [s] as split() in nawk.
Added _exit to exported functions of os.
1992-09-20 21:41:09 +00:00
Guido van Rossum
b59cdd4356 Add separator 1992-04-06 14:03:45 +00:00
Guido van Rossum
1a76ef260d Added definition for pardir ('..') 1992-03-31 18:57:28 +00:00
Guido van Rossum
31104f4624 Initial revision 1992-01-14 18:28:36 +00:00