◐ Shell
reader mode source ↗
Skip to content

Feat: locale-module#4081

Closed
Yaminyam wants to merge 7 commits into
RustPython:mainfrom
Yaminyam:feature/module-locale
Closed

Feat: locale-module#4081
Yaminyam wants to merge 7 commits into
RustPython:mainfrom
Yaminyam:feature/module-locale

Conversation

@Yaminyam

Copy link
Copy Markdown
Contributor

No description provided.

@Yaminyam Yaminyam marked this pull request as draft August 16, 2022 05:33
Yaminyam and others added 4 commits August 16, 2022 16:09
Co-authored-by: Jeong YunWon <69878+youknowone@users.noreply.github.com>
@youknowone youknowone added the z-ca-2022 Tag to track contrubution-academy 2022 label Aug 16, 2022
@fanninpm

Copy link
Copy Markdown
Contributor

I don't think this particular module belongs in the stdlib crate:

>>> import _locale
>>> _locale.__file__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module '_locale' has no attribute '__file__'. Did you mean: '__name__'?

I think it should belong in the vm crate instead. What do you think, @youknowone?

@youknowone

Copy link
Copy Markdown
Member

@fanninpm Interesting. Does __file__ attribute existence different by it is builtin or not?

I usually check sys.builtin_module_names

>>> import sys
>>> sys.builtin_module_names
('_abc', '_ast', '_codecs', '_collections', '_functools', '_imp', '_io', '_locale', '_operator', '_signal', '_sre', '_stat', '_string', '_symtable', '_thread', '_tracemalloc', '_warnings', '_weakref', 'atexit', 'builtins', 'errno', 'faulthandler', 'gc', 'itertools', 'marshal', 'posix', 'pwd', 'sys', 'time', 'xxsubtype')
>>> '_locale' in sys.builtin_module_names
True

Yes, so this belongs in vm crate.

@fanninpm

Copy link
Copy Markdown
Contributor

Does __file__ attribute existence different by it is builtin or not?

Let's see:

>>> import argparse # pure-python module
>>> argparse.__file__
'/usr/lib/python3.10/argparse.py'
>>> import mmap # dynamically-linked c module
>>> mmap.__file__
'/usr/lib/python3.10/lib-dynload/mmap.cpython-310-x86_64-linux-gnu.so'
>>> import gc # statically-linked c module
>>> gc.__file__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'gc' has no attribute '__file__'. Did you mean: '__name__'?

The Python docs say that the __file__ attribute is

The pathname of the file from which the module was loaded, if it was loaded from a file. The __file__ attribute may be missing for certain types of modules, such as C modules that are statically linked into the interpreter. For extension modules loaded dynamically from a shared library, it’s the pathname of the shared library file.

@youknowone

Copy link
Copy Markdown
Member

Thanks! I didn't know that.

@youknowone

Copy link
Copy Markdown
Member

Thank you for contributing. This is not implemented by #4558

@youknowone youknowone closed this Mar 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

z-ca-2022 Tag to track contrubution-academy 2022

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants