Commit Graph

491 Commits

Author SHA1 Message Date
Berker Peksag 6ef726af3e
bpo-29734: Cleanup test_getfinalpathname_handles test (GH-12908) 2019-04-22 18:46:28 +03:00
Victor Stinner 876e82b4f3
bpo-36234: Add more tests to PosixUidGidTests (GH-12234)
test_posix.PosixUidGidTests:

* Add tests for invalid uid/gid type (str)
* Add UID_OVERFLOW and GID_OVERFLOW constants to replace (1 << 32)

Initial patch written by David Malcolm.

Co-Authored-By: David Malcolm <dmalcolm@redhat.com>
2019-03-11 13:57:53 +01:00
Serhiy Storchaka 5b10b98247
bpo-22831: Use "with" to avoid possible fd leaks in tests (part 2). (GH-10929) 2019-03-05 10:06:26 +02:00
Anthony Sottile 8377cd4fcd Clean up code which checked presence of os.{stat,lstat,chmod} (#11643) 2019-02-25 23:32:27 +01:00
Serhiy Storchaka 8d01eb49fc
Fix syntax warnings in tests introduced in bpo-35942. (GH-11934) 2019-02-19 13:52:35 +02:00
Pablo Galindo 09fbcd6085
bpo-35942: Improve the error message if __fspath__ returns invalid types in path_converter (GH-11831)
The error message emitted when returning invalid types from __fspath__ in interfaces that allow passing PathLike objects has been improved and now it does explain the origin of the error.
2019-02-18 10:46:34 +00:00
pxinwr 3e028b2d40 bpo-35994: add sub dir for sub2_tree in os.walk test if symlink is not supported (GH-11853)
https://bugs.python.org/issue35994
2019-02-14 21:04:47 -08:00
Mark Becwar b82bfac436 bpo-29734: nt._getfinalpathname handle leak (GH-740)
Make sure that failure paths call CloseHandle outside of the function that failed
2019-02-02 13:08:23 -08:00
Serhiy Storchaka 32bc11c33c
bpo-35371: Fix possible crash in os.utime() on Windows. (GH-10844) 2018-12-01 14:30:20 +02:00
Alexey Izbyshev 834603112e bpo-32890, os: Use errno instead of GetLastError() in execve() and truncate() (GH-5784)
path_error() uses GetLastError() on Windows, but some os functions
are implemented via CRT APIs which report errors via errno.
This may result in raising OSError with invalid error code (such
as zero).

Introduce posix_path_error() function and use it where appropriate.
2018-10-20 02:28:22 +02:00
Benjamin Peterson 84db4a9978
closes bpo-34664: Only check file permission bits of newly created directories. (GH-9273) 2018-09-13 12:00:14 -07:00
Oren Milman 0bd1a2dcfd bpo-31577: Fix a crash in os.utime() in case of a bad ns argument. (GH-3752) 2018-09-12 22:14:35 +03:00
Berker Peksag e0b5b2096e
bpo-34384: Fix os.readlink() on Windows (GH-8740)
os.readlink() now accepts path-like and bytes objects on Windows.
Previously, support for path-like and bytes objects was only
implemented on Unix.

This commit also merges Unix and Windows implementations of
os.readlink() in one function and adds basic unit tests to increase
test coverage of the function.
2018-08-15 13:03:41 +03:00
Serhiy Storchaka 9d5727326a
bpo-33871: Fix os.sendfile(), os.writev(), os.readv(), etc. (GH-7931)
* Fix integer overflow in os.readv(), os.writev(), os.preadv()
  and os.pwritev() and in os.sendfile() with headers or trailers
  arguments (on BSD-based OSes and MacOS).

* Fix sending the part of the file in os.sendfile() on MacOS.
  Using the trailers argument could cause sending more bytes from
  the input file than was specified.

Thanks Ned Deily for testing on 32-bit MacOS.
2018-07-31 10:24:54 +03:00
Steve Dower 6921e73e33
bpo-33001: Prevent buffer overrun in os.symlink (GH-5989) 2018-03-05 14:26:08 -08:00
Serhiy Storchaka b21d155f57
bpo-32964: Reuse a testing implementation of the path protocol in tests. (#5930) 2018-03-02 11:53:51 +02:00
SSE4 3c34aad4e7 bpo-29248: Fix os.readlink() on Windows (GH-5577)
The PrintNameOffset field of the reparse data buffer
was treated as a number of characters instead of bytes.
2018-02-12 20:10:35 +03:00
Victor Stinner 13ff24582c
bpo-32593: Drop FreeBSD 9 and older support (#5232)
Drop support of FreeBSD 9 and older.
2018-01-22 18:32:50 +01:00
Benjamin Peterson bbdb17d19b
return the new file descriptor from os.dup2 (closes bpo-32441) (#5041) 2017-12-29 13:13:06 -08:00
Giuseppe Scrivano 96a5e50a5d bpo-32143: add f_fsid to os.statvfs() (#4571)
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2017-12-14 17:46:46 -05:00
Pablo Galindo fb77e0d855 Fix hardcoded value in test_os.py (#4744) 2017-12-07 07:55:44 +01:00
xdegaye 6a55d09573
bpo-29180: Skip test_os tests on PermissionError raised by Android (GH-4374) 2017-11-12 17:57:04 +01:00
Victor Stinner 8c663fd60e
Replace KB unit with KiB (#4293)
kB (*kilo* byte) unit means 1000 bytes, whereas KiB ("kibibyte")
means 1024 bytes. KB was misused: replace kB or KB with KiB when
appropriate.

Same change for MB and GB which become MiB and GiB.

Change the output of Tools/iobench/iobench.py.

Round also the size of the documentation from 5.5 MB to 5 MiB.
2017-11-08 14:44:44 -08:00
Victor Stinner c29b585fd4
bpo-31784: Implement PEP 564: add time.time_ns() (#3989)
Add new time functions:

* time.clock_gettime_ns()
* time.clock_settime_ns()
* time.monotonic_ns()
* time.perf_counter_ns()
* time.process_time_ns()
* time.time_ns()

Add new _PyTime functions:

* _PyTime_FromTimespec()
* _PyTime_FromNanosecondsObject()
* _PyTime_FromTimeval()

Other changes:

* Add also os.times() tests to test_os.
* pytime_fromtimeval() and pytime_fromtimeval() now return
  _PyTime_MAX or _PyTime_MIN on overflow, rather than undefined
  behaviour
* _PyTime_FromNanoseconds() parameter type changes from long long to
  _PyTime_t
2017-11-02 07:28:27 -07:00
Benjamin Peterson 4eaf7f9490 fixes bpo-31866: remove code pertaining to AtheOS support (#4115)
We stop support this OS in 2007 with commit
19fab761b7. Let's finish.
2017-10-25 23:55:14 -07:00
Victor Stinner 01b5aab7bf bpo-31827: Remove os.stat_float_times() (GH-4061) 2017-10-24 02:02:00 -07:00
Victor Stinner a8e7d903d7 os.test_utime_current(): tolerate 50 ms delta (#3646) 2017-09-18 08:49:45 -07:00
Antoine Pitrou a6a4dc816d bpo-31370: Remove support for threads-less builds (#3385)
* Remove Setup.config
* Always define WITH_THREAD for compatibility.
2017-09-07 18:56:24 +02:00
Ville Skyttä 49b2734bf1 Spelling fixes (#2902) 2017-08-03 09:00:59 +03:00
Victor Stinner d1cc037d14 bpo-30908: Fix dangling thread in test_os.TestSendfile (#2680)
tearDown() now clears explicitly the self.server variable to make
sure that the thread is completely cleared when tearDownClass()
checks if all threads have been cleaned up.

Fix the following warning:

$ ./python -m test --fail-env-changed -m test.test_os.TestSendfile.test_keywords -R 3:1 test_os
(...)
Warning -- threading_cleanup() failed to cleanup 0 threads after 3 sec (count: 0, dangling: 2)
(...)
Tests result: ENV CHANGED
2017-07-12 16:05:43 +02:00
Serhiy Storchaka 1180e5a518 bpo-30879: os.listdir() and os.scandir() now emit bytes names when (#2634)
called with bytes-like argument.
2017-07-11 06:36:46 +03:00
Osvaldo Santana Neto 8a8d28501f bpo-30441: Fix bug when modifying os.environ while iterating over it (#2409) 2017-07-01 20:34:45 +03:00
Serhiy Storchaka af5392f5c6 bpo-30746: Port more tests for os.spawnvpe() and os.execve() from 2.7. (#2394) 2017-06-25 09:48:54 +03:00
Serhiy Storchaka 77703942c5 bpo-30746: Prohibited the '=' character in environment variable names (#2382)
in `os.putenv()` and `os.spawn*()`.
2017-06-25 07:33:01 +03:00
Victor Stinner 3402f72688 bpo-30649: Revert utime delta in test_os (#2176)
PPC64 Fedora 3.x buildbot requires at least a delta of 14 ms: revert
the utime delta to 20 ms.

I tried 10 ms, but test_os failed on the PPC64 Fedora 3.x buildbot.
2017-06-14 11:55:17 +02:00
Victor Stinner c94caca65c bpo-30649: test_os tolerates 50 ms delta for utime (#2156)
On Windows, tolerate a delta of 50 ms instead of 20 ms in
test_utime_current() and test_utime_current_old() of test_os.

On other platforms, reduce the delta from 20 ms to 10 ms.
2017-06-13 23:48:27 +02:00
Denis Osipov 897bba7563 bpo-30584: Fix test_os fails on non-English Windows (#1980)
* Fix bpo-30584

* Adding a comment mentionning the bpo and explaining what is the identifier

* Add Denis Osipov to Misc/ACKS
2017-06-07 19:15:26 +02:00
Serhiy Storchaka ea720fe7e9 bpo-25996: Added support of file descriptors in os.scandir() on Unix. (#502)
os.fwalk() is sped up by 2 times by using os.scandir().
2017-03-30 09:12:31 +03:00
Serhiy Storchaka e304e33c16 bpo-19930: The mode argument of os.makedirs() no longer affects the file (#799)
permission bits of newly-created intermediate-level directories.
2017-03-24 13:27:42 +02:00
Serhiy Storchaka 8f6b344d36 bpo-28682: Added support for bytes paths in os.fwalk(). (#489) 2017-03-07 14:33:21 +02:00
Serhiy Storchaka 70d28a184c Remove unused imports. 2016-12-16 20:00:15 +02:00
Steve Dower bce26262d1 Issue #28732: Raise ValueError when argv[0] is empty 2016-11-19 19:17:26 -08:00
Steve Dower 859fd7bd7a Issue #28732: Raise ValueError when os.spawn*() is passed an empty tuple of arguments 2016-11-19 18:53:19 -08:00
Xavier de Gaye 21060105d9 Issue #26935: Fix broken Android dup2() in test_os 2016-11-16 08:05:27 +01:00
Steve Dower 78057b4159 Closes #27781: Removes special cases for the experimental aspect of PEP 529 2016-11-06 19:35:08 -08:00
Serhiy Storchaka b6bd81dee9 Issue #28353: Make test_os.WalkTests.test_walk_bad_dir stable. 2016-10-28 09:18:30 +03:00
Serhiy Storchaka 7865dfff2e Issue #28353: Make test_os.WalkTests.test_walk_bad_dir stable. 2016-10-28 09:17:38 +03:00
Serhiy Storchaka 36888dd970 Issue #28353: Fixed tests of os.fwalk() with broken links. 2016-10-25 20:18:31 +03:00
Serhiy Storchaka 28f982060c Issue #28353: Try to fix tests. 2016-10-25 19:01:41 +03:00
Serhiy Storchaka af4e4747f5 Issue #28353: os.fwalk() no longer fails on broken links. 2016-10-25 14:34:38 +03:00
Serhiy Storchaka 42bababba6 Issue #28353: os.fwalk() no longer fails on broken links. 2016-10-25 14:28:38 +03:00
Berker Peksag bf3c1c3235 Issue #28075: Fix test_access_denied in Python 3.5
I forgot there two variations of os.stat() in Python 3.5.
2016-09-18 13:56:29 +03:00
Berker Peksag 9a1c91a10d Fix test_access_denied in 3.5 2016-09-17 16:20:55 +03:00
Berker Peksag 052e4f18c4 Issue #28075: Merge from 3.5 2016-09-17 15:51:14 +03:00
Berker Peksag 0b4dc4846b Issue #28075: Check for ERROR_ACCESS_DENIED in Windows implementation of os.stat()
Patch by Eryk Sun.
2016-09-17 15:49:59 +03:00
Berker Peksag 4af23d7ddd Use requires_os_func() to skip SpawnTests 2016-09-15 20:32:44 +03:00
Berker Peksag 47e7062f76 Make SpawnTest.create_args() keyword-only 2016-09-15 20:23:55 +03:00
Berker Peksag 8181646931 Issue #28114: Fix a crash in parse_envlist() when env contains byte strings
Patch by Eryk Sun.
2016-09-15 20:19:47 +03:00
Victor Stinner 4659ccff70 Issue #28114: Add unit tests on os.spawn*() 2016-09-14 10:57:00 +02:00
Martin Panter 99e843b48e Correct spelling in documentation and code comment 2016-09-10 10:38:28 +00:00
Steve Dower 3929499914 Issue #1602: Windows console doesn't input or print Unicode (PEP 528)
Closes #17602: Adds a readline implementation for the Windows console
2016-08-30 21:22:36 -07:00
R David Murray 44b548dda8 #27364: fix "incorrect" uses of escape character in the stdlib.
And most of the tools.

Patch by Emanual Barry, reviewed by me, Serhiy Storchaka, and
Martin Panter.
2016-09-08 13:59:53 -04:00
Steve Dower cc16be85c0 Issue #27781: Change file system encoding on Windows to UTF-8 (PEP 529) 2016-09-08 10:35:16 -07:00
Victor Stinner 173a1f3dc7 Fix test_os.GetRandomTests()
Issue #27778: Skip getrandom() tests if getrandom() fails with ENOSYS.
2016-09-06 19:57:40 -07:00
Victor Stinner 9b1f474df6 Add os.getrandom()
Issue #27778: Expose the Linux getrandom() syscall as a new os.getrandom()
function.

This change is part of the PEP 524.
2016-09-06 16:18:52 -07:00
Brett Cannon ec6ce879c7 Issue #26027: Support path-like objects in PyUnicode-FSConverter().
This is to add support for os.exec*() and os.spawn*() functions. Part
of PEP 519.
2016-09-06 15:50:29 -07:00
Benjamin Peterson a9ab165cd2 os.access does not allow a fd 2016-09-05 15:40:59 -07:00
Berker Peksag d0f5bab21b Issue #26027: Fix test_path_t_converter on Windows 2016-08-27 21:26:35 +03:00
Brett Cannon 3ce2fd484b Don't test for path-like bytes paths on Windows 2016-08-27 09:42:40 -07:00
Brett Cannon 8f96a30630 Issue #26027: Don't test for bytearray in path_t as that's now
deprecated.
2016-08-26 19:30:11 -07:00
Brett Cannon 3f9183b5ac Issue #26027, #27524: Add PEP 519/__fspath__() support to os and
os.path.

Thanks to Jelle Zijlstra for the initial patch against posixmodule.c.
2016-08-26 14:44:48 -07:00
Serhiy Storchaka d73c31899e Issue #26800: Undocumented support of general bytes-like objects
as paths in os functions is now deprecated.
2016-08-06 23:22:08 +03:00
Xavier de Gaye d141531eb5 Issue #27472: Add test.support.unix_shell as the path to the default shell. 2016-07-22 12:15:29 +02:00
Brett Cannon 33ed881f79 Fix a failing test introduced as part of issue #27512 2016-07-15 11:26:53 -07:00
Brett Cannon 044283a426 Issue #27512: Don't segfault when os.fspath() calls an object whose
__fspath__() raises an exception.

Thanks to Xiang Zhang for the patch.
2016-07-15 10:41:49 -07:00
Brett Cannon a32c4d0531 Issue #27038: Expose DirEntry as os.DirEntry.
Thanks to Jelle Zijlstra for the code portion of the patch.
2016-06-24 14:14:44 -07:00
Brett Cannon c78ca1e044 Issue #27186: Update os.fspath()/PyOS_FSPath() to check the return
type of __fspath__().

As part of this change, also make sure that the pure Python
implementation of os.fspath() is tested.
2016-06-24 12:03:43 -07:00
Martin Panter 0c9ad59dab Issue #27186: Skip scandir(bytes) test with os.name == "nt" 2016-06-13 03:28:35 +00:00
Brett Cannon 41ae559108 Issue #27186: skip bytes path test for os.scandir() on Windows 2016-06-12 11:11:20 -07:00
Brett Cannon 96881cd621 Issue #27186: Add os.PathLike support to DirEntry
Initial patch thanks to Jelle Zijlstra.
2016-06-10 14:37:21 -07:00
Ethan Furman 228c636908 issue27186: fix fsencode/fsdecode and update tests; patch by Jelle Zijlstra 2016-06-04 13:47:39 -07:00
Ethan Furman 958b3e4058 issue27186: add PathLike ABC 2016-06-04 12:49:35 -07:00
Ethan Furman 410ef8e230 issue27186: add C version of os.fspath(); patch by Jelle Zijlstra 2016-06-04 12:06:26 -07:00
Ethan Furman c1cbeedf0c issue27182: update fsencode and fsdecode for os.path(); patch by Dusty Phillips 2016-06-04 10:19:27 -07:00
Ethan Furman cdc0879d3a issue27186 -- initial docs, tests, and python version of os.fspath 2016-06-02 15:06:09 -07:00
Serhiy Storchaka 9e9235511e Issue #26783: test_os.WalkTests.test_walk_topdown did't test fwalk and bytes.
Patch by Aviv Palivoda.
2016-04-16 17:51:17 +03:00
Serhiy Storchaka a07ab29a79 Issue #26783: test_os.WalkTests.test_walk_topdown did't test fwalk and bytes.
Patch by Aviv Palivoda.
2016-04-16 17:51:00 +03:00
Victor Stinner 53b0a41d31 Issue #25911: more info on test_os failure 2016-03-26 01:12:36 +01:00
Victor Stinner e984eb501b Fix test_os.test_symlink(): remove create symlink 2016-03-25 22:51:17 +01:00
Victor Stinner 32830149d8 changeset: 100749:0b61b2d28a07
tag: tip
parent: 100742:ebae81b31cf6
user: Victor Stinner <victor.stinner@gmail.com>
date: Fri Mar 25 15:03:34 2016 +0100
files: Lib/test/test_os.py
description:
test_os: Win32ErrorTests checks if file exists

Don't use os.path.exists() since it ignores *any* OSError.
2016-03-25 15:12:08 +01:00
Victor Stinner e77c974357 test_os: Win32ErrorTests now ensures that TESTFN doesn't exist
Replace also other open(filename, "w") with open(filename, "x") to fail if a
previous test forgot to remove filename.
2016-03-25 10:28:23 +01:00
Victor Stinner 3899b549e3 test_os: use support.rmtree() to cleanup WalkTests 2016-03-24 17:21:17 +01:00
Victor Stinner ae39d236b4 Enhance and modernize test_os
* add create_file() helper function
* create files using "x" mode instead of "w" to detect when a previous test
  forget to remove a file
* open file for writing in unbuferred mode (buffering=0)
* replace "try/finally: unlink" with self.addCleanup(support.unlink)
* register unlink cleanup function *before* creating new files
2016-03-24 17:12:55 +01:00
Victor Stinner f95a19b900 test_os: use @support.requires_linux_version 2016-03-24 16:50:41 +01:00
Victor Stinner 923590e397 Fix DeprecationWarning on Windows
Issue #25911: Use support.check_warnings() to expect or ignore
DeprecationWarning in test_os.
2016-03-24 09:11:48 +01:00
Serhiy Storchaka 786e922054 Issue #25911: Tring to silence deprecation warnings in bytes path walk tests. 2016-03-08 21:26:44 +02:00
Serhiy Storchaka ada6db7870 Issue #25911: Tring to silence deprecation warnings in bytes path walk tests. 2016-03-08 21:26:26 +02:00
Serhiy Storchaka 706379ae0d Backed out changeset da020e408c7f 2016-03-08 21:16:47 +02:00
Serhiy Storchaka 7ab61ae8aa Backed out changeset f9e22717722d 2016-03-08 21:15:43 +02:00
Serhiy Storchaka adca8464b1 Backed out changeset 19a3e0e664af 2016-03-08 21:13:35 +02:00