Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

bpo-40549: Convert posixmodule.c to multiphase init #19982

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 2 commits into from
May 10, 2020
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Fix Windows implementation
  • Loading branch information
vstinner committed May 7, 2020
commit a2d444b1541c4f5e0795a1905a2f13c3c34cfa15
10 changes: 6 additions & 4 deletions 10 Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -12824,7 +12824,8 @@ DirEntry_get_lstat(DirEntry *self)
{
if (!self->lstat) {
#ifdef MS_WINDOWS
self->lstat = _pystat_fromstructstat(&self->win32_lstat);
self->lstat = _pystat_fromstructstat(DirEntry_get_module(self),
&self->win32_lstat);
#else /* POSIX */
self->lstat = DirEntry_fetch_stat(self, 0);
#endif
Expand Down Expand Up @@ -13114,7 +13115,6 @@ DirEntry_from_find_data(PyObject *module, path_t *path, WIN32_FIND_DATAW *dataW)
entry = PyObject_New(DirEntry, (PyTypeObject *)DirEntryType);
if (!entry)
return NULL;
entry->module = module;
entry->name = NULL;
entry->path = NULL;
entry->stat = NULL;
Expand Down Expand Up @@ -13319,8 +13319,10 @@ ScandirIterator_iternext(ScandirIterator *iterator)

/* Skip over . and .. */
if (wcscmp(file_data->cFileName, L".") != 0 &&
wcscmp(file_data->cFileName, L"..") != 0) {
entry = DirEntry_from_find_data(iterator->module, &iterator->path, file_data);
wcscmp(file_data->cFileName, L"..") != 0)
{
PyObject *module = PyType_GetModule(Py_TYPE(iterator));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also only works because the iterator type is not subclassable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, You are right. I use pep573 in functools. I got some error from test cases.

Something like:

ERROR: test_arg_combinations (test.test_functools.TestPartialCSubclass)

Traceback (most recent call last):
File "/temp/shihai/cpython/Lib/test/test_functools.py", line 109, in test_arg_combinations
p = self.partial(capture)
TypeError: PyType_GetModule: Type 'CPartialSubclass' has no associated module

#20055

entry = DirEntry_from_find_data(module, &iterator->path, file_data);
if (!entry)
break;
return entry;
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.