[issue42002] Clean up initialization of the sys module

2020-10-11 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42002] Clean up initialization of the sys module

2020-10-11 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset fa1d83db62a545580d9a1a585b2c1fb55961a5c3 by Serhiy Storchaka in 
branch 'master':
bpo-42002: Clean up initialization of the sys module. (GH-22642)
https://github.com/python/cpython/commit/fa1d83db62a545580d9a1a585b2c1fb55961a5c3


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42002] Clean up initialization of the sys module

2020-10-10 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
keywords: +patch
pull_requests: +21616
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/22642

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42002] Clean up initialization of the sys module

2020-10-10 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +vstinner

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42002] Clean up initialization of the sys module

2020-10-10 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

_PySys_InitCore() and _PySys_InitMain() in Python/sysmodule.c contains many 
invocations of macros for setting attributes of the sys module. The proposed PR 
changes these macros.

1. SET_SYS_FROM_STRING was renamed to just SET_SYS. It is much shorter and 
allow to write many invocations in one line. Also SET_SYS_FROM_STRING was not 
consistent with SET_SYS_FROM_WSTR.

2. Added new SET_SYS_FROM_STRING which sets attribute specified as C char 
string (similarly to SET_SYS_FROM_WSTR which sets attribute specified as C 
wchar_t string).

3. Added COPY_SYS_ATTR for making a copy of the attribute. It uses 
PyMapping_GetItemString() instead of PyDict_GetItemString() which silences all 
expressions.

4. Removed SET_SYS_FROM_STRING_BORROW. It no longer used, and it was used 
improperly.

5. SET_SYS_FROM_STRING_INT_RESULT replaced with SET_SYS.

6. All macros have been rewritten in term of SET_SYS that significantly 
simplifies the code.

All this makes the code clearer and makes errors handling more correct.

--
components: Interpreter Core
messages: 378415
nosy: serhiy.storchaka
priority: normal
severity: normal
status: open
title: Clean up initialization of the sys module
versions: Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com