Skip to content

bpo-35381 Remove all static state from posixmodule #15892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 45 commits into from
Nov 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
e09cf81
Make Posixmodule use PyType_FromSpec
eduardo-elizondo Dec 3, 2018
40f0ff4
Added NEWS
eduardo-elizondo Dec 3, 2018
5be18a1
Updated hash
eduardo-elizondo Dec 3, 2018
9479848
Addressed PR Issues
eduardo-elizondo Jan 19, 2019
d31df5f
Rebased
eduardo-elizondo Jan 19, 2019
c84689c
Ran argument clinic
eduardo-elizondo Jan 19, 2019
796a8d7
Added NEWS
eduardo-elizondo Jan 19, 2019
b7cae5b
Remove INCREF from GenericAlloc
eduardo-elizondo Jan 19, 2019
5fa6e46
Make Posixmodule use PyType_FromSpec
eduardo-elizondo Dec 3, 2018
df178b4
Added NEWS
eduardo-elizondo Dec 3, 2018
e59208f
Updated hash
eduardo-elizondo Dec 3, 2018
def6467
Addressed PR Issues
eduardo-elizondo Jan 19, 2019
bb2ead8
Ran argument clinic
eduardo-elizondo Jan 19, 2019
427c772
Added NEWS
eduardo-elizondo Jan 19, 2019
7b9b85f
Merged to master
eduardo-elizondo Sep 11, 2019
9e8fb83
Merge branch 'master' into posixmodule-fromspec
eduardo-elizondo Sep 11, 2019
99d5c26
Cleaned up slot acces
eduardo-elizondo Sep 11, 2019
ca19f51
Cleaned up more slot accesses
eduardo-elizondo Sep 11, 2019
8af0c4e
Nits
eduardo-elizondo Sep 11, 2019
cee2cd9
Fixes
eduardo-elizondo Sep 11, 2019
a8d2f56
Run clinic
eduardo-elizondo Sep 11, 2019
5e4d2ab
Run clinic
eduardo-elizondo Sep 11, 2019
c42ec45
Improve error handling
encukou Sep 11, 2019
d27a547
Remove static from posixmodule.c
eduardo-elizondo Sep 12, 2019
6af98a9
Merge branch 'posixmodule-fromspec' of https://github.com/eduardo-eli…
eduardo-elizondo Sep 12, 2019
a723d1c
Address Comments
eduardo-elizondo Sep 12, 2019
e91096a
Address Comments
eduardo-elizondo Sep 12, 2019
3cf259e
Fix Windows build
eduardo-elizondo Sep 12, 2019
925a41e
Use interned strings for constants in module state
encukou Sep 13, 2019
ad7359b
Use descriptor directly, rather than look it up by name
encukou Sep 13, 2019
5de545d
Bring _Py_IDENTIFIER(__fspath__) back
encukou Sep 13, 2019
3ada298
Use the tp_free slot directly
encukou Sep 13, 2019
4c80b06
Remove duplicate function
encukou Sep 13, 2019
6e505ac
Use tp_new directly
encukou Sep 13, 2019
b9a49aa
Don't call PyState_AddModule
encukou Sep 13, 2019
c1a6d03
Add __new__ changes
eduardo-elizondo Sep 17, 2019
bbe887f
Merge branch 'master' into posixmodule-fromspec
eduardo-elizondo Sep 17, 2019
4a6d4ec
Regenerate clinic
eduardo-elizondo Sep 18, 2019
138ffb6
Nits
eduardo-elizondo Sep 23, 2019
78fbed3
Merge to master
eduardo-elizondo Nov 3, 2019
1b57f3a
Revert tp_new changes
eduardo-elizondo Nov 3, 2019
e7e9634
Rerun argument clinit
eduardo-elizondo Nov 3, 2019
3bf99bf
More fixes
eduardo-elizondo Nov 3, 2019
afb249c
Re-add newlines and fix docstring for os.sched_param.__new__
encukou Nov 5, 2019
187b5d4
Code style nitpicks
encukou Nov 5, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Lib/test/test_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -3638,6 +3638,24 @@ def test_os_all(self):
self.assertIn('walk', os.__all__)


class TestDirEntry(unittest.TestCase):
def setUp(self):
self.path = os.path.realpath(support.TESTFN)
self.addCleanup(support.rmtree, self.path)
os.mkdir(self.path)

def test_uninstantiable(self):
self.assertRaises(TypeError, os.DirEntry)

def test_unpickable(self):
filename = create_file(os.path.join(self.path, "file.txt"), b'python')
entry = [entry for entry in os.scandir(self.path)].pop()
self.assertIsInstance(entry, os.DirEntry)
self.assertEqual(entry.name, "file.txt")
import pickle
self.assertRaises(TypeError, pickle.dumps, entry, filename)


class TestScandir(unittest.TestCase):
check_no_resource_warning = support.check_no_resource_warning

Expand Down Expand Up @@ -3672,6 +3690,18 @@ def assert_stat_equal(self, stat1, stat2, skip_fields):
else:
self.assertEqual(stat1, stat2)

def test_uninstantiable(self):
scandir_iter = os.scandir(self.path)
self.assertRaises(TypeError, type(scandir_iter))
scandir_iter.close()

def test_unpickable(self):
filename = self.create_file("file.txt")
scandir_iter = os.scandir(self.path)
import pickle
self.assertRaises(TypeError, pickle.dumps, scandir_iter, filename)
scandir_iter.close()

def check_entry(self, entry, name, is_dir, is_file, is_symlink):
self.assertIsInstance(entry, os.DirEntry)
self.assertEqual(entry.name, name)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Convert posixmodule.c statically allocated types ``DirEntryType`` and
``ScandirIteratorType`` to heap-allocated types.
4 changes: 2 additions & 2 deletions Modules/clinic/posixmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading