wximage::getwidth(): invalid image

I’m trying to load a known good PNG file with a very strange, but legal MSW file name as both a wx.Bitmap and an wx.Image with this result:

Windows 6.1.7601
Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)]
Wx Version 2.8.11.0
Wx Pltform (‘WXMSW’, ‘wxMSW’, ‘unicode’, ‘wx-assertions-on’, ‘SWIG-1.3.29’)

$$$$ type( imgFilename ) = <type ‘str’>
$$$$ imgFilename = [ !@#$^&()_+.PNG ]
$$$$ wxBmap.GetSize() (0, 0)
$$$$ wxImage.GetSize()

EXCEPTION: PyAssertionError: C++ assertion “ok()” failed at …\src\co

mmon\image.cpp(1454) in wximage::getwidth(): invalid image

---- Statement return core.Image_GetSize(*args, **kwargs)
Line # 3047
Function GetSize
File _core.py
File Path C:\PROGRA~1\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\

---- Statement print '$$$$ wxImage.GetSize() ', wxImage.GetSize()
Line # 51
Function
File try.PY
File Path \

It fails the same way on Wx Version 2.8.12.0
Is this a known bug ?

Thanks,
Ray Pasco

TRY.py (1.26 KB)

!@#$%^&()_+.PNG

Ray Pasco wrote:

  I'm trying to load a known good PNG file with a very

strange, but legal MSW file name as both a wx.Bitmap and an
wx.Image with this result:

  Windows   6.1.7601

  Python    2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32

bit (Intel)]

  Wx Version 2.8.11.0

  Wx Pltform ('__WXMSW__', 'wxMSW', 'unicode', 'wx-assertions-on',

‘SWIG-1.3.29’)

  $$$$  type( imgFilename ) = <type 'str'>

  $$$$  imgFilename         = [ !@#$^&()_+.PNG ]

  $$$$  wxBmap.GetSize()  (0, 0)

  $$$$  wxImage.GetSize()
Works for me in 2.8.10:

`C:\tmp>python

    Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32

bit (Intel)] on win32

    Type "help", "copyright", "credits" or "license" for more

information.

    >>> wx.__version__

    '2.8.10.1'

    >>> import wx

    >>> a = wx.App(0)

    >>> z =

wx.Bitmap(,wx.BITMAP_TYPE_PNG)

z.GetSize()
wx.Size(32, 32)
y =
wx.Image(,wx.BITMAP_TYPE_PNG)
y.GetSize()
wx.Size(32, 32)
`
Are you sure the image file exists in the directory you’re
expecting? Remember that you cannot use that file name in a command
line without quoting it. The ^ and & characters have special
meaning to the Windows shell. For example, if you did this:

    rename file1.png  !@#$%^&()_+.PNG

The ^ character would be eaten as escaping the & and would not

appear:

···

“!@#$%^&()_+.PNG”

“!@#$%^&()_+.PNG”

-- Tim Roberts, Providenza & Boekelheide, Inc.

timr@probo.com

> Tim Roberts, timr@probo.com
> Providenza & Boekelheide, Inc.
...

Works for me in 2.8.10:
The MSW .CMD file script interpreter takes it upon itself to double any caret characters [ ^ ] it finds in a filename, even when the filename is double-quoted !
How very sad…

I’ve never tried using filenames with carets before this. Quoting all the other special characters, [ ()@ ], excluding [ % ], keeps them intact.

Also, my PC has been updated with fifty-six (56) MSW hotfixes in the last 12 days. I’m sure every one of them has been 100% tested…

Thanks for your help,
Ray

Just an off hand question, why would such a strange file name be used? Is there some special cases where it is useful?

···


Hi, I will kill all ads in google gmail.
They will all be dead and gone for all my emails to you. HA HA bye bye ads I just massacred you!!!

I’m storing data from files which can be retrieved by its OS filename. Functions are automatically created to retrieve the data by creating valid Python identifier hashes. I’m testing the name hashing function with a filename which has all the OS-legal characters (in MSW, anyway) that are also Python-illegal.

I want to preserve all the legal Python identifier characters, so a typical hash function can’t be used.

It seems to me this kind translation function should have been created in the very early days of Python and would have to be cross-platform, too. I just don’t happen to know of one.

Ray

This is a non-wx question, so you might want to try another list, but anyway:

I'm confused about what you are trying to do --why hash the filename, why not just store it as is?

what is a "valid Python identifier hash"?

If you use unicode, all OS-legal characters are python-legal.

In short, perhaps a bit more explanation will clarify your question for me/us.

-Chris

···

On 4/27/11 10:27 AM, Ray Pasco wrote:

I'm storing data from files which can be retrieved by its OS filename.
Functions are automatically created to retrieve the data by creating
valid Python identifier hashes. I'm testing the name hashing function
with a filename which has all the OS-legal characters (in MSW, anyway)
that are also Python-illegal.

I want to preserve all the legal Python identifier characters, so a
typical hash function can't be used.

It seems to me this kind translation function should have been created
in the very early days of Python and would have to be cross-platform,
too. I just don't happen to know of one.

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Ray Pasco wrote:

> Works for me in 2.8.10:

The MSW .CMD file script interpreter takes it upon itself to double
any caret characters [ ^ ] it finds in a filename, even when the
filename is double-quoted ! How very sad...

That's simply not true. The interpreter does not double ANY
characters. For reasons that are beyond human comprehension, Microsoft
chose caret [ ^ ] as their escape character instead of backslash. You
have exactly the same problems with ^ in Windows that you do with
backslash in Unix. If you want caret in a file name, you either have to
double it, or you have to wrap the name in quotes. One or the other.

If you show an example of what led you to make that statement, I can
provide an explanation.

I've never tried using filenames with carets before this. Quoting all
the other special characters, [ ()@ ], excluding [ % ], keeps them intact.

It's not necessary to quote those characters. They have no special
meaning. There are exactly 5 characters that need quoting: & ^ < > ;

Also, my PC has been updated with fifty-six (56) MSW hotfixes in the
last 12 days. I'm sure every one of them has been 100% tested...

That's common if you have a new installation. If you install XP SP3
today, you'll get upwards of 100 updates over a period of days. That's
not surprising for a system that was released 3 years ago. If you
installed a new RHEL 5.0 install today, you'd have exactly the same
situation.

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

I can attest to what Tim’s talking about regarding updates. If you don’t want to deal with all the updates, then you’ll need some patching software. There are several enterprise ones out there (like Shavlik or BigFix) as well as a couple for home use. If you happen to be updating an older Office, you’ll notice that it usually needs quite a few too.

···

On Wed, Apr 27, 2011 at 1:18 PM, Tim Roberts timr@probo.com wrote:

Ray Pasco wrote:

Works for me in 2.8.10:

The MSW .CMD file script interpreter takes it upon itself to double

any caret characters [ ^ ] it finds in a filename, even when the

filename is double-quoted ! How very sad…

That’s simply not true. The interpreter does not double ANY

characters. For reasons that are beyond human comprehension, Microsoft

chose caret [ ^ ] as their escape character instead of backslash. You

have exactly the same problems with ^ in Windows that you do with

backslash in Unix. If you want caret in a file name, you either have to

double it, or you have to wrap the name in quotes. One or the other.

If you show an example of what led you to make that statement, I can

provide an explanation.

I’ve never tried using filenames with carets before this. Quoting all

the other special characters, [ ()@ ], excluding [ % ], keeps them intact.

It’s not necessary to quote those characters. They have no special

meaning. There are exactly 5 characters that need quoting: & ^ < > ;

Also, my PC has been updated with fifty-six (56) MSW hotfixes in the

last 12 days. I’m sure every one of them has been 100% tested…

That’s common if you have a new installation. If you install XP SP3

today, you’ll get upwards of 100 updates over a period of days. That’s

not surprising for a system that was released 3 years ago. If you

installed a new RHEL 5.0 install today, you’d have exactly the same

situation.

Tim Roberts, timr@probo.com

Providenza & Boekelheide, Inc.

Mike Driscoll

Blog: http://blog.pythonlibrary.org

The source of all the problems is that my MS OS installation had permanently “lost its mind” - I had to reinstall the OS !

I’m trying to create a valid Python identifier name derived from an OS filename. Python identifiers are in the form: [_azAZ][09_azAZ] and so, may not contain characters such as [ ()#@! ], etc., which are perfectly valid for MSW filenames.

Thanks,
Ray

The source of all the problems is that my MS OS installation had permanently “lost its mind” - I had to reinstall the OS !

Thanks,
Ray

When you say identifier, I take it you mean something you can name a variable.

However, when I see this, it makes me think you're mingling program and data. With a Python dict, you can store and access all sorts of stuff without giving it variable names, and dict keys can be just about anything.

Why do you need to have your data files match to a variable name?

-Chris

···

On 4/28/11 12:13 PM, Ray Pasco wrote:

I'm trying to create a valid Python identifier name derived from an OS
filename. Python identifiers are in the form: [_azAZ][09_azAZ] and so,
may not contain characters such as [ ()#@! ], etc., which are perfectly
valid for MSW filenames.

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

I want it to be the other way around: The data retrieval call will match as best as possible the name of the disk file from which the data was read. This is the strategy used in [ img2py.py ].

Yes, I’m using a dictionary to store the filename/identifier pairs, but just like in any language dictionary, you first have to know how the word is spelled before you can look it up.

···

On Thu, Apr 28, 2011 at 4:09 PM, Christopher Barker Chris.Barker@noaa.gov wrote:

Why do you need to have your data files match to a variable name?

-Chris


Ray Pasco