This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2015年03月23日 09:30 by pythonhacker, last changed 2022年04月11日 14:58 by admin.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 31462 | open | slateny, 2022年02月21日 08:30 | |
| Messages (5) | |||
|---|---|---|---|
| msg238995 - (view) | Author: Anand B Pillai (pythonhacker) * | Date: 2015年03月23日 09:30 | |
>>> import platform
>>> platform.system()
'Linux'
>>> platform.win32_ver()
('', '', '', '')
Why is this function even exposed on Linux ? It should be conditionally exposed only on win32 platforms.
Funny that this is coming from the module named "platform" itself :)
|
|||
| msg238996 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2015年03月23日 09:33 | |
> Why is this function even exposed on Linux? It is a deliberate design choice of the platform module. mac_ver(), win32_ver() and linux_distribution() are available on all platforms. mac_ver() says "entries which cannot be determined are set to ''. All tuple entries are strings." Maybe it should be better explained in the doc. |
|||
| msg238997 - (view) | Author: Anand B Pillai (pythonhacker) * | Date: 2015年03月23日 09:36 | |
Similarly for mac_ver, java_ver etc.
>>> platform.mac_ver()
('', ('', '', ''), '')
>>> platform.java_ver()
('', '', ('', '', ''), ('', '', ''))
Maybe it is okay if these functions are present, but can't they raise an exception or return None instead of returning these funny tuples when empty strings ?
I am surprised at Python's inconsistency in such things. For example,
>>> import winsound
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'winsound'
Works as expected on Linux. In the same vein, these functions shouldn't be present as well IMHO - I agree this is debatable of course.
|
|||
| msg239001 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2015年03月23日 09:50 | |
> Maybe it is okay if these functions are present, but can't they raise an exception or return None instead of returning these funny tuples when empty strings ? It would break the backward compatibility. Again, it's a delibarate choice. |
|||
| msg239126 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2015年03月24日 14:26 | |
It is a deliberate choice because the functions accept default values to be returned if the actual values cannot be determined, and because it is easier therefore to write cross-platform scripts if the functions do *not* raise an error when called on the "wrong" platform. There are other functions in the platform module to use to determine which platform you are on. Agreed that the fact that they work is currently documented only by implication for those familiar with our doc style (that is, there are no "avaiability" tags, implying they are available on all platforms). This should be corrected, probably in an introductory paragraph (which will be overlooked by most people reading the docs :) |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:14 | admin | set | github: 67935 |
| 2022年02月21日 08:30:09 | slateny | set | keywords:
+ patch nosy: + slateny pull_requests: + pull_request29591 stage: needs patch -> patch review |
| 2021年12月13日 17:40:54 | iritkatriel | set | keywords:
+ easy title: platform module exposes win32_ver function on posix systems -> [doc] platform module exposes win32_ver function on posix systems versions: + Python 3.9, Python 3.10, Python 3.11, - Python 2.7, Python 3.4, Python 3.5 |
| 2015年03月24日 14:26:34 | r.david.murray | set | messages: - msg239124 |
| 2015年03月24日 14:26:24 | r.david.murray | set | messages:
+ msg239126 stage: needs patch |
| 2015年03月24日 14:18:06 | r.david.murray | set | nosy:
+ r.david.murray messages: + msg239124 |
| 2015年03月23日 09:50:54 | vstinner | set | messages: + msg239001 |
| 2015年03月23日 09:36:00 | pythonhacker | set | messages: + msg238997 |
| 2015年03月23日 09:33:45 | vstinner | set | versions:
+ Python 2.7, Python 3.4, Python 3.5 nosy: + docs@python, vstinner messages: + msg238996 assignee: docs@python components: + Documentation |
| 2015年03月23日 09:30:16 | pythonhacker | create | |