Skip to content
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

getdefaultlocale() deprecated in Python 3.11 #2538

Closed
pesekon2 opened this issue Aug 27, 2022 · 5 comments · Fixed by #2550
Closed

getdefaultlocale() deprecated in Python 3.11 #2538

pesekon2 opened this issue Aug 27, 2022 · 5 comments · Fixed by #2550
Assignees
Labels
good first issue Good for newcomers Python Related code is in Python
Milestone

Comments

@pesekon2
Copy link
Contributor

Describe the bug

Initializing GRASS with Python 3.11, I am getting the following warning messages:

/grass/bin.x86_64-pc-linux-gnu/grass:69: DeprecationWarning: Use setlocale(), getencoding() and getlocale() instead
  ENCODING = locale.getdefaultlocale()[1]
/grass/bin.x86_64-pc-linux-gnu/grass:1421: DeprecationWarning: Use setlocale(), getencoding() and getlocale() instead
  language, encoding = locale.getdefaultlocale()

Not annoying so much, but it could cause us some problems once the function will be fully removed from locale.

Possible solution

Change to getlocale(). Will dive deeper to find out if it can cause some problems.

@pesekon2 pesekon2 added good first issue Good for newcomers Python Related code is in Python labels Aug 27, 2022
@pesekon2 pesekon2 changed the title [Bug] getdefaultlocale() deprecated in Python 3.11 getdefaultlocale() deprecated in Python 3.11 Aug 27, 2022
@pesekon2
Copy link
Contributor Author

See a discussion touching this topic here

@neteler
Copy link
Member

neteler commented Sep 14, 2022

This is meanwhile a blocker in Fedora 37:
https://bugzilla.redhat.com/show_bug.cgi?id=2126608

@pesekon2
Copy link
Contributor Author

The blocker is actually connected to another issue, #2507.

But both of them are caused by Python 3.11, so they are related.

Theoretically, PR #2550 linked to this shouldn't really cause a problem in Windows. Hence, as this is a blocker (not only for Fedora, it is a blocker for anything with Python 3.11), it might be easier to accept the fixes (#2550 and #2539) and then see if somebody reports any issue on Windows?

@neteler
Copy link
Member

neteler commented Sep 17, 2022

it might be easier to accept the fixes (#2550 and #2539) and then see if somebody reports any issue on Windows?

Yes, I agree. Will you merge it?

pesekon2 added a commit that referenced this issue Sep 17, 2022
* fix #2538
* Use getencoding() where only encoding is needed; getlocale() otherwise
@pesekon2
Copy link
Contributor Author

Will you merge it?

Done. Python 3.11-connected issues should be solved by #2550 and #2539

ninsbl pushed a commit to ninsbl/grass that referenced this issue Oct 26, 2022
* fix OSGeo#2538
* Use getencoding() where only encoding is needed; getlocale() otherwise
pesekon2 added a commit that referenced this issue Dec 2, 2022
* fix #2538
* Use getencoding() where only encoding is needed; getlocale() otherwise
ninsbl pushed a commit to ninsbl/grass that referenced this issue Feb 17, 2023
* fix OSGeo#2538
* Use getencoding() where only encoding is needed; getlocale() otherwise
neteler pushed a commit that referenced this issue May 29, 2023
Backport of #2550 to G78, fixing Python 3.11 error after deprecation.

* fix #2538
* Use getencoding() where only encoding is needed; getlocale() otherwise

Additional changes:
- sync of `tools/mkhtml.py` with `main` branch
- selected backport from #2140 to get `utils/generate_last_commit_file.py`
- selective sync of `lib/init/grass.py`
marisn pushed a commit to marisn/grass that referenced this issue Jun 2, 2023
* fix OSGeo#2538
* Use getencoding() where only encoding is needed; getlocale() otherwise
neteler pushed a commit to nilason/grass that referenced this issue Nov 7, 2023
* fix OSGeo#2538
* Use getencoding() where only encoding is needed; getlocale() otherwise
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers Python Related code is in Python
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants