git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-p4: import the ctypes module

From
EGEtienne Girard <etienne.g.girard@gmail.com>
Date
Oct 21, 2015, 09:54 UTC
Message-ID
<CAJA=mv5ui6OLc=0OSJg+k5a6bgSxwX=waLmyxtV4=ikWBkXPQg@mail.gmail.com>
In-Reply-To
<CAJA=mv7N=PmL69kgZRjq8P6J_qsfUbLx76WguhvqPrG2o1UFww@mail.gmail.com>

I was wrong, the script doesn't work on my machine if ctypes is not imported regardless of python version. I guess I was confused by using a version of git-p4 before ctypes was introduced, the failing version and the patched version, as well as several python versions.

Sorry for this misleading claim, and thanks for the quick fix.
2015-10-21 10:23 GMT+02:00 Etienne Girard <etienne.g.girard@gmail.com>:
Show 48 quoted lines
> Hello,
>
> I couldn't work further on this yesterday (but I read
> Documentation/SubmittingPatches, which is a good start I guess). The
> diff proposed by Dennis works on my machine, I'll try to figure out
> why the original script worked with 2.7.10.
>
> Thanks
>
> 2015-10-21 1:00 GMT+02:00 Luke Diamand <luke@diamand.org>:
>> On 20/10/15 20:36, Junio C Hamano wrote:
>>>
>>> Dennis Kaarsemaker <dennis@kaarsemaker.net> writes:
>>>
>>>>> I do not follow Python development, but does the above mean that
>>>>> with recent 2.x you can say ctypes without first saying "import
>>>>> ctypes"?  It feels somewhat non-pythonesque that identifiers like
>>>>> this is given to you without you asking with an explicit 'import',
>>>>> so I am puzzled.
>>>>
>>>>
>>>> No, you cannot do that. The reason others may not have noticed this bug
>>>> is that
>>>> in git-p4.py, ctypes is only used on windows.
>>>>
>>>>   111     if platform.system() == 'Windows':
>>>>   112         free_bytes = ctypes.c_ulonglong(0)
>>>>   113
>>>> ctypes.windll.kernel32.GetDiskFreeSpaceExW(ctypes.c_wchar_p(os.getcwd()),
>>>> None, None, ctypes.pointer(free_bytes))
>>>>
>>>> The fact that it works for the OP with 2.7.10 is puzzling (assuming that
>>>> it's
>>>> on the same system).
>>>
>>>
>>> Exactly.  That is where my "I am puzzled" comes from.
>>>
>>> The patch looks obviously the right thing to do.  Luke?  Lars?
>>
>>
>> It looks sensible to me, and works fine on Linux, thanks. ack.
>>
>> I can't test on Windows today but I can't see why it wouldn't work.
>>
>> Luke
>>
>>
Previous: Etienne GirardNext: Lars Schneider
Message 9 of 10 in “Git-p4 fails with NameError with python 2.7.2”
  1. Etienne GirardOct 20, 2015
  2. Luke DiamandOct 20, 2015
  3. Junio C HamanoOct 20, 2015
  4. Manlio PerilloOct 20, 2015
  5. git-p4: import the ctypes moduleDennis Kaarsemaker, Oct 20, 2015
  6. Junio C HamanoOct 20, 2015
  7. Luke DiamandOct 20, 2015
  8. Etienne GirardOct 21, 2015
  9. Etienne GirardOct 21, 2015
  10. Lars SchneiderOct 21, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.