msg174634 - (view) |
Author: anatoly techtonik (techtonik) |
Date: 2012-11-03 15:22 |
>>> import ctypes.wintypes
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.2/ctypes/wintypes.py", line 20, in <module>
class VARIANT_BOOL(ctypes._SimpleCData):
ValueError: _type_ 'v' not supported
>>>
Shouldn't it just import silently without failing? Or if it's destined to fail, explain how to make a cross-platform import?
|
msg174635 - (view) |
Author: anatoly techtonik (techtonik) |
Date: 2012-11-03 15:24 |
Perhaps the patch already there - see http://www.themacaque.com/?p=826
|
msg188245 - (view) |
Author: Dmi Baranov (dmi.baranov) * |
Date: 2013-05-01 22:16 |
Found only this "patch" [1] :) I think is possible to change VARIANT_BOOL._type_ to any of short types [2] for non-"nt" platforms?
[1] https://code.launchpad.net/~mandel/python-distutils-extra/import_issues/+merge/53519
[2] http://msdn.microsoft.com/en-us/library/cc237864.aspx
|
msg188707 - (view) |
Author: Ezio Melotti (ezio.melotti) *  |
Date: 2013-05-08 08:05 |
That patch is more a workaround than an actual fix. Lib/ctypes/wintypes.py should either fail with an ImportError or be importable. For the former it's possible to catch the ValueError and turn it into an ImportError, or perhaps raise it if some precondition is missing; for the latter, either the creation of that signle class is skipped if _type_ 'v' is not supported, or a way to define it that works on other platforms too should be found instead.
|
msg191756 - (view) |
Author: Christian Heimes (christian.heimes) *  |
Date: 2013-06-24 12:17 |
The fix is trivial:
- define VARIANT_FALSE and VARIANT_BOOL according to specs
- enable 'v' on non-Windows systems
- enable tests for vbool
Done
|
msg191763 - (view) |
Author: Jason R. Coombs (jaraco) *  |
Date: 2013-06-24 13:56 |
Looks good to me. Ben, any objections to applying this to 2.7?
|
msg192324 - (view) |
Author: Christian Heimes (christian.heimes) *  |
Date: 2013-07-04 23:48 |
RM, please decide. :)
|
msg194927 - (view) |
Author: Benjamin Peterson (benjamin.peterson) *  |
Date: 2013-08-12 05:50 |
Smells like a new feature to me.
|
msg194948 - (view) |
Author: Ezio Melotti (ezio.melotti) *  |
Date: 2013-08-12 12:11 |
Even if the patch is applied only on 3.4, I would still like to see the ValueError turned into ImportError for 2.7/3.3.
|
msg194985 - (view) |
Author: Jason R. Coombs (jaraco) *  |
Date: 2013-08-12 18:58 |
My sense on the issue is that wintypes was added to the library and was never intended to raise a ValueError on import. By that logic, the behavior is a bug, not a new feature. I agree with Ezio that raising a ValueError on import is a bug. And since the patch not only addresses the ValueError on import, but simply addresses the underlying cause, it seems to me the most obvious solution.
|
msg195652 - (view) |
Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) *  |
Date: 2013-08-19 17:48 |
I think it's the opposite: when Unix support was added to ctypes, 'import ctypes.wintypes' was not considered. By that logic, the patch is a new feature.
IMO "historical" arguments are moot :-)
I agree with the conclusion tough: the patch will not break code that carefully catches ValueError, and so it suitable for 2.7.
|
msg195675 - (view) |
Author: Meador Inge (meador.inge) *  |
Date: 2013-08-20 01:42 |
On Mon, Aug 12, 2013 at 7:11 AM, Ezio Melotti <report@bugs.python.org>wrote:
> Even if the patch is applied only on 3.4, I would still like to see the
> ValueError turned into ImportError for 2.7/3.3.
>
Why not raise an ImportError for all versions? I don't see how
'ctypes.wintypes' is ever actually useful on anything but Windows.
Allowing it to successfully import on non-Windows systems seems misleading.
|
msg195825 - (view) |
Author: Benjamin Peterson (benjamin.peterson) *  |
Date: 2013-08-21 21:36 |
We can argue about whether it's a bugfix or not. But I don't see how having this patch in 2.7 helps anyone, since ctypes.wintypes is useless on non-Windows platforms.
|
msg195924 - (view) |
Author: Jason R. Coombs (jaraco) *  |
Date: 2013-08-22 21:39 |
The first thing it helps is that it eliminates a ValueError on import. Without it, code must catch both ValueError and ImportError to run portably:
import ctypes
try:
import ctypes.wintypes
except ImportError, ValueError:
# catch ImportError and ValueError due to issue16396
pass
...
def code_that_runs_only_on_win():
ctypes.wintypes.foo
One _could_ cause ctypes.wintypes to always raise an ImportError on non-Windows systems, allowing the import routine to be simpler:
try:
import ctypes.wintypes
except ImportError:
pass
But it would be even nicer if ctypes.wintypes always imported on any platform, such that the statement could be simply:
import ctypes.wintypes
But it's conceivable that certain functionality in wintypes might be useful on other systems. Consider, for example, a routine that works with pickles produced on a Windows system, or simply a comparison of some object in ctypes.wintypes against a value produced on a Windows system.
The argument for that need (esp. on Python 2.7) is not strong, but since the patch to address the ValueError is simple, straightforward, and perhaps even simpler than something that would address the ValueError specifically, it seems worthwhile to accept the patch.
|
msg195926 - (view) |
Author: Meador Inge (meador.inge) *  |
Date: 2013-08-22 21:54 |
Using 'ctypes.wintypes' on non-Windows systems is most likely a bad idea. Most of the types are defined in terms of the types for the target that the interpreter is built for. Comparing serializations thereof in a cross platform manner doesn't make sense for a lot of cases.
I really think it is only useful for Windows platforms and allowing it to silently import is misleading.
|
msg195940 - (view) |
Author: Benjamin Peterson (benjamin.peterson) *  |
Date: 2013-08-23 04:24 |
This is not a regression, though, so most people wouldn't be able to simplify their code because they have to support older Python versions.
|
msg284191 - (view) |
Author: Mike Place (Mike Place) |
Date: 2016-12-28 18:41 |
+1 to getting this patch in. The fact that this raises a ValueError and not an ImportError is really annoying and we definitely see it as a bug.
|
msg379033 - (view) |
Author: Steve Dower (steve.dower) *  |
Date: 2020-10-19 22:06 |
New changeset 5456e78f4593edc277ab72fb9a9db1ebae7d4c2d by Jason R. Coombs in branch 'master':
bpo-16396: Allow wintypes to be imported on non-Windows systems. (GH-21394)
https://github.com/python/cpython/commit/5456e78f4593edc277ab72fb9a9db1ebae7d4c2d
|
msg379042 - (view) |
Author: miss-islington (miss-islington) |
Date: 2020-10-19 22:29 |
New changeset 6e998fad1c92aee9c8c23c5887a7023d76bdf6c2 by Miss Skeleton (bot) in branch '3.8':
bpo-16396: Allow wintypes to be imported on non-Windows systems. (GH-21394)
https://github.com/python/cpython/commit/6e998fad1c92aee9c8c23c5887a7023d76bdf6c2
|
msg379047 - (view) |
Author: miss-islington (miss-islington) |
Date: 2020-10-19 22:32 |
New changeset 05d52a0ad69cbadd4b048f2a97991e4e58d4a922 by Miss Skeleton (bot) in branch '3.9':
bpo-16396: Allow wintypes to be imported on non-Windows systems. (GH-21394)
https://github.com/python/cpython/commit/05d52a0ad69cbadd4b048f2a97991e4e58d4a922
|
msg383808 - (view) |
Author: miss-islington (miss-islington) |
Date: 2020-12-26 15:37 |
New changeset 7865f516f313bd31ca48ee1fdae2a80add2293b6 by Shantanu in branch 'master':
bpo-16396: fix BPO number in changelog (GH-23951)
https://github.com/python/cpython/commit/7865f516f313bd31ca48ee1fdae2a80add2293b6
|
msg383983 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2020-12-29 11:52 |
New changeset 71d73900ebd4a93a64dae9d2fbef4337fa975e66 by Miss Islington (bot) in branch '3.9':
bpo-16396: fix BPO number in changelog (GH-23951) (GH-23956)
https://github.com/python/cpython/commit/71d73900ebd4a93a64dae9d2fbef4337fa975e66
|
|
Date |
User |
Action |
Args |
2022-04-11 14:57:38 | admin | set | github: 60600 |
2020-12-29 11:52:15 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka messages:
+ msg383983
|
2020-12-26 15:37:24 | miss-islington | set | messages:
+ msg383808 |
2020-12-26 15:37:17 | miss-islington | set | pull_requests:
+ pull_request22803 |
2020-12-26 06:03:28 | hauntsaninja | set | nosy:
+ hauntsaninja
pull_requests:
+ pull_request22798 |
2020-10-19 22:32:43 | miss-islington | set | messages:
+ msg379047 |
2020-10-19 22:29:40 | miss-islington | set | messages:
+ msg379042 |
2020-10-19 22:07:07 | steve.dower | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
2020-10-19 22:06:37 | miss-islington | set | pull_requests:
+ pull_request21747 |
2020-10-19 22:06:28 | miss-islington | set | nosy:
+ miss-islington pull_requests:
+ pull_request21746
|
2020-10-19 22:06:12 | steve.dower | set | nosy:
+ steve.dower messages:
+ msg379033
|
2020-07-08 13:43:57 | jaraco | set | pull_requests:
+ pull_request20542 |
2020-07-07 21:42:21 | jaraco | set | versions:
+ Python 3.8, Python 3.9, Python 3.10, - Python 2.7, Python 3.3, Python 3.4 |
2017-01-01 18:15:16 | ppperry | set | title: Importing ctypes.wintypes on Linux gives a traceback -> Importing ctypes.wintypes on Linux gives a ValueError instead of an ImportError |
2016-12-28 18:41:07 | Mike Place | set | nosy:
+ Mike Place messages:
+ msg284191
|
2013-08-23 04:24:01 | benjamin.peterson | set | messages:
+ msg195940 |
2013-08-22 21:54:45 | meador.inge | set | messages:
+ msg195926 |
2013-08-22 21:39:03 | jaraco | set | messages:
+ msg195924 |
2013-08-21 21:36:07 | benjamin.peterson | set | messages:
+ msg195825 |
2013-08-20 01:42:30 | meador.inge | set | messages:
+ msg195675 |
2013-08-19 17:48:54 | amaury.forgeotdarc | set | messages:
+ msg195652 |
2013-08-12 18:58:20 | jaraco | set | messages:
+ msg194985 |
2013-08-12 12:11:20 | ezio.melotti | set | messages:
+ msg194948 |
2013-08-12 05:50:01 | benjamin.peterson | set | messages:
+ msg194927 |
2013-07-04 23:48:47 | christian.heimes | set | assignee: benjamin.peterson messages:
+ msg192324 stage: needs patch -> patch review |
2013-06-24 13:56:57 | jaraco | set | nosy:
+ benjamin.peterson messages:
+ msg191763
|
2013-06-24 12:17:08 | christian.heimes | set | files:
+ 16396_vbool.patch
nosy:
+ christian.heimes messages:
+ msg191756
keywords:
+ patch |
2013-06-24 08:32:53 | jaraco | set | nosy:
+ jaraco
|
2013-05-08 08:05:48 | ezio.melotti | set | messages:
+ msg188707 |
2013-05-01 22:16:42 | dmi.baranov | set | nosy:
+ dmi.baranov messages:
+ msg188245
|
2013-05-01 12:23:50 | ezio.melotti | set | nosy:
+ ezio.melotti stage: needs patch type: behavior
versions:
+ Python 3.4, - Python 3.2 |
2012-11-11 17:20:18 | terry.reedy | set | nosy:
+ amaury.forgeotdarc, belopolsky, meador.inge
versions:
- Python 3.1 |
2012-11-03 15:24:30 | techtonik | set | messages:
+ msg174635 |
2012-11-03 15:22:51 | techtonik | create | |