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 2011年07月03日 08:02 by techtonik, last changed 2022年04月11日 14:57 by admin.
| Messages (3) | |||
|---|---|---|---|
| msg139675 - (view) | Author: anatoly techtonik (techtonik) | Date: 2011年07月03日 08:02 | |
ctypes documentation lacks an example, how to pass a raw data block from Python to a C function. For example, how to pass this chunk:
data = open('somefile', 'rb').read()
to this function:
int checkBuffer(LPSTR lpData, DWORD dwBufferLength);
?
|
|||
| msg139676 - (view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) | Date: 2011年07月03日 08:52 | |
Can you suggest a patch? |
|||
| msg139686 - (view) | Author: anatoly techtonik (techtonik) | Date: 2011年07月03日 12:24 | |
ISTM that this code works ok.
data = open('data.raw', 'rb').read()
ret = checkBuffer(data, len(data))
You need to make sure that checkBuffer doesn't try to modify memory though. For mutable memory blocks use create_string_buffer().
|
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:19 | admin | set | github: 56685 |
| 2011年07月03日 12:24:43 | techtonik | set | messages: + msg139686 |
| 2011年07月03日 08:52:25 | amaury.forgeotdarc | set | nosy:
+ amaury.forgeotdarc messages: + msg139676 |
| 2011年07月03日 08:02:36 | techtonik | create | |