Commit Graph

176 Commits

Author SHA1 Message Date
Serhiy Storchaka f6fb3a3206 Issue #15845: Fix comparison between bytes and string. 2013-01-08 11:36:54 +02:00
Serhiy Storchaka 4ab23bfbeb Issue #15845: Fix comparison between bytes and string. 2013-01-08 11:32:58 +02:00
Benjamin Peterson b29614e047 compare singletons by identity not equality (closes #16712)
Patch from Serhiy Storchaka.
2012-10-09 11:16:03 -04:00
Larry Hastings b40380667c Issue #15202: Consistently use the name "follow_symlinks" for
new parameters in os and shutil functions.  Patch by Serhiy Storchaka.
2012-07-15 10:57:38 -07:00
Larry Hastings c48fe98a7c Issue #15177: Added dir_fd parameter to os.fwalk(). 2012-06-25 04:49:05 -07:00
Georg Brandl 306336bcda Closes #15161: add support for giving path as a fd for truncate() and pathconf(). 2012-06-24 12:55:33 +02:00
Larry Hastings b698d8e7e9 Issue #15154: Add "dir_fd" parameter to os.rmdir, remove "rmdir"
parameter from os.remove / os.unlink.
Patch written by Georg Brandl.  (I'm really looking forward to George
getting commit privileges so I don't have to keep doing checkins on his
behalf.)
2012-06-23 16:55:07 -07:00
Larry Hastings dbbc0c8bb3 Issue #14626: Fix buildbot issue on OpenIndiana 3.x machines. (Hopefully.) 2012-06-22 19:50:21 -07:00
Larry Hastings 9cf065cfdc Issue #14626: Large refactoring of functions / parameters in the os module.
Many functions now support "dir_fd" and "follow_symlinks" parameters;
some also support accepting an open file descriptor in place of of a path
string.  Added os.support_* collections as LBYL helpers.  Removed many
functions only previously seen in 3.3 alpha releases (often starting with
"f" or "l", or ending with "at").  Originally suggested by Serhiy Storchaka;
implemented by Larry Hastings.
2012-06-22 16:30:09 -07:00
Jesus Cea 9436361e4c Closes #10142: Support for SEEK_HOLE/SEEK_DATA 2012-06-22 18:32:07 +02:00
Gregory P. Smith 2d7d56abf8 Revert the modification of e.strerror in 3.2 as that kind of change could
break someone's over specified test that depends on the exact error message.
2012-06-03 14:39:26 -07:00
Gregory P. Smith f0a9a9b502 Fixes Issue #14992: os.makedirs(path, exist_ok=True) would raise an OSError
when the path existed and had the S_ISGID mode bit set when it was
not explicitly asked for.  This is no longer an exception as mkdir
cannot control if the OS sets that bit for it or not.
2012-06-03 14:35:09 -07:00
Gregory P. Smith a81c856436 Fixes Issue #14992: os.makedirs(path, exist_ok=True) would raise an OSError
when the path existed and had the S_ISGID mode bit set when it was not
explicitly asked for.  This is no longer an exception as mkdir cannot control
if the OS sets that bit for it or not.
2012-06-03 14:30:44 -07:00
Petri Lehtinen 3bc37f2360 #14862: Add missing names to os.__all__ 2012-05-23 21:36:28 +03:00
Hynek Schlawack 66bfcc1b0f #14773: Fix os.fwalk() failing on dangling symlinks 2012-05-15 16:32:21 +02:00
Benjamin Peterson 569d087574 use yield from 2012-05-10 16:17:35 -05:00
Jesus Cea 990eff0776 Backing out 86dc014cdd74. Not ready yet 2012-04-26 17:05:31 +02:00
Jesus Cea 2b47f0a23f Close #10142: Support for SEEK_HOLE/SEEK_DATA 2012-04-26 16:39:35 +02:00
Charles-François Natali 84c0ca06d2 Use os.path.samestat() instead of reinventing the wheel. 2012-04-22 15:55:43 +02:00
Brett Cannon fd0741555b Issue #2377: Make importlib the implementation of __import__().
importlib._bootstrap is now frozen into Python/importlib.h and stored
as _frozen_importlib in sys.modules. Py_Initialize() loads the frozen
code along with sys and imp and then uses _frozen_importlib._install()
to set builtins.__import__() w/ _frozen_importlib.__import__().
2012-04-14 14:10:13 -04:00
Georg Brandl 2fb477c0f0 Merge 3.2: Issue #13703 plus some related test suite fixes. 2012-02-21 00:33:36 +01:00
Georg Brandl 09a7c72cad Merge from 3.1: Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
in order to make algorithmic complexity attacks on (e.g.) web apps much more complicated.

The environment variable PYTHONHASHSEED and the new command line flag -R control this
behavior.
2012-02-20 21:31:46 +01:00
Georg Brandl 2daf6ae249 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
in order to make algorithmic complexity attacks on (e.g.) web apps much more complicated.

The environment variable PYTHONHASHSEED and the new command line flag -R control this
behavior.
2012-02-20 19:54:16 +01:00
Charles-François Natali 7794090251 Following Nick's suggestion, rename posix.fdlistdir() to posix.flistdir(), to
be consistent with other functions accepting file descriptors (fdlistdir() was
added in 3.3, so hasn't been released yet).
2012-02-06 19:54:48 +01:00
Charles-François Natali 7372b06cd7 Issue #13734: Add os.fwalk(), a directory walking function yielding file
descriptors.
2012-02-05 15:15:38 +01:00
Antoine Pitrou 7b98d02302 Issue #11459: A `bufsize` value of 0 in subprocess.Popen() really creates
unbuffered pipes, such that select() works properly on them.
2011-03-19 17:04:13 +01:00
Antoine Pitrou 877766dee8 Issue #11459: A `bufsize` value of 0 in subprocess.Popen() really creates
unbuffered pipes, such that select() works properly on them.
2011-03-19 17:00:37 +01:00
Antoine Pitrou 1679f4daa1 Issue #11459: A `bufsize` value of 0 in subprocess.Popen() really creates
unbuffered pipes, such that select() works properly on them.
2011-03-19 17:06:22 +01:00
Raymond Hettinger 158c9c26fc Issue #11085: Moved collections abstract base classes into a separate module
called collections.abc, following the pattern used by importlib.abc.  For
backwards compatibility, the names continue to also be imported into the
collections module.
2011-02-22 00:41:50 +00:00
Terry Reedy 5a22b65117 Issue 9299 Add exist_ok parameter to os.makedirs to suppress 'File exists' exception. Patch by Ray Allen. 2010-12-02 07:05:56 +00:00
Victor Stinner bb4f218050 os module: remove nonbreaking space in a comment 2010-11-07 15:43:39 +00:00
Victor Stinner 273b766870 os.get_exec_path() ignores BytesWarning instead of recoding them
Use only one global warning.catch_warnings() context, instead of two local
contexts. Improve also the explaination why the function uses a local import.
2010-11-06 12:59:33 +00:00
Victor Stinner 6f35eda4d9 Issue #10210: os.get_exec_path() ignores BytesWarning warnings 2010-10-29 00:38:58 +00:00
Victor Stinner e882aac16d str.encode() doesn't accept None as errors: use 'strict' instead 2010-10-24 21:12:26 +00:00
Victor Stinner df6d6cb0fa os: fsencode(), fsdecode() and os.environ(b) internal encode-decode methods
keep a local copy of the fileystem encoding, instead of calling
sys.getfilesystemencoding() each time.

The filesystem encoding is now constant.
2010-10-24 20:32:26 +00:00
Victor Stinner 3d75d0cc92 Issue #8603: Environ.data is now protected -> Environ._data
os.environ.data was a str dict in Python 3.1. In Python 3.2 on UNIX/BSD,
os.environ.data is now a bytes dict: mark it as protected to avoid confusion.
2010-09-10 22:18:16 +00:00
Victor Stinner 38430e2dff Fix os.get_exec_path() (code and tests) for python -bb
Catch BytesWarning exceptions.
2010-08-19 17:10:18 +00:00
Victor Stinner e8d5145e18 Create os.fsdecode(): decode from the filesystem encoding with surrogateescape
error handler, or strict error handler on Windows.

 * Rewrite os.fsencode() documentation
 * Improve os.fsencode and os.fsdecode() tests using the new PYTHONFSENCODING
   environment variable
2010-08-19 01:05:19 +00:00
Victor Stinner 70120e202d #8603: Add environb to os.__all__ 2010-07-29 17:19:38 +00:00
Victor Stinner bed7117fda Issue #9283: Oops, add missing { and } to repr(os.environ) 2010-07-28 21:25:42 +00:00
Victor Stinner d73c1a3009 #9283: Fix repr(os.environ), display unicode keys and values on POSIX systems 2010-07-28 21:23:23 +00:00
Victor Stinner 313a120ab6 Issue #8969: On Windows, use mbcs codec in strict mode to encode and decode
filenames and enable os.fsencode().
2010-06-11 23:56:51 +00:00
Victor Stinner b745a74c99 Issue #8513: os.get_exec_path() supports b'PATH' key and bytes value.
subprocess.Popen() and os._execvpe() support bytes program name. Add
os.supports_bytes_environ flag: True if the native OS type of the environment
is bytes (eg. False on Windows).
2010-05-18 17:17:23 +00:00
Victor Stinner 449c466e7d Issue #8514: Add os.fsencode() function (Unix only): encode a string to bytes
for use in the file system, environment variables or the command line.
2010-05-08 11:10:09 +00:00
Victor Stinner 84ae118006 Issue #8603: Create a bytes version of os.environ for Unix
Create os.environb mapping and os.getenvb() function, os.unsetenv() encodes str
argument to the file system encoding with the surrogateescape error handler
(instead of utf8/strict) and accepts bytes, and posix.environ keys and values
are bytes.
2010-05-06 22:05:07 +00:00
Victor Stinner a27dcb76ee Merged revisions 80421,80424 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r80421 | victor.stinner | 2010-04-23 23:41:56 +0200 (ven., 23 avril 2010) | 3 lines

  Issue #8391: os.execvpe() and os.getenv() supports unicode with surrogates and
  bytes strings for environment keys and values
........
  r80424 | victor.stinner | 2010-04-24 00:55:39 +0200 (sam., 24 avril 2010) | 13 lines

  Fix test_undecodable_env of test_subproces for non-ASCII directory

  This test was introduced by r80421 (issue #8391).

  The fix: copy the environment variables instead of starting Python in an empty
  environement. In an empty environment, the locale is C and Python uses ASCII
  for the default file system encoding. The non-ASCII directory will be encoded
  using surrogates, but Python3 is unable to load a module or package with a
  filename using surrogates.

  See issue #8242 for more information about running Python3 with a non-ascii
  directory in an empty environement.
........
2010-04-25 22:39:07 +00:00
Victor Stinner 13bb71c38f Issue #8391: os.execvpe() and os.getenv() supports unicode with surrogates and
bytes strings for environment keys and values
2010-04-23 21:41:56 +00:00
Gregory P. Smith b6e8c7e8fb Add an os.get_exec_path() function to return the list of directories
that launching a subprocess will search for the executable.
Refactors some code in os._execvpe().
2010-02-27 07:22:22 +00:00
Ezio Melotti d2a577d623 Merged revisions 78316 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r78316 | ezio.melotti | 2010-02-22 17:59:01 +0200 (Mon, 22 Feb 2010) | 1 line

  #7310: fix the repr() of os.environ
........
2010-02-22 16:01:22 +00:00
Ezio Melotti 19e4acfa15 #7310: fix the repr() of os.environ 2010-02-22 15:59:01 +00:00