RustPython icon indicating copy to clipboard operation
RustPython copied to clipboard

locale support including _locale and time.tzname

Open youknowone opened this issue 2 years ago • 4 comments

  • [ ] _locale module
  • [ ] time.tzname

youknowone avatar Jul 08 '22 16:07 youknowone

https://docs.python.org/3/library/time.html#time.tzname

The doc says tzname is determined at module load time. Does "module load time" mean those values to be initialized in the function below?

https://github.com/RustPython/RustPython/blob/77b821a1941019fe34f73ce17cea013ae1b98fd0/vm/src/stdlib/time.rs#L9-L17

bonjune avatar Nov 02 '22 13:11 bonjune

#4054

If we are talking about holding states such as tzname (which is initialized at module load time), this can be related.

bonjune avatar Nov 02 '22 13:11 bonjune

The doc says tzname is determined at module load time. Does "module load time" mean those values to be initialized in the function below?

It may not be exactly, but you can regard it is.

youknowone avatar Nov 05 '22 12:11 youknowone

And yes. #4054 is generally related to module attributes and hidden data like Info types in sys module.

youknowone avatar Nov 05 '22 12:11 youknowone

Noticed quite a few functions in CPython Locale are not implemented in locale.rs. I don't have much experience with this type of work but would the general idea be to write a wrapper for say: GetLocaleIInfoA since it is used throughout CPython's implementation of getdefaultlocale so it can be used in our implementation?

JazzGlobal avatar Apr 18 '23 08:04 JazzGlobal

You are on Windows right? I haven't looked into how CPython does it (am out atm) but if this is calling some os provided function then yes, we typically wrap it and call into it after converting the args.

The function to be wrapped should be in windows.rs?

DimitrisJim avatar Apr 18 '23 11:04 DimitrisJim

That's right, and gotcha. Looks like libc has bindings for setlocale but that's all im seeing

EDIT: Not all obviously, but no binding for getlocale .

JazzGlobal avatar Apr 18 '23 13:04 JazzGlobal