Commit Graph

818 Commits

Author SHA1 Message Date
Larry Hastings b333640aba Issue #14127: Fix two bugs with the Windows implementation. 2012-05-04 02:31:57 -07:00
Benjamin Peterson 9bd9d74996 what is a invalid tuple? 2012-05-04 01:42:41 -04:00
Benjamin Peterson b399ab2c5c clean up converted path on error 2012-05-04 01:31:13 -04:00
Benjamin Peterson 3e2e368f3b avoid unitialized memory 2012-05-04 01:14:03 -04:00
Benjamin Peterson 35a8f0dee5 check correct variable for error 2012-05-04 01:10:59 -04:00
Larry Hastings 76ad59b7e8 Issue #14127: Add ns= parameter to utime, futimes, and lutimes.
Removed futimens as it is now redundant.
Changed shutil.copystat to use st_atime_ns and st_mtime_ns from os.stat
and ns= parameter to utime--it once again preserves exact metadata on Linux!
2012-05-03 00:30:07 -07: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
Jesus Cea 1d642d2af1 Closes Issue #14661: posix module: add O_EXEC, O_SEARCH, O_TTY_INIT (I add some Solaris constants too) 2012-04-24 20:59:17 +02:00
Jesus Cea cf381206fc Issue #14661: posix module: add O_EXEC, O_SEARCH, O_TTY_INIT 2012-04-24 20:44:40 +02:00
Larry Hastings 6fe20b3aee Issue #14127: Add st_{cma}time_ns fields to os.stat() result object. 2012-04-19 15:07:49 -07:00
Benjamin Peterson 2dbda07a17 fix condition (#14296) 2012-03-16 10:12:55 -05:00
Benjamin Peterson 7b51b8de38 try to fix compilation on glibc's with cpu sets (#14296) 2012-03-14 22:28:25 -05:00
Victor Stinner 5d272cc6a2 Close #14180: Factorize code to convert a number of seconds to time_t, timeval or timespec
time.ctime(), gmtime(), time.localtime(), datetime.date.fromtimestamp(),
datetime.datetime.fromtimestamp() and datetime.datetime.utcfromtimestamp() now
raises an OverflowError, instead of a ValueError, if the timestamp does not fit
in time_t.

datetime.datetime.fromtimestamp() and datetime.datetime.utcfromtimestamp() now
round microseconds towards zero instead of rounding to nearest with ties going
away from zero.
2012-03-13 13:35:55 +01:00
Brett Cannon efb00c0cc1 Issue #14153 Create _Py_device_encoding() to prevent _io from having to import
the os module.
2012-02-29 18:31:31 -05: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
Antoine Pitrou bcf2b59fb5 Issue #13609: Add two functions to query the terminal size:
os.get_terminal_size (low level) and shutil.get_terminal_size (high level).
Patch by Zbigniew Jędrzejewski-Szmek.
2012-02-08 23:28:36 +01:00
Victor Stinner 4195b5caea Backout f8409b3d6449: the PEP 410 is not accepted yet 2012-02-08 23:03:19 +01:00
Victor Stinner ccd5715a14 PEP 410 2012-02-08 14:31:50 +01:00
Victor Stinner 1aa54a417d Issue #13964: Skip os.*utime*() tests if os.stat() doesn't support timestamp
with a subsecond resolution
2012-02-08 04:09:37 +01:00
Victor Stinner a2f7c00638 Issue #13964: Split os.*utime*() subsecond tests into multiple tests to help
debugging
2012-02-08 03:36:25 +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
Antoine Pitrou f3b2d88b67 Issue #8828: Add new function os.replace(), for cross-platform renaming with overwriting. 2012-01-30 22:08:52 +01:00
Antoine Pitrou 91ecea24f5 Issue #13772: In os.symlink() under Windows, do not try to guess the link
target's type (file or directory).  The detection was buggy and made the
call non-atomic (therefore prone to race conditions).
2012-01-24 09:05:18 +01:00
Antoine Pitrou 5311c1d7ab Issue #13772: In os.symlink() under Windows, do not try to guess the link
target's type (file or directory).  The detection was buggy and made the
call non-atomic (therefore prone to race conditions).
2012-01-24 08:59:28 +01:00
Martin v. Löwis 50590f111b Use GetModuleHandleW to avoid *A functions where possible. 2012-01-14 17:54:09 +01:00
Victor Stinner e83f899364 Issue #13530: Document os.lseek() result
Patch written by Jérémy Anger.
2011-12-17 23:15:09 +01:00
Charles-François Natali 76961faaa0 Issue #13757: Change os.fdlistdir() so that it duplicates the passed file
descriptor (instead of closing it).
2012-01-10 20:25:09 +01:00
Charles-François Natali f2840a8890 Backed out changeset 36f2e236c601: For some reason, rewinddir() doesn't work as
it should on OpenIndiana.
2012-01-08 20:30:47 +01:00
Charles-François Natali 38f425e475 Issue #13739: It's simpler and more direct to call rewinddir() at the
beginning.
2012-01-08 19:07:18 +01:00
Charles-François Natali 7546ad327d Issue #13739: In os.listdir(), rewind the directory stream (so that listdir()
can be called again on the same open file).
2012-01-08 18:34:06 +01:00
Victor Stinner 25ec056cc2 Issue #13530: Document os.lseek() result
Patch written by Jérémy Anger.
2011-12-17 23:15:22 +01:00
Victor Stinner 1b57967b96 Issue #13560: Locale codec functions use the classic "errors" parameter,
instead of surrogateescape

