Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #37189
| Path | csiph.com!aioe.org!news.mixmin.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder2.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <square.steve@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.025 |
| X-Spam-Evidence | '*H*': 0.95; '*S*': 0.00; 'python': 0.09; 'snippet': 0.09; "'c'": 0.16; 'dll,': 0.16; 'dlls': 0.16; 'mistake.': 0.16; 'python;': 0.16; 'result:': 0.16; 'subject:handling': 0.16; 'textual': 0.16; 'char': 0.17; '>>>': 0.18; 'input': 0.18; 'trying': 0.21; 'import': 0.21; 'ctypes': 0.22; 'minor': 0.22; 'specified': 0.23; "i've": 0.23; 'tried': 0.25; 'header:User- Agent:1': 0.26; 'appreciated.': 0.26; 'dll': 0.27; 'implies': 0.29; "i'm": 0.29; 'error': 0.30; 'code': 0.31; 'skip:s 30': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'expected': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'but': 0.36; 'message-id:@gmail.com': 0.36; 'being': 0.37; 'received:209': 0.37; 'some': 0.38; 'sure': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'where': 0.40; 'received:192.168': 0.40; 'bottom': 0.60; 'lost': 0.60; 'back': 0.62; 'header:Reply-To:1': 0.68; 'below:': 0.71; 'reply-to:no real name:2**0': 0.72; 'reply-to:addr:gmail.com': 0.79; 'newbie,': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:reply-to:user-agent:mime-version:to :subject:content-type:content-transfer-encoding; bh=3Ccyeg1j+ZUtwJb2uo17oRD/RWalR3ix9oMqyiV+SJQ=; b=LrvsEyfXmRuV62BrSLKhCh4Z0/HWoVAFlyZy/Tk49N0mrqV53ibTCTtxuD7UA568kM LTv8vSFvZborZvkT7CseFEa6srcrEMfl/h77tUObhteR23l8LYW3b1rtDmAIzXic3TIw 8smuTLwX+z0Ivg735q7O3nVbFM3t9lGdDE8dOXR3/aPbAhCP0lq5/2+KCR39sQRPOwsY 19eoD5/nTxWjsXqrCdXpjrGJoBuiy0yvzdBWJV27bgfE3NafXmKt6iCWFVQzmRdGzhrO g7mAltZloTGpYzoWv8DyKhm8I0yn52VXCS5aao4Yg36m1Rgkpc1tf6IY5vwGRVkO1umU Gktw== |
| X-Received | by 10.236.151.168 with SMTP id b28mr19909254yhk.11.1358765172043; Mon, 21 Jan 2013 02:46:12 -0800 (PST) |
| Date | Mon, 21 Jan 2013 10:46:07 +0000 |
| From | Steve Simmons <square.steve@gmail.com> |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | handling return codes from CTYPES |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| Reply-To | square.steve@gmail.com |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.736.1358765181.2939.python-list@python.org> (permalink) |
| Lines | 48 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1358765181 news.xs4all.nl 6932 [2001:888:2000:d::a6]:36133 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:37189 |
Show key headers only | View raw
PY33, Win7, Python Newbie, Not homework:-)
I'm trying to use some 'C' DLLs from Python using ctypes and I have a
minor issue with the return valuesbut I am new to Python; ctypes and
using DLLs so I am at the bottom of so many learning curves, I'm not
sure where or how to find my mistake.
When I call the DLL, I am expecting a return of 1 (success) or a
negative number (one of a set of error conditions)the return value is
specified as 'short' in the DLL call specification - "short InitScanLib
(const char * szLicense)". What I get back is either a 1 or something
like 65535. This implies that I am receiving the expected value (-1)
but 'something' is being lost in the translation. The code is asper the
snippet below:
>>> from ctypes import *
>>> sLib = cdll.slib
>>> lic_key = c_char_p("asdfghjkl".encode(encoding='utf_8',
errors='strict'))
>>> initResult = sLib.InitScanLib(lic_key.value)
>>> print("InitScanLib Result: ", initResult)
InitScanLib Result: 65535
>>>
I've tried declaring initResult as c_short by: inserting...
>>> initResult = c_short(0)
... before the call to sLib.InitScanLib but I still get the same
response (65535).
Interactively, I can see ...
>>> c_short(65535)
c_short(-1)
>>> c_short(-1)
c_short(-1)
>>>
It's not a critical issue because I only want the return value to
lookupa textual error message but I do want to understand what's going
on. Any input appreciated.
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
handling return codes from CTYPES Steve Simmons <square.steve@gmail.com> - 2013-01-21 10:46 +0000
Re: handling return codes from CTYPES Duncan Booth <duncan.booth@invalid.invalid> - 2013-01-21 11:11 +0000
Re: handling return codes from CTYPES Steve Simmons <square.steve@gmail.com> - 2013-01-22 08:02 +0000
Re: handling return codes from CTYPES Chris Angelico <rosuav@gmail.com> - 2013-01-23 00:10 +1100
csiph-web