So it would be possible to support more error handlers later.
2011-12-17 05:47:23 +01:00
Victor Stinner 1f33f2b0c3 Issue #13560: os.strerror() now uses the current locale encoding instead of UTF-8 2011-12-17 04:45:09 +01:00
Victor Stinner 984890fcbb Close #13415: Test in configure if unsetenv() has a return value or not.
Patch written by Charles-François Natali.
2011-11-24 13:53:38 +01:00
Benjamin Peterson e8eb0e82f3 merge 3.2 2011-11-22 23:14:47 -06:00
Benjamin Peterson 4bb867d3ec plug refleak 2011-11-22 23:12:49 -06:00
Victor Stinner 65170954e0 (Merge 3.2) Issue #13415: os.unsetenv() doesn't ignore errors anymore. 2011-11-22 22:16:17 +01:00
Victor Stinner 60b385e813 Issue #13415: os.unsetenv() doesn't ignore errors anymore. 2011-11-22 22:01:28 +01:00
Victor Stinner f8facacf30 Fix compiler warnings 2011-11-22 02:30:47 +01:00
Victor Stinner 9d3b93ba30 Use the new Unicode API
* Replace PyUnicode_FromUnicode(NULL, 0) by PyUnicode_New(0, 0)
 * Replce PyUnicode_FromUnicode(str, len) by PyUnicode_FromWideChar(str, len)
 * Replace Py_UNICODE by wchar_t
 * posix_putenv() uses PyUnicode_FromFormat() to create the string, instead
   of PyUnicode_FromUnicode() + _snwprintf()
2011-11-22 02:27:30 +01:00
Victor Stinner f7c5ae2257 Issue #13374: Deprecate os.getcwdb() on Windows 2011-11-16 23:43:07 +01:00
Victor Stinner 1ab6c2d2c2 Issue #13374: The Windows bytes API has been deprecated in the os module. Use
Unicode filenames instead of bytes filenames to not depend on the ANSI code
page anymore and to support any filename.
2011-11-15 22:27:41 +01:00
Victor Stinner 6139c1bfa3 Issue #12442: nt._getdiskusage() is now using the Windows Unicode API 2011-11-09 22:14:14 +01:00
Jesus Cea d03a49150f Commit 59dca1e2363d for issue #13327 introduced a compilation warning 2011-11-08 17:28:04 +01:00
Brian Curtin 569b494320 Fix #13327. utimensat now has the atime and mtime arguments set as optional,
defaulting to None like the other utimes family members. It now accepts
keyword arguments because, unlike other other functions in the family,
it has a `flags` value at the end of the argument list (which
retains its 0 default).
2011-11-07 16:09:20 -06:00
Brian Curtin 7ef53ef916 Forgot to apply the futimesat change. 2011-11-07 14:38:24 -06:00
Brian Curtin c1b65d1831 Fix 13327. Remove explicit None arguments from futimes, futimens, futimesat,
and lutimes.
2011-11-07 14:18:54 -06:00
Brian Curtin b0d5b5d3b2 Adjust None handling to be a bit more clean. Thanks to Benjamin
for pointing it out.
2011-11-07 10:51:18 -06:00
Brian Curtin 52fbea1d87 Fix #13327. Remove the need for an explicit None as the second argument to
os.utime in order to update to the current time. The second argument is now
optional.
2011-11-06 13:41:17 -06:00
Ross Lagerwall ab1078b987 (Merge 3.2) Issue #13339. 2011-11-04 07:15:35 +02:00
Ross Lagerwall dcfde5aac9 Issue #13339: Fix compile error in posixmodule.c due to missing semicolon.
Thanks to Robert Xiao.
2011-11-04 07:09:14 +02:00
Victor Stinner 8b905bd9d4 Issue #13226: Add RTLD_xxx constants to the os module. These constants can by
used with sys.setdlopenflags().
2011-10-25 13:34:04 +02:00
Martin v. Löwis bd928fef42 Rename _Py_identifier to _Py_IDENTIFIER. 2011-10-14 10:20:37 +02:00
Victor Stinner beac78bb24 Use PyUnicode_AsUnicodeAndSize() instead of PyUnicode_GET_SIZE() 2011-10-11 21:55:01 +02:00
Martin v. Löwis 1ee1b6fe0d Use identifier API for PyObject_GetAttrString. 2011-10-10 18:11:30 +02:00
Victor Stinner 034f6cf10c Add PyUnicode_Copy() function, include it to the public API 2011-09-30 02:26:44 +02:00
Victor Stinner eb5657a0c5 posix module catches PyUnicode_AsUnicode() failure
* Replace PyUnicode_AS_UNICODE by PyUnicode_AsUnicode, PyUnicode_AS_UNICODE is
   no more a real macro
 * Replace Py_UNICODE by wchar_t in code specific to Windows
2011-09-30 01:44:27 +02:00
Victor Stinner 639418812f Use the new Py_ARRAY_LENGTH macro 2011-09-29 00:42:28 +02:00
Victor Stinner 6fa6777503 os.statvfs() encodes the filename to the filesystem encoding 2011-09-20 04:04:33 +02:00
Ross Lagerwall b1e5d595af Issue #12517: Silence warning on windows buildbots (from 7fd80c61ddaa). 2011-09-19 08:30:43 +02:00
Benjamin Peterson 9428d53eb4 only compile xattrs on glibc (closes #12720) 2011-09-14 11:45:52 -04:00
Benjamin Peterson b77fe17320 Use xattr functions from sys/xattr.h instead of attr/xattr.h (closes #12720)
sys/xattr.h is glibc while attr/xattr.h is a separate library.
2011-09-13 17:20:47 -04:00
Jesus Cea 54b01498e3 Typo 2011-09-10 01:53:19 +02:00
Jesus Cea 9c82227277 Yet another fix for #12763: test_posix failure on OpenIndiana 2011-09-10 01:40:52 +02:00
Jesus Cea f2cb4e8b35 Close issue 12952: Solaris/Illumos (OpenIndiana) Scheduling policies 2011-09-09 23:55:42 +02:00
Larry Hastings 9e3e70b331 Issue #12904: os.utime, os.futimes, os.lutimes, and os.futimesat now write
atime and mtime with nanosecond precision on modern POSIX platforms.
2011-09-08 19:29:07 -07:00
Charles-François Natali ea0d5fcb4a Issue #12871: sched_get_priority_(min|max) might not be defined even though
<sched.h> is available (most notably on OpenBSD when built without pthread):
add an explicit configure check.
2011-09-06 19:03:35 +02:00
Benjamin Peterson 799bd80d8a expose linux extended file system attributes (closes #12720) 2011-08-31 22:15:17 -04:00
Brian Curtin dfc80e3d97 Replace Py_NotImplemented returns with the macro form Py_RETURN_NOTIMPLEMENTED.
The macro was introduced in #12724.
2011-08-10 20:28:54 -05:00
Benjamin Peterson a17a5d67b4 typo 2011-08-09 16:49:13 -05:00
Benjamin Peterson 087a2a951c merge 3.2 2011-08-04 11:09:57 -05:00
Benjamin Peterson fc9bbd1692 dosmodule is, thankfully, no more 2011-08-04 11:07:42 -05:00
Benjamin Peterson 7ac9214e43 fix arg strings 2011-08-03 08:54:26 -05:00
Benjamin Peterson 4e36d5ae88 need NULL sentinel 2011-08-02 19:56:11 -05:00
Benjamin Peterson bad9c2f13a avoid warning when SchedParamType is not used 2011-08-02 18:42:14 -05:00
Benjamin Peterson e3298dda6d only add sched_param if it is initialized 2011-08-02 18:40:46 -05:00
Benjamin Peterson 8f7bdd3208 I have been spoiled by chained comparisons in python 2011-08-02 18:34:30 -05:00
Benjamin Peterson 9b374bfa03 comparing on number of cpus makes more sense 2011-08-02 18:22:30 -05:00
Benjamin Peterson 0163c9aa0c fix sched defines 2011-08-02 18:11:38 -05:00
Benjamin Peterson c5fce4ded2 check individually for some for sched_ functions 2011-08-02 18:07:32 -05:00
Benjamin Peterson e870fe601a make_new_cpu_set takes the number of cpus 2011-08-02 17:44:26 -05:00
Benjamin Peterson 2740af8cc4 sched.h can exist without sched affinity support 2011-08-02 17:41:34 -05:00
Benjamin Peterson 94b580d423 expose sched.h functions (closes #12655) 2011-08-02 17:30:04 -05:00
Charles-François Natali 6613c18ea2 Issue #13415: Test in configure if unsetenv() has a return value or not. 2011-11-27 12:41:06 +01:00
Benjamin Peterson 06403cff16 decref correct object 2011-11-22 23:57:23 -06:00
Giampaolo Rodola' 210e7ca032 Issue #12442: add shutil.disk_usage() 2011-07-01 13:55:36 +02:00
Victor Stinner 6ee7a57b38 (Merge 3.2) posixmodule.c: fix function name in argument parsing
Fix os.fchown() and os.open()

Remove also trailing spaces and replace tabs by spaces.
2011-06-17 15:18:16 +02:00
Victor Stinner 26de69dff8 posixmodule.c: fix function name in argument parsing
Fix os.fchown() and os.open()

Remove also trailing spaces and replace tabs by spaces.
2011-06-17 15:15:38 +02:00
Brian Curtin 4ff1a414f8 Merge 3.2 - update to the fix for #12084 2011-06-14 10:06:41 -05:00
Brian Curtin c8be84077b Correct completely broken os.stat behavior on Windows XP.
After 1a3e8db28d49, Windows XP could not os.stat at all due to raising
immediately when GetFinalPathNameByHandle wasn't available (pre-Vista).
The proper behavior in that situation is to just not attempt a traversal
rather than outright rejecting.

This change additionally handles a failed malloc by setting the error code
and returning false.

Patch by Hirokazu Yamamoto.
2011-06-14 09:52:50 -05:00
Brian Curtin a87d586fd6 branch merge? 2011-06-13 16:10:32 -05:00
Brian Curtin c9d6a501db branch merge 2011-06-13 16:03:01 -05:00
Brian Curtin 3e86c99f90 Merge from 3.2 for Issue #12084. 2011-06-13 16:00:35 -05:00
Brian Curtin d25aef55c8 Fix #12084. os.stat on Windows wasn't working properly with relative symlinks.
Use of DeviceIoControl to obtain the symlink path via the reparse tag was
removed. The code now uses GetFinalPathNameByHandle in the case of a
symbolic link and works properly given the added test which creates a symbolic
link and calls os.stat on it from multiple locations.

Victor Stinner also noticed an issue with os.lstat following the os.stat
code path when being passed bytes. The posix_lstat function was adjusted to
properly hook up win32_lstat instead of the previous STAT macro (win32_stat).
2011-06-13 15:16:04 -05:00
Ross Lagerwall b0ae53d8a0 Issue #9344: Add os.getgrouplist(). 2011-06-10 07:30:30 +02:00
Brian Curtin d9463b233c Merge 3.2 2011-06-09 09:46:21 -05:00
Brian Curtin 95d028fd18 Correction to 88e318166eaf - Issue #11583
Rather than wrapping the C _isdir function in a Python function,
just import the C _isdir function directly. Additionally, add in the
docstring which was left out.
2011-06-09 09:10:38 -05:00
Brian Curtin 9a82eaade3 Fix #11583. Changed os.path.isdir to use GetFileAttributes instead of os.stat.
By changing to the Windows GetFileAttributes API in nt._isdir we can figure
out if the path is a directory without opening the file via os.stat. This has
the minor benefit of speeding up os.path.isdir by at least 2x for regular
files and 10-15x improvements were seen on symbolic links (which opened the
file multiple times during os.stat). Since os.path.isdir is used in
several places on interpreter startup, we get a minor speedup in startup time.
2011-06-08 18:43:57 -05:00
Brian Curtin 9c669ccc77 Fix #11583. Changed os.path.isdir to use GetFileAttributes instead of os.stat.
By changing to the Windows GetFileAttributes API in nt._isdir we can figure
out if the path is a directory without opening the file via os.stat. This has
the minor benefit of speeding up os.path.isdir by at least 2x for regular
files and 10-15x improvements were seen on symbolic links (which opened the
file multiple times during os.stat). Since os.path.isdir is used in
several places on interpreter startup, we get a minor speedup in startup time.
2011-06-08 18:17:18 -05:00
Charles-François Natali 368f34bb4b Issue #12196: Make os.pipe2() flags argument mandatory. 2011-06-06 19:49:47 +02:00
Charles-François Natali daafdd5bea Issue #12196: Add pipe2() to the os module. 2011-05-29 20:07:40 +02:00
Victor Stinner 7870bdff5a Issue #6501: os.device_encoding() returns None on Windows if the application
has no console.
2011-05-23 18:12:52 +02:00
Charles-François Natali 1e045b1831 Issue #12105: Add O_CLOEXEC to the os module. 2011-05-22 20:42:32 +02:00
Victor Stinner b90db4caf0 Issue #11918: OS/2 and VMS are no more supported because of the lack of
maintainer.
2011-04-26 22:48:24 +02:00
Antoine Pitrou 877509aef4 Issue #11382: Trivial system calls, such as dup() or pipe(), needn't
release the GIL.  Patch by Charles-François Natali.
2011-04-23 17:21:13 +02:00
Giampaolo Rodola' ff1a73590d os.sendfile(): on Linux if offset parameter is passed as NULL we were erroneously returning a (bytes_sent, None) tuple instead of bytes_sent 2011-04-19 09:47:16 +02:00
Ezio Melotti 4969f709cc #11515: Merge with 3.1. 2011-03-15 05:59:46 +02:00
Ross Lagerwall 9ad63e0914 Fix refleak introduced by #10812. 2011-03-19 09:11:14 +02:00
Ross Lagerwall 4d076da4de Issue #11592: Fix compilation warnings in os module. 2011-03-18 06:56:53 +02:00
Ross Lagerwall 8e74967855 Issue #10812: Revert os.lseek change. 2011-03-17 21:54:07 +02:00
Ross Lagerwall 7807c3545d Issue #10812: Add some extra posix functions to the os module. 2011-03-17 20:20:30 +02:00
Ezio Melotti 373089239b #11515: Merge with 3.2. 2011-03-15 06:03:08 +02:00
Giampaolo Rodolà acdad9a40b Issue 11351 - apply patch by Steffen Daode Nurpmeso which should fix TestSendfile.test_headers failure on OSX. 2011-03-03 16:10:51 +00:00
Benjamin Peterson d8a43b4a4b revert accidental formatting change 2011-02-26 21:35:16 +00:00
Benjamin Peterson c6696d272f this isn't true anymore 2011-02-26 21:32:16 +00:00
Antoine Pitrou dcc20b8563 Check error return from _parse_off_t(), and remove cruft from the 2->3 transition. 2011-02-26 13:38:35 +00:00
Antoine Pitrou 8250e23abd Issue #10755: Add the posix.fdlistdir() function. Patch by Ross Lagerwall. 2011-02-25 23:41:16 +00:00
Antoine Pitrou f65132de3d Issue #4761: Add the *at() family of functions (openat(), etc.) to the posix
module.  Patch by Ross Lagerwall.
2011-02-25 23:25:17 +00:00
Giampaolo Rodolà 18e8bcb289 Issue 10784: adds os.getpriority() and os.setpriority() functions. 2011-02-25 20:57:54 +00:00
Georg Brandl a391b11320 Rename internal helper function and make it static. 2011-02-25 15:23:18 +00:00
Giampaolo Rodolà c9c2c8b034 Issue 10882: add os.sendfile(). (patch provided by Ross Lagerwall) 2011-02-25 14:39:16 +00:00
Antoine Pitrou 710e96651d Merged revisions 88111 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r88111 | antoine.pitrou | 2011-01-19 16:21:35 +0100 (mer., 19 janv. 2011) | 4 lines

  Issue #10898: Allow compiling the posix module when the C library defines
  a symbol named FSTAT.
........
2011-01-19 15:26:37 +00:00
Antoine Pitrou e47e093f70 Issue #10898: Allow compiling the posix module when the C library defines
a symbol named FSTAT.
2011-01-19 15:21:35 +00:00
Victor Stinner 7234479580 Issue #9611: remove useless and dangerous explicit conversion to size_t 2011-01-11 00:04:12 +00:00
Antoine Pitrou ff17385fbd Merged revisions 87802 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r87802 | antoine.pitrou | 2011-01-06 19:25:55 +0100 (jeu., 06 janv. 2011) | 6 lines

  Issue #7858: Raise an error properly when os.utime() fails under Windows
  on an existing file.

  (this does not seem to be easily testable)
........
2011-01-06 18:29:05 +00:00
Antoine Pitrou e85da7aa4f Issue #7858: Raise an error properly when os.utime() fails under Windows
on an existing file.

(this does not seem to be easily testable)
2011-01-06 18:25:55 +00:00
Victor Stinner e6edec2371 Issue #9015, #9611: FileIO.readinto(), FileIO.write() and os.write() clamp the
length to 2^31-1 on Windows.
2011-01-04 00:29:35 +00:00
Amaury Forgeot d'Arc 32e8aab1fb Merged revisions 87666 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r87666 | amaury.forgeotdarc | 2011-01-03 01:19:11 +0100 (lun., 03 janv. 2011) | 4 lines

  #8278: In the Windows implementation of stat() and utime(),
  use time_t instead of int.  This gives support for dates after 2038,
  at least when compiled with VS2003 or later, where time_t is 64bit.
........
2011-01-03 00:40:04 +00:00
Amaury Forgeot d'Arc a251a853c7 #8278: In the Windows implementation of stat() and utime(),
use time_t instead of int.  This gives support for dates after 2038,
at least when compiled with VS2003 or later, where time_t is 64bit.
2011-01-03 00:19:11 +00:00
Brian Curtin 3b4499c5c7 Fix #9333. The symlink function is always available now, raising OSError
when the user doesn't hold the symbolic link privilege rather than hiding it.
2010-12-28 14:31:47 +00:00
Hirokazu Yamamoto 7ed117addf Issue #10637: Called CloseHandle twice in os.stat/os.lstat (Windows) 2010-12-07 10:24:37 +00:00
Hirokazu Yamamoto 26253bb09e Should use posix_error here. 2010-12-05 04:16:47 +00:00
Hirokazu Yamamoto 74673513e7 Sorry, I had introduced tab in source code. 2010-12-05 02:48:08 +00:00
Hirokazu Yamamoto 427d3149eb Fixed several corner case issues on os.stat/os.lstat related to reparse
points. (Windows)

- Set S_IEXEC via final path name not link name.
- Set S_IFLNK also via FindFirstFile (when CreateFile fails)
2010-12-04 10:16:05 +00:00
Brian Curtin 52173d4959 Fix #9333. Expose os.symlink on Windows only when usable.
In order to create symlinks on Windows, SeCreateSymbolicLinkPrivilege
is an account privilege that is required to be held by the user. Not only
must the privilege be enabled for the account, the activated privileges for
the currently running application must be adjusted to enable the requested
privilege.

Rather than exposing an additional function to be called prior to the user's
first os.symlink call, we handle the AdjustTokenPrivileges Windows API call
internally and only expose os.symlink when the privilege escalation was
successful.

Due to the change of only exposing os.symlink when it's available, we can
go back to the original test skipping methods of checking via `hasattr`.
2010-12-02 18:29:18 +00:00
Georg Brandl 71c23d4473 Include structseq.h in Python.h, and remove now-redundant includes in individual sources. 2010-11-30 09:30:54 +00:00
Brian Curtin fc889c48ed Fix for #8879.
Amaury noticed that this was originally written in a way that would fail on
names that can't be encoded with the mbcs codec. Restructured the function
to work with wide names first then narrow names second, to fall in line
with the way other functions are written in posixmodule.c.
2010-11-28 23:59:46 +00:00
Stefan Krah 2a7feee76d Windows: fix leak in posix_listdir. 2010-11-27 22:06:49 +00:00
Stefan Krah 30b341f1a5 Fix additional leaks. 2010-11-27 11:44:18 +00:00
Stefan Krah 6773331104 Merged revisions 86808 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r86808 | stefan.krah | 2010-11-26 17:16:47 +0100 (Fri, 26 Nov 2010) | 1 line

  Further indentation cleanup.
........
2010-11-26 17:04:40 +00:00
Stefan Krah 0e803b3322 Further indentation cleanup. 2010-11-26 16:16:47 +00:00
Stefan Krah 40b61237bd Merged revisions 86804 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r86804 | stefan.krah | 2010-11-26 13:58:05 +0100 (Fri, 26 Nov 2010) | 1 line

  Issue #10383: Fix two leaks.
........
2010-11-26 15:08:59 +00:00
Stefan Krah 99439266a3 Issue #10383: Fix two leaks. 2010-11-26 12:58:05 +00:00
Brian Curtin 1b9df39620 Fix #8879. Add os.link support to Windows.
Additionally, the st_ino attribute of stat structures was not being filled
in. This was left out of the fix to #10027 and was noticed due to
test_tarfile failing when applying the patch for this issue. An earlier
version of the fix to #10027 included st_ino, but that attribute got lost
in the shuffle of a few review/fix cycles. All tests pass.
2010-11-24 20:24:31 +00:00
Brian Curtin fc1be6d807 ifdef a Windows specific section. 2010-11-24 13:23:18 +00:00
Brian Curtin f5e76d01ea Fix #10027. st_nlink not set on Windows calls to os.stat/lstat.
Note: This patch has no tests because as of now there is no way to create
links. #8879 adds that and the tests will go in there. I've manually observed
that existing links on my system function properly with this.
2010-11-24 13:14:05 +00:00
Jesus Cea 7e9065cf8c Issue #10143: Update "os.pathconf" values 2010-10-25 13:02:04 +00:00
Brian Curtin 94622b0013 Fix a typo. full->final 2010-09-24 00:03:39 +00:00
Brian Curtin e8e4b3bfd6 #9808. Implement os.getlogin for Windows, completed by Jon Anglin.
The test is semi-dumb, it just makes sure something comes back since we
don't have a solid source to validate the returned login. We can't be 100%
sure that the USERNAME env var will always match what os.getlogin() returns,
so we don't make any specific assertion there.
2010-09-23 20:04:14 +00:00
Antoine Pitrou 38425292fb Issue #9908: Fix os.stat() on bytes paths under Windows 7. 2010-09-21 18:19:07 +00:00
Amaury Forgeot d'Arc 6c9c09058f Remove unused code in posixmodule.c 2010-09-17 23:39:42 +00:00
Antoine Pitrou 3d330add9e Remove C++-style comments 2010-09-14 10:08:08 +00:00
Victor Stinner cb04352e8c Issue #9579, #9580: Fix os.confstr() for value longer than 255 bytes and encode
the value with filesystem encoding and surrogateescape (instead of utf-8 in
strict mode).
2010-09-10 23:49:04 +00:00
Amaury Forgeot d'Arc 66d00ad2ea Untabify file. 2010-09-10 18:11:45 +00:00
Amaury Forgeot d'Arc 4b6fdf3852 #6394: Add os.getppid() support for Windows. 2010-09-07 21:31:17 +00:00
Brian Curtin 6285774f06 Implement #7566 - os.path.sameopenfile for Windows.
This uses the GetFileInformationByHandle function to return a tuple of values
to identify a file, then ntpath.sameopenfile compares file tuples, which
is exposed as os.path.sameopenfile.
2010-09-06 17:07:27 +00:00
Georg Brandl a9b51d2a0e #9747: fix copy-paste error in getresgid() doc. 2010-09-05 17:07:12 +00:00
Antoine Pitrou 037077fe03 Merged revisions 84489 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r84489 | antoine.pitrou | 2010-09-04 19:21:57 +0200 (sam., 04 sept. 2010) | 4 lines

  Issue #7736: Release the GIL around calls to opendir() and closedir()
  in the posix module.  Patch by Marcin Bachry.
........
2010-09-04 17:26:01 +00:00
Antoine Pitrou d3ccde8a21 Issue #7736: Release the GIL around calls to opendir() and closedir()
in the posix module.  Patch by Marcin Bachry.
2010-09-04 17:21:57 +00:00
Andrew M. Kuchling 4ea04a306f #7647: add ST_RDONLY, ST_NOSUID constants to os module.
(Also fix a name ordering in the ACKS file.)
2010-08-18 22:30:34 +00:00
Amaury Forgeot d'Arc 844807ead2 r82659 reintroduced some tab characters. Untabify again. 2010-08-16 22:16:51 +00:00
Antoine Pitrou 835b445a91 Merged revisions 84076 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r84076 | antoine.pitrou | 2010-08-15 20:07:50 +0200 (dim., 15 août 2010) | 4 lines

  Fix other warnings under 64-bit Windows.
........
2010-08-15 18:32:16 +00:00
Antoine Pitrou 22e4155706 Fix other warnings under 64-bit Windows. 2010-08-15 18:07:50 +00:00
Victor Stinner 85675994e6 Merged revisions 84063 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r84063 | victor.stinner | 2010-08-15 11:33:08 +0200 (dim., 15 août 2010) | 5 lines

  Issue #9605: posix.getlogin() decodes the username with file filesystem
  encoding and surrogateescape error handler. Patch written by David Watson.

  Reindent also posix_getlogin(), and fix a typo in the NEWS file.
........
2010-08-15 09:35:13 +00:00
Victor Stinner e039ffe41d Issue #9605: posix.getlogin() decodes the username with file filesystem
encoding and surrogateescape error handler. Patch written by David Watson.

Reindent also posix_getlogin(), and fix a typo in the NEWS file.
2010-08-15 09:33:08 +00:00
Victor Stinner 61ec5dca2b Issue #9604: posix.initgroups() encodes the username using the fileystem
encoding and surrogateescape error handler. Patch written by David Watson.
2010-08-15 09:22:44 +00:00
Victor Stinner bae0e623f9 Merged revisions 84060 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r84060 | victor.stinner | 2010-08-15 11:12:51 +0200 (dim., 15 août 2010) | 4 lines

  Issue #9603: posix.ttyname() and posix.ctermid() decode the terminal name
  using the filesystem encoding and surrogateescape error handler. Patch
  written by David Watson.
........
2010-08-15 09:15:02 +00:00
Victor Stinner 5fe6de8c72 Issue #9603: posix.ttyname() and posix.ctermid() decode the terminal name
using the filesystem encoding and surrogateescape error handler. Patch
written by David Watson.
2010-08-15 09:12:51 +00:00
Benjamin Peterson 9ecbc07256 Merged revisions 83951 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r83951 | benjamin.peterson | 2010-08-11 14:20:42 -0500 (Wed, 11 Aug 2010) | 4 lines

  use pep 383 decoding for mknod and mkfifo #9570

  Patch by David Watson.
........
2010-08-11 19:24:27 +00:00
Benjamin Peterson d4efbf90d2 use pep 383 decoding for mknod and mkfifo #9570
Patch by David Watson.
2010-08-11 19:20:42 +00:00
Antoine Pitrou bd25d598a5 Merged revisions 83921 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r83921 | antoine.pitrou | 2010-08-10 01:39:31 +0200 (mar., 10 août 2010) | 4 lines

  Issue #6915: Under Windows, os.listdir() didn't release the Global
  Interpreter Lock around all system calls.  Original patch by Ryan Kelly.
........
2010-08-09 23:47:57 +00:00
Antoine Pitrou b73caab436 Issue #6915: Under Windows, os.listdir() didn't release the Global
Interpreter Lock around all system calls.  Original patch by Ryan Kelly.
2010-08-09 23:39:31 +00:00
Raymond Hettinger 0291c9ffa2 Issue 9445: Fix undefined symbols on VS8.0 build. 2010-08-01 21:10:35 +00:00
Ronald Oussoren 47076f7897 This fixes issue7900 by adding code that deals
with the fact that getgroups(2) might return
more that MAX_GROUPS on OSX.

See the issue (and python-dev archives) for the
gory details. Summarized: OSX behaves rather oddly
and Apple says this is intentional.
2010-07-23 15:46:03 +00:00
Ronald Oussoren b6ee4f5bfc This fixes issue7900 by adding code that deals
with the fact that getgroups(2) might return
more that MAX_GROUPS on OSX.

See the issue (and python-dev archives) for the
gory details. Summarized: OSX behaves rather oddly
and Apple says this is intentional.
2010-07-23 13:53:51 +00:00
Martin v. Löwis c9e1c7d97f Issue #6095: Make directory argument to os.listdir optional.
Patch by Virgil Dupras.
2010-07-23 12:16:41 +00:00
Brian Curtin 74e4561a3c Re-flow several long lines from #1578269. 2010-07-09 15:58:59 +00:00
Brian Curtin d40e6f70a5 Implement #1578269. Patch by Jason R. Coombs.
Added Windows support for os.symlink when run on Windows 6.0 or greater,
aka Vista. Previous Windows versions will raise NotImplementedError
when trying to symlink.

Includes numerous test updates and additions to test_os, including
a symlink_support module because of the fact that privilege escalation
is required in order to run the tests to ensure that the user is able
to create symlinks. By default, accounts do not have the required
privilege, so the escalation code will have to be exposed later (or
documented on how to do so). I'll be following up with that work next.

Note that the tests use ctypes, which was agreed on during the PyCon
language summit.
2010-07-08 21:39:08 +00:00
Senthil Kumaran 28fdadb768 Merged revisions 82049 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r82049 | senthil.kumaran | 2010-06-17 22:18:06 +0530 (Thu, 17 Jun 2010) | 9 lines

  Merged revisions 82047 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r82047 | senthil.kumaran | 2010-06-17 22:08:34 +0530 (Thu, 17 Jun 2010) | 3 lines

    Fix Issue4452 - Incorrect docstring of os.setpgrp
  ........
................
2010-06-17 16:51:08 +00:00
Senthil Kumaran 684760a148 Merged revisions 82047 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r82047 | senthil.kumaran | 2010-06-17 22:08:34 +0530 (Thu, 17 Jun 2010) | 3 lines

  Fix Issue4452 - Incorrect docstring of os.setpgrp
........
2010-06-17 16:48:06 +00:00
Amaury Forgeot d'Arc 0a589c9898 Remove unused variable, and fix a compilation warning on Windows. 2010-05-15 20:35:12 +00:00
Victor Stinner 203406c368 Revert r81171 (posix_listdir(), posix_readlink(): avoid temporary PyBytes object)
PyUnicode_DecodeFSDefault*() doesn't use surrogateescape error handler, and so
PyUnicode_FromEncodedObject(v, Py_FileSystemDefaultEncoding, "surrogateescape")
cannot be replaced by PyUnicode_DecodeFSDefault().

It's a bad idea to try to fix surrogates things in Python 3.1...
2010-05-14 18:07:39 +00:00
Victor Stinner 26a968d8fe Merged revisions 81170 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r81170 | victor.stinner | 2010-05-14 18:35:39 +0200 (ven., 14 mai 2010) | 6 lines

  posix_listdir(), posix_readlink(): avoid temporary PyBytes object

  Use directly PyUnicode_DecodeFSDefaultAndSize() instead of
  PyBytes_FromStringAndSize() + PyUnicode_FromEncodedObject() if the argument is
  unicode.
........
2010-05-14 16:39:10 +00:00
Victor Stinner a45598a035 posix_listdir(), posix_readlink(): avoid temporary PyBytes object
Use directly PyUnicode_DecodeFSDefaultAndSize() instead of
PyBytes_FromStringAndSize() + PyUnicode_FromEncodedObject() if the argument is
unicode.
2010-05-14 16:35:39 +00:00
Victor Stinner 77ccd6d0c7 posix_error_with_allocated_filename() decodes the filename with
PyUnicode_DecodeFSDefaultAndSize() and call
PyErr_SetFromErrnoWithFilenameObject() instead of
PyErr_SetFromErrnoWithFilename()
2010-05-08 00:36:42 +00:00
Victor Stinner 97c18ab6a5 Replace PyUnicode_Decode(buf, strlen(buf), Py_FileSystemDefaultEncoding,
"surrogateescape") by PyUnicode_DecodeFSDefault(val).
2010-05-07 16:34:53 +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 97b8988e6e Recorded merge of revisions 80846 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r80846 | victor.stinner | 2010-05-06 02:08:46 +0200 (jeu., 06 mai 2010) | 20 lines

  Recorded merge of revisions 80844-80845 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r80844 | victor.stinner | 2010-05-06 01:33:33 +0200 (jeu., 06 mai 2010) | 5 lines

    Untabify Modules/posixmodule.c

    Run Antoine Pitrou "untabify" script + manual editions (OS/2 and some
    continuation lines).
  ........
    r80845 | victor.stinner | 2010-05-06 02:03:44 +0200 (jeu., 06 mai 2010) | 4 lines

    Untabify Modules/posixmodule.c (2)

    Fix some more functions by hand
  ........

  I rewrote the patch for py3k from scratch using untabify + manual editions
................
2010-05-06 00:25:39 +00:00
Victor Stinner 8c62be88e6 Recorded merge of revisions 80844-80845 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r80844 | victor.stinner | 2010-05-06 01:33:33 +0200 (jeu., 06 mai 2010) | 5 lines

  Untabify Modules/posixmodule.c

  Run Antoine Pitrou "untabify" script + manual editions (OS/2 and some
  continuation lines).
........
  r80845 | victor.stinner | 2010-05-06 02:03:44 +0200 (jeu., 06 mai 2010) | 4 lines

  Untabify Modules/posixmodule.c (2)

  Fix some more functions by hand
........

I rewrote the patch for py3k from scratch using untabify + manual editions
2010-05-06 00:08:46 +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
Victor Stinner dcb2403022 Issue #8485: PyUnicode_FSConverter() doesn't accept bytearray object anymore,
you have to convert your bytearray filenames to bytes
2010-04-22 12:08:36 +00:00
Mark Dickinson 466e9266d1 Merged revisions 80108,80111,80114-80115 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r80108 | victor.stinner | 2010-04-16 13:23:43 +0100 (Fri, 16 Apr 2010) | 4 lines

  Add CS_GNU_LIBC_VERSION and CS_GNU_LIBPTHREAD_VERSION constants for constr(),
  and disable test_execvpe_with_bad_program() of test_os if the libc uses
  linuxthreads to avoid the "unknown signal 32" bug (see issue #4970).
........
  r80111 | mark.dickinson | 2010-04-16 13:47:52 +0100 (Fri, 16 Apr 2010) | 1 line

  Keep confstr entries in alphabetical order.
........
  r80114 | mark.dickinson | 2010-04-16 14:45:35 +0100 (Fri, 16 Apr 2010) | 1 line

  Issue #4970:  move linuxthreads check outside the affected test, and use skipIf
........
  r80115 | mark.dickinson | 2010-04-16 14:51:27 +0100 (Fri, 16 Apr 2010) | 1 line

  Don't assume that os.confstr_names exists.
........
2010-04-16 16:32:49 +00:00
Victor Stinner a5ab4fcf68 Merged revisions 80105 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r80105 | victor.stinner | 2010-04-16 13:45:13 +0200 (ven., 16 avril 2010) | 3 lines

  Issue #8412: os.system() now accepts bytes, bytearray and str with
  surrogates.
........
2010-04-16 12:47:52 +00:00
Mark Dickinson 876d7c84e6 Keep confstr entries in alphabetical order. 2010-04-16 12:47:52 +00:00
Victor Stinner 6f7adcc58e Add CS_GNU_LIBC_VERSION and CS_GNU_LIBPTHREAD_VERSION constants for constr(),
and disable test_execvpe_with_bad_program() of test_os if the libc uses
linuxthreads to avoid the "unknown signal 32" bug (see issue #4970).
2010-04-16 12:23:43 +00:00
Victor Stinner cfa72789c4 Issue #8412: os.system() now accepts bytes, bytearray and str with
surrogates.
2010-04-16 11:45:13 +00:00