[Python-Dev] Fwd: [Python-committers] Pulling from contributors repositories

2011-06-13 Thread Hirokazu Yamamoto
I've read the Python-committers thread Pulling from contributors 
repositories, which is about version control system. It seems there are 
two main issues, linear (cleaner) history on pushing, and NEWS merging. 
I'm newby of bazaar, but it seems to have a solution for first issue.


$ bzr checkout /repo/trunk

$ bzr merge /repo/feature-a

$ bzr revert --forget-merges

$ bzr push

See 
http://doc.bazaar.canonical.com/latest/en/user-guide/adv_merging.html#merging-without-parents


___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] OpenSSL Vulnerability (openssl-1.0.0a)

2010-12-09 Thread Hirokazu Yamamoto

On 2010/11/25 1:23, exar...@twistedmatrix.com wrote:

Ah. Okay, then Python 3.2 would be vulnerable. Good thing it isn't
released yet. ;)


It seems OpenSSL 1.0.0c out.

http://openssl.org/news/secadv_20101202.txt

 02-Dec-2010:  Security Advisory: ciphersuite downgrade fix
 02-Dec-2010: 	   OpenSSL 1.0.0c is now available, including important 
 bug and security fixes
 02-Dec-2010: 	   OpenSSL 0.9.8q is now available, including important 
 bug and security fixes

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] kill_python on windows buildbots

2010-12-07 Thread Hirokazu Yamamoto

On 2010/12/08 0:11, David Bolen wrote:

In thinking about it some more, I suppose there's still a small window
for a loss of communication during a test which results in clean not
being run (which could then block the next svn checkout without an
opportunity to kill the processes), so maybe the right place is
actually at the end of the test batch file which is the step during
which such hung processes might get generated?  I don't know the
history, if any, of it's current location in the flow.


Yes, but test can freeze. In that case, I'm worried that
  (snip)
  rt.bat  # freeze here (will be halt by buildbot)
  vcbuild   kill_python_d # Will this be called?
in test.bat.
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Unanswered reactions to python-checkins

2010-12-05 Thread Hirokazu Yamamoto

On 2010/12/05 23:19, Éric Araujo wrote:

Me, about a change to winsound.PlaySound:

  Extension Modules
  -

+- Issue #6317: Now winsound.PlaySound only accepts unicode.
+
  - Issue #6317: Now winsound.PlaySound can accept non ascii filename.

I think the new entry should have replaced the older: “only accepts”
trumps “can accept“.


This is two difference thing. Ordinary winsound.PlaySound accepted both
bytes and str, but cannot accept non ascii filename. Now it accepts
only str, but can accept non ascii filename.

I can read can accept as can accept str, but also bytes, but this
is not true.
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] PEP 11: Dropping support for ten year old systems

2010-12-05 Thread Hirokazu Yamamoto

On 2010/12/06 6:48, Martin v. Löwis wrote:

The other major system affected by this would be Windows 2000, for which
we already decided to not support it anymore.

Opinions?


I'm +1/2 for supporting Windows 2000...
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [Python-checkins] r87070 - python/branches/py3k/Lib/test/test_shutil.py

2010-12-04 Thread Hirokazu Yamamoto

On 2010/12/05 11:08, Brian Curtin wrote:

I created #10540 for this issue, but the patch I have on there is just a bad
hack. I need to fix os.path.samefile for hard links, which might be easier
if we keep st_ino data in stat structures on Windows.


MSDN says,
http://msdn.microsoft.com/en-us/library/aa363788%28v=VS.85%29.aspx

In the NTFS file system, a file keeps the same file ID until it is deleted.


Hard link can be live in NTFS only, so maybe we can say st_ino data is
valid until hard links are established.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [Python-checkins] r87070 - python/branches/py3k/Lib/test/test_shutil.py

2010-12-04 Thread Hirokazu Yamamoto

I missed it, st_dev is not set yet. When I set st_dev with
dwVolumeSerialNumber, it was sometimes negative. Is it OK?
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [Python-checkins] r86817 - python/branches/py3k-stat-on-windows/Lib/test/test_shutil.py

2010-12-02 Thread Hirokazu Yamamoto

On 2010/11/27 5:31, Brian Curtin wrote:

On Fri, Nov 26, 2010 at 14:18, Hirokazu Yamamotoocean-c...@m2.ccsnet.ne.jp

wrote:



On 2010/11/27 5:02, Brian Curtin wrote:


We briefly chatted about this on the os.link
feature issue, but I never found a way around it.



How about implementing os.path.samefile in
Modules/posixmodule.c like this?

http://bugs.python.org/file19262/py3k_fix_kill_python_for_short_path.patch

# I hope this works.



That's almost identical to what the current os.path.sameopenfile is.

Lib/ntpath.py opens both files, then compares them via _getfileinformation.
That function is implemented to take in a file descriptor, call
GetFileInformationByHandle with it, then returns a tuple
of dwVolumeSerialNumber, nFileIndexHigh, and nFileIndexLow.



Yes. Difference is, file object cannot represent directory,
and probably FILE_FLAG_BACKUP_SEMANTICS makes it faster to open file.
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-26 Thread Hirokazu Yamamoto

On 2010/11/14 9:06, Victor Stinner wrote:

Yes, but how do you check if the input argument is a bytes or a str object
with your PyArg_Parse converter? You should use O format and manually
convert it to unicode, and then convert the result back to bytes (if the input
was bytes). It don't think that it makes the code shorter.

The code is currently working. The question is if we have to drop the ANSI API
now, later or never. It looks like the decision moves to later (deprecate in
3.2, remove in 3.3). I still think that drop now doesn't really hurt.

Victor


Humble thoughts...
Is it possible a conversion from bytes (ANSI) to unicode fails on
windows? If not, is it allowed to convert to unicode with
PyUnicode_FSDecoder if function doesn't return str? For example, 
os.stat() takes str as arguments but doesn't return str.


# I noticed win_readlink() in Modules/posixmodule.c already unicode
# only. Maybe not so much problem? ;-)
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-26 Thread Hirokazu Yamamoto

On 2010/11/12 1:18, Ulrich Eckhardt wrote:

# I recently did it for winsound.PlaySound with MvL's approval


Interesting, is there a ticket associate with this? Also, was that on Python 3
or 2? Which commits?


Sorry for late posting. Rev 86300 and Issue 6317.
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [Python-checkins] r86817 - python/branches/py3k-stat-on-windows/Lib/test/test_shutil.py

2010-11-26 Thread Hirokazu Yamamoto

On 2010/11/27 3:52, Brian Curtin wrote:

On Fri, Nov 26, 2010 at 12:44, hirokazu.yamamotopython-check...@python.org

wrote:



Author: hirokazu.yamamoto
Date: Fri Nov 26 19:44:28 2010
New Revision: 86817

Log:
Now can reproduce the error on AMD64 Windows Server 2008
even where os.symlink is not supported.


Modified:
   python/branches/py3k-stat-on-windows/Lib/test/test_shutil.py

Modified: python/branches/py3k-stat-on-windows/Lib/test/test_shutil.py

==
--- python/branches/py3k-stat-on-windows/Lib/test/test_shutil.py
  (original)
+++ python/branches/py3k-stat-on-windows/Lib/test/test_shutil.pyFri
Nov 26 19:44:28 2010
@@ -271,24 +271,32 @@
 shutil.rmtree(src_dir)
 shutil.rmtree(os.path.dirname(dst_dir))

-@support.skip_unless_symlink
+@unittest.skipUnless(hasattr(os, 'link'), 'requires os.link')
 def test_dont_copy_file_onto_link_to_itself(self):
 # bug 851123.
 os.mkdir(TESTFN)
 src = os.path.join(TESTFN, 'cheese')
 dst = os.path.join(TESTFN, 'shop')
 try:
-f = open(src, 'w')
-f.write('cheddar')
-f.close()
-
-if hasattr(os, link):
-os.link(src, dst)
-self.assertRaises(shutil.Error, shutil.copyfile, src, dst)
-with open(src, 'r') as f:
-self.assertEqual(f.read(), 'cheddar')
-os.remove(dst)
+with open(src, 'w') as f:
+f.write('cheddar')
+os.link(src, dst)
+self.assertRaises(shutil.Error, shutil.copyfile, src, dst)
+with open(src, 'r') as f:
+self.assertEqual(f.read(), 'cheddar')
+os.remove(dst)
+finally:
+shutil.rmtree(TESTFN, ignore_errors=True)

+@support.skip_unless_symlink
+def test_dont_copy_file_onto_symlink_to_itself(self):
+# bug 851123.
+os.mkdir(TESTFN)
+src = os.path.join(TESTFN, 'cheese')
+dst = os.path.join(TESTFN, 'shop')
+try:
+with open(src, 'w') as f:
+f.write('cheddar')
 # Using `src` here would mean we end up with a symlink pointing
 # to TESTFN/TESTFN/cheese, while it should point at
 # TESTFN/cheese.
@@ -298,10 +306,7 @@
 self.assertEqual(f.read(), 'cheddar')
 os.remove(dst)
 finally:
-try:
-shutil.rmtree(TESTFN)
-except OSError:
-pass
+shutil.rmtree(TESTFN, ignore_errors=True)

 @support.skip_unless_symlink
 def test_rmtree_on_symlink(self):



You might be working on something slightly different, but I have an issue
created for the failure of that test: http://bugs.python.org/issue10540

It slipped past me because I was only running the test suite as a regular
user without the required symlink privilege, so the test was skipped. That
Server 2008 build slave runs the test suite as administrator, so it was
running that test and going into the os.link block, which it didn't do until
r86733.


I'm not sure, but why does os.path.samefile return False for hard link
on windows? MSDN says,

 A hard link is the file system representation of a file by which more 
 than one path references a single file in the same volume.

(http://msdn.microsoft.com/en-us/library/aa365006%28VS.85%29.aspx)

I know st_ino on windows is a bit different from POSIX, so, just I'm not 
sure. ;-)




___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [Python-checkins] r86817 - python/branches/py3k-stat-on-windows/Lib/test/test_shutil.py

2010-11-26 Thread Hirokazu Yamamoto

On 2010/11/27 5:02, Brian Curtin wrote:

We briefly chatted about this on the os.link
feature issue, but I never found a way around it.


How about implementing os.path.samefile in
Modules/posixmodule.c like this?

http://bugs.python.org/file19262/py3k_fix_kill_python_for_short_path.patch

# I hope this works.
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] OpenSSL Voluntarily (openssl-1.0.0a)

2010-11-22 Thread Hirokazu Yamamoto

Hello. Does this affect python? Thank you.

http://www.openssl.org/news/secadv_20101116.txt
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Issues 9931 and 9055 - test_ttk_guionly and buildbot run as a service

2010-11-13 Thread Hirokazu Yamamoto

On 2010/11/13 2:07, Terry Reedy wrote:

On 11/12/2010 3:44 AM, Paul Moore wrote:

Hi,
My buildbot has been failing for some time because of these 2 issues,
both related to the fact that tests are hanging when run as a service
(and hence have no display to open GUI elements on). Both issues have
patches, and as far as I am aware, the patches fix the issues
reasonably well. What can I do to move these 2 issues forwards? As
things stand, my buildbot is not providing a lot of value on the 3.x
branch :-(


http://bugs.python.org/issue9055
is marked as a 2.7 issue only, perhaps fixed by Tim Golden's committed
patches. Should it be re-versioned for 3.1/2? There is no patch file
attached, though perhaps the code in Yamamoto's message is meant as such
(but for which version?). So the first thing you could do is clarify the
current status and remaining issue on the tracker.

http://bugs.python.org/issue9931
by Yamamoto is marked for all 3 versions. It seems to be a similar
issue, though marked 'test' rather than 'ctypes'. It does have a patch
by him apparently based on his previous comments. The issue has no
responses and needs a patch review. So the first thing you could do is
to provide one;-). If it looks great (no changes that you can think of)
and works great, say so. Then it can move on to commit review stage.

PS. Providing links like the above makes it easier for multiple people
to take a look and respond.


My patch won't fix issue9055 directly, but solves issue9931.
Probably it's easy to create a patch to fix issue9055 based
on my patch.

One problem is, how to skip test. With single decorator like
skip_unless_symlink? Or let requires() raise SkipTest?
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-13 Thread Hirokazu Yamamoto

On 2010/11/12 4:26, Victor Stinner wrote:
 On Thursday 11 November 2010 17:07:28 Hirokazu Yamamoto wrote:
 Hello. Is it possible to remove Win32 ANSI API (ie: GetFileAttributesA)
 and only use Win32 WIDE API (ie: GetFileAttributesW)?
 Mainly in posixmodule.c.

 Even if I hate the MBCS encoding, because it replaces undecodable 
characters
 by similar glyphs by default, I'm not certain that it is a good idea 
to drop

 the bytes API.

On 2010/11/12 21:08, Victor Stinner wrote:

On Thursday 11 November 2010 23:01:32 you wrote:

Sure, it will divide the number of lines, of the code specific to
Windows, by two.


Can we get most of the code cleanup benefit without the backwards
compatibility risk by doing the decode from 'mbcs' on our side of the
fence?


I created PyUnicode_FSDecoder, a ParseTuple converter used to work on unicode
paths, instead of bytes paths. On Windows, this converter uses mbcs encoding
in strict mode, whereas Windows converter uses replace error handler to
decode, and ignore to encode. So I don't think that we should this converter
on Windows.


That is, have code that was the C equivalent of:

arg_is_bytes = not isinstance(arg, str)
if arg_is_bytes:
   val = _decode_mbcs(arg)
   # Decoding error checking here
else:
   val = arg
# Common processing using WIDE API
if arg_is_bytes:
   result = _encode_mbcs(wide_result)
   # Encoding error checking here
else:
   result = wide_result


This doesn't make the code shorter, it may be longer than the actual code, and
it is less compliant with the Windows native API...


Is it possible to implement new PyArg_ParseTuple converter to use
PyUnicode_Decode(const char *s,
 Py_ssize_t size,
 const char *encoding, /* mbcs */
 const char *errors) /* replace */
and use it?
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Removal of Win32 ANSI API

2010-11-11 Thread Hirokazu Yamamoto

Hello. Is it possible to remove Win32 ANSI API (ie: GetFileAttributesA)
and only use Win32 WIDE API (ie: GetFileAttributesW)?
Mainly in posixmodule.c.
I think we can simplify the code hugely. (This means droping bytes
support for os.stat etc on windows)

# I recently did it for winsound.PlaySound with MvL's approval

Thank you.
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [Python-checkins] r85987 - python/branches/py3k/Lib/test/test_os.py

2010-11-04 Thread Hirokazu Yamamoto

On 2010/11/02 1:30, Nick Coghlan wrote:

On Tue, Nov 2, 2010 at 2:10 AM, Hirokazu Yamamoto
ocean-c...@m2.ccsnet.ne.jp  wrote:

Does this really cause resource warning? I think os.popen instance
won't be into traceback because it's not declared as variable. So I
suppose it will be deleted by reference count == 0 even when exception
occurs.


Any time __del__ has to close the resource triggers ResourceWarning,
regardless of whether that is due to the cyclic garbage collector or
the refcount naturally falling to zero. In the past dealing with this
was clumsy, so it made sense to rely on CPython's refcounting to do
the work. However, we have better tools for deterministic resource
management now (in the form of context managers), so these updates
help make the standard library and its test suite more suitable for
use with non-refcounting Python implementations (such as PyPy, Jython
and IronPython).

Cheers,
Nick.



Thank you for reply. Probably this is difficult problem. I often
use with statement, but it's also true sometimes I feel this warning is
a bit noisy. Is there a way to turn this off?

C:\Documents and Settings\Oceanpy3k
Python 3.2a3+ (py3k, Nov  3 2010, 00:27:28) [MSC v.1200 32 bit (Intel)] 
on win32


Type help, copyright, credits or license for more information.
 open(a.py).read()
__main__:1: ResourceWarning: unclosed file _io.TextIOWrapper 
name='a.py' encodi

ng='cp932'
'\nimport timeit\n\nt = 
timeit.Timer(\nos.stat(e:/voltest/lnk)\n, \ni

mport os\n)\n\nprint(t.timeit(1000))\n\n'
[49593 refs]

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [Python-checkins] r85987 - python/branches/py3k/Lib/test/test_os.py

2010-11-04 Thread Hirokazu Yamamoto

On 2010/11/04 23:23, Antoine Pitrou wrote:

You can use all the usual means of controlling emission of warnings, so
for example python -Wi would work to silence them all.
Also, ResourceWarning is silenced by default in release builds.

Regards

Antoine.


Thank you, this works. (I couldn't find the way from python --help)
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Resource leaks warnings

2010-11-02 Thread Hirokazu Yamamoto

Sorry for late post.

On 2010/09/29 20:01, Antoine Pitrou wrote:

Furthermore, it can produce real bugs, especially under Windows when
coupled with refererence cycles created by traceback objects


I think this can be relaxed with the patch in #9815. ;-)
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] PyMem_MALLOC vs PyMem_Malloc

2010-11-01 Thread Hirokazu Yamamoto

On 2010/10/31 2:32, M.-A. Lemburg wrote:

M.-A. Lemburg wrote:

Hirokazu Yamamoto wrote:

Hello. I found several codes using PyMem_Free to free
allocated memory with PyMem_MALLOC (ie: PyUnicode_AsWideCharString)

Is it safe?


Within the interpreter: yes.

In extensions: depends on the platform, but probably not.

The macros provide faster access to the C lib malloc calls.

The functions need to be used in extensions in case the interpreter will
free the resource or the extension wants to free an interpreter
allocated resource. They provide access to the malloc calls
used by the interpreter, which may operate on a different heap
than the extensions.

Within an extension the macros use the extension heap.

A subtle, but important difference.


BTW: If you were referring to extensions using PyMem_Free()
to deallocate memory allocated in the interpreter using
PyMem_MALLOC(), then that's exactly how things should be
done.

I was referring to use of the two mentioned APIs within
an extension.


Thank you for reply, probably I could understand.
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [Python-checkins] r85987 - python/branches/py3k/Lib/test/test_os.py

2010-11-01 Thread Hirokazu Yamamoto

On 2010/10/31 6:24, brian.curtin wrote:

Author: brian.curtin
Date: Sat Oct 30 23:24:21 2010
New Revision: 85987

Log:
Fix #10257. Clear resource warnings by using os.popen's context manager.


Modified:
python/branches/py3k/Lib/test/test_os.py

Modified: python/branches/py3k/Lib/test/test_os.py
==
--- python/branches/py3k/Lib/test/test_os.py(original)
+++ python/branches/py3k/Lib/test/test_os.pySat Oct 30 23:24:21 2010
@@ -406,17 +406,19 @@
  os.environ.clear()
  if os.path.exists(/bin/sh):
  os.environ.update(HELLO=World)
-value = os.popen(/bin/sh -c 'echo $HELLO').read().strip()
-self.assertEquals(value, World)
+with os.popen(/bin/sh -c 'echo $HELLO') as popen:
+value = popen.read().strip()
+self.assertEquals(value, World)


Does this really cause resource warning? I think os.popen instance
won't be into traceback because it's not declared as variable. So I
suppose it will be deleted by reference count == 0 even when exception
occurs.
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [Python-checkins] r85934 - in python/branches/py3k: Misc/NEWS Modules/socketmodule.c

2010-10-30 Thread Hirokazu Yamamoto

On 2010/10/30 3:20, martin.v.loewis wrote:

Modified: python/branches/py3k/Modules/socketmodule.c
==
--- python/branches/py3k/Modules/socketmodule.c (original)
+++ python/branches/py3k/Modules/socketmodule.c Fri Oct 29 20:20:08 2010
@@ -3093,6 +3093,27 @@
  static PyObject *
  socket_gethostname(PyObject *self, PyObject *unused)
  {
+#ifdef MS_WINDOWS
+/* Don't use winsock's gethostname, as this returns the ANSI
+   version of the hostname, whereas we need a Unicode string.
+   Otherwise, gethostname apparently also returns the DNS name. */
+wchar_t buf[MAX_COMPUTERNAME_LENGTH];
+DWORD size = sizeof(buf);
+if (!GetComputerNameExW(ComputerNamePhysicalDnsHostname, buf,size)) {
+if (GetLastError() == ERROR_MORE_DATA) {
+/* MSDN says this may occur because DNS allows longer names */
+PyObject *result = PyUnicode_FromUnicode(NULL, size);
+if (!result)
+return NULL;
+if (GetComputerName(ComputerNamePhysicalDnsHostname,
+PyUnicode_AS_UNICODE(result),
+size+1))
+return result;
+}
+return PyErr_SetExcFromWindowsErr(PyExc_WindowsError, GetLastError());
+}
+return PyUnicode_FromUnicode(buf, size);
+#else
  char buf[1024];
  int res;
  Py_BEGIN_ALLOW_THREADS
@@ -3102,6 +3123,7 @@
  return set_error();
  buf[sizeof buf - 1] = '\0';
  return PyUnicode_FromString(buf);
+#endif
  }

  PyDoc_STRVAR(gethostname_doc,
___
Python-checkins mailing list
python-check...@python.org
http://mail.python.org/mailman/listinfo/python-checkins



I think size should be in TCHARs, not in bytes. (MSDN says so)
And GetComputerName's signature differs from MSDN. (Maybe should
use GetComputerNameExW again?)

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] PyMem_MALLOC vs PyMem_Malloc

2010-10-30 Thread Hirokazu Yamamoto

Hello. I found several codes using PyMem_Free to free
allocated memory with PyMem_MALLOC (ie: PyUnicode_AsWideCharString)

Is it safe?
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Fwd: Builder: x86 Windows7 3.x OpenSSL compile error

2010-09-20 Thread Hirokazu Yamamoto

Hello. I've sent following mail to buildbot manager,
but I found that buildbot page saids the problem of unsable
bot should be sent to python-...@python.org. So I'll do it.

 Original Message 
Subject: Builder: x86 Windows7 3.x OpenSSL compile error
Date: Mon, 20 Sep 2010 22:53:04 +0900
From: Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp
To: db3l@gmail.com

Hello, David Bolen. I'm Hirokazu Yamamoto, Python committer.
I've noticed your buildbot x86 Windows7 3.x fails to compile OpenSSL,
I'm very sorry because this buildbot is very fast and looks useful.
(Running on Windows7 which I don't have)

Builder: x86 Windows7 3.x
http://www.python.org/dev/buildbot/all/builders/x86%20Windows7%203.x

I confirmed this happens when nasmw's version is 2.06.
I'm using 2.07 on my machine, so I didn't notice this. I checked
Windows buildbot's nasmw versions with
Tools/buildbot/external_common.bat hack, the versions were

x86 Windows7 3.x Buildbot (FAILURE)
NASM version 2.06 compiled on Jul  1 2009

x86 XP-5 3.x Buildbot (OK)
NASM version 2.07 compiled on Jul 19 2009

x86 XP-4 3.x Buildbot (OK)
NASM version 2.02 compiled on Feb 23 2008

I didn't check 2.02 but probably it dosen't have this issue.
Could you upgrade nasmw on Windows7 buildbot? Thank you.

Regards,
Yamamoto.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [Python-checkins] r83763 - in python/branches/py3k: Doc/library/signal.rst Lib/test/test_signal.py Misc/NEWS Modules/signalmodule.c

2010-08-07 Thread Hirokazu Yamamoto

This is the idea just popped up. :-)

#define SIG(name) if (sig_num != SIG##name)
SIG(ABRT) SIG(FPE) SIG(ILL) SIG(INT) SIG(SEGV) SIG(TERM) {
 PyErr_SetString(PyExc_ValueError, signal number out of range);
 return NULL;
 }
#undef SIG

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [Python-checkins] r83763 - in python/branches/py3k: Doc/library/signal.rst Lib/test/test_signal.py Misc/NEWS Modules/signalmodule.c

2010-08-07 Thread Hirokazu Yamamoto

+valid_sig |= (sig_num == valid_sigs[cur_sig]);


I think ||= is more appropriate here.
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [Python-checkins] r83763 - in python/branches/py3k: Doc/library/signal.rst Lib/test/test_signal.py Misc/NEWS Modules/signalmodule.c

2010-08-07 Thread Hirokazu Yamamoto

On 2010/08/07 19:09, Greg Ewing wrote:

Hirokazu Yamamoto wrote:


#define SIG(name) if (sig_num != SIG##name)
SIG(ABRT) SIG(FPE) SIG(ILL) SIG(INT) SIG(SEGV) SIG(TERM) {
PyErr_SetString(PyExc_ValueError, signal number out of range);


Out of range doesn't seem like quite the right message here,
because it suggests a contiguous range of legal values, which
isn't the case.


I agree, I suppose invalid signal number or something is better.
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [Python-checkins] r83763 - in python/branches/py3k: Doc/library/signal.rst Lib/test/test_signal.py Misc/NEWS Modules/signalmodule.c

2010-08-07 Thread Hirokazu Yamamoto

On 2010/08/07 19:18, Ronald Oussoren wrote:


On 7 Aug, 2010, at 10:24, Hirokazu Yamamoto wrote:


This is the idea just popped up. :-)

#define SIG(name) if (sig_num != SIG##name)
SIG(ABRT) SIG(FPE) SIG(ILL) SIG(INT) SIG(SEGV) SIG(TERM) {
 PyErr_SetString(PyExc_ValueError, signal number out of range);
 return NULL;
 }
#undef SIG


What's wrong with:

switch (sig_num) {
case SIGABRT:
case SIGFPE:
...
case SIGTERM:
break;
default:
   PyErr_SetString(...)
   return NULL;
}

That would IMO be clearer than the macro you propose.

Ronald


Hmm... I liked the macro idea, but nothing is wrong with switch
statement.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] 3.1a2

2009-04-01 Thread Hirokazu Yamamoto


Hirokazu Yamamoto wrote:


I added #5499 to release blocker because it needs specification 
decision. (It's too strong?)


Thank you for fixing this. I also added

#5391: mmap: read_byte/write_byte and object type
#5410: msvcrt bytes cleanup

which depend on this issue. These are also API spec issue.
#5410 is easy, but #5391 still needs decision which of getarg(c) or 
getarg(b) read_byte/write_byte should use.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] 3.1a2

2009-03-31 Thread Hirokazu Yamamoto


Benjamin Peterson wrote:

Hi,
I'd like to release the second alpha of 3.1 as planned on Saturday,
April 4th. There are currently two release blockers, issues #4847 and
#5470. #5470 appears to be Martin's issue.

I haven't looked at #4847 in depth, but appears that the csv module
will need some API changes to deal with encodings. Perhaps somebody
would like to sprint on it?



I added #5499 to release blocker because it needs specification 
decision. (It's too strong?)

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Test failures under Windows?

2009-03-30 Thread Hirokazu Yamamoto


David Bolen wrote:

I don't know why they are happening so frequently now when there was a
reasonable period when they weren't an issue (something about new I/O
support in 3.x perhaps?), but without preventing them it seems the
Windows build slaves are going to become (if not already) quite a bit
less useful.  Don't know about anyone else's but I can't watch mine
7x24.

-- David


CRT Assertion was totally disabled before, but recently was enabled,
and workarounds were patched for problematic functions. (ex: fdopen and 
dup) Probably this *patch* is not perfect. See 
http://bugs.python.org/issue4804


I'm now +3/4 for the idea disabling assertion by default,
and enabling by startup option or environment variable. (Or enabling
by default and disabling by environment variable?)

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] 3.1 performance

2009-03-07 Thread Hirokazu Yamamoto

Antoine Pitrou wrote:

Hello,

Out of curiosity, I timed running the test suite (./python -m test.regrtest)
in non-debug mode, in both the release30-maint and py3k branches:

* release30-maint got:
302 tests OK.
[...]
165.79user 26.03system 5:01.75elapsed 63%CPU

* py3k got:
304 tests OK.
[...]
113.33user 28.93system 4:06.79elapsed 57%CPU

So, 3.1 is 30% faster in user CPU time, even though it probably has more tests
(because of io-c, ordereddict and importlib). This is on a 64-bit Linux AMD
system, and I got similar results on a 64-bit Linux Core2 system.

Regards

Antoine.


Yes, traceback in large file is also quite fast now. Good work, io-c 
guys. :-)

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] What type of object mmap.read_byte should return on py3k?

2009-03-01 Thread Hirokazu Yamamoto

I uploaded the patch with choice (a)
http://bugs.python.org/file13215/py3k_mmap_and_bytes.patch
If (b) is suitable, I'll rewrite the patch.
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] What type of object mmap.read_byte should return on py3k?

2009-02-28 Thread Hirokazu Yamamoto
Hello. I noticed mmap.read_byte returns 1-length unicode on py3k. I felt 
this was strange, so I created issue on bug tracker 
(http://bugs.python.org/issue5391) and Martin proposed this is suitable 
for discussion on python-dev. I'll quote messages on bug tracker here.


I wrote:

On Python3000, mmap.read_byte returns str not bytes, and mmap.write_byte
accepts str. Is this intended behavior?


import mmap
m = mmap.mmap(-1, 10)
type(m.read_byte())

class 'str'

m.write_byte(a)
m.write_byte(ba)


Maybe another possibility. read_byte() returns int which represents
byte, write_byte accepts int which represents byte. (Like babc[0]
returns int not 1-length bytes)


Martin wrote:

Indeed, I think it should use the b code, instead of the c code.
Please discuss this on python-dev, though.

It might not be ok to backport this to 3.0, since it may break existing
code.



Furthermore, all other uses of the c code might need to be reconsidered.



___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] What type of object mmap.read_byte should return on py3k?

2009-02-28 Thread Hirokazu Yamamoto

It certainly seems like mmap should be playing in an all-bytes world
(where only already encoded strings are allowed).


Agreed.


On the specific
question of whether it would be better for read_byte()/write_byte to use
1-length bytes objects or integers, I have no strong opinion (the former
is closer to the 2.x class API, the later more consistent with the
operation of the 3.x bytes class).


Personally, I was surprised when I saw b0123[1] != b1. But I don't
have strong opinion neither.


However, as Martin says, it wouldn't be reasonable to backport the fixes
in this to 3.0 - the associated API changes would almost certainly break
otherwise working code.


Agreed.

I greped py3k source tree with c, I found another Py_BuildValue(c in 
curse module. But this function returns unicode in else clause, so 
probably this is correct usage.


Modules\mmapmodule.c(207):  return Py_BuildValue(c, value);
Modules\_cursesmodule.c(893): return Py_BuildValue(c, rtn);
Modules\_dbmmodule.c(380):  else if ( strcmp(flags, c) == 0 )
Modules\_ctypes\cfield.c(112): 			if (idict-getfunc == 
getentry(c)-getfunc) {
Modules\_ctypes\stgdict.c(459): if (dict-getfunc != 
getentry(c)-getfunc
Modules\_ctypes\_ctypes.c(1372): 	if (itemdict-getfunc == 
getentry(c)-getfunc) {
Modules\_ctypes\_ctypes.c(1536): 		if (dict  (dict-setfunc == 
getentry(c)-setfunc)) {
Modules\_ctypes\_ctypes.c(1545): 		if (dict  (dict-setfunc == 
getentry(c)-setfunc)) {
Modules\_ctypes\_ctypes.c(4197): 		if (itemdict-getfunc == 
getentry(c)-getfunc) {
Modules\_ctypes\_ctypes.c(4890): 		if (itemdict-getfunc == 
getentry(c)-getfunc) {

PC\os2emx\getpathp.c(128):  strcat(filename, Py_OptimizeFlag ? o : 
c);
Python\import.c(1756):  strcpy(buf+i, Py_OptimizeFlag ? o : c);


___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] What type of object mmap.read_byte should return on py3k?

2009-02-28 Thread Hirokazu Yamamoto


Victor Stinner wrote:

About m.read_byte(), we have two choices:
 (a) Py_BuildValue(b, value) = 0
 (b) Py_BuildValue(y#, value, 1) = b\x00

About m.write_byte(x), we have also two choices:
 (a) PyArg_ParseTuple(args, b:write_byte, value): write_byte(0)
 (b) PyArg_ParseTuple(args, y#:write_byte, value, length) and
 check for length=1: write_byte(b\x00)

(b) choices are close to Python 2.x API. But we can already use 
m.read(1)-b\x00 and m.write(b\x00) to use byte string of 1 byte. So it 
would be better to break the API and use integers, (a) choices which require 
also documentation changes:


I'm +1 for (a) because mmap.__getitem__ already returns integer not 
1-length bytes. And as I wrote in http://bugs.python.org/msg82912, it 
seems that more bytes cleanup is needed in mmap 
documentaion/implementation. I hope someone else will look into other 
modules' ones. ;-)

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Py_END_ALLOW_THREADS and GetLastError()

2009-01-10 Thread Hirokazu Yamamoto

Kristján Valur Jónsson wrote:
 Currently on Windows, Py_END_ALLOW_THREADS can have the side effect of
 resetting the windows error code returned by GetLastError().

 There is a number of cases, particularly in posixmodule, with a pattern
 like:

 Py_BEGIN_ALLOW_THREADS

 result = FindNextFile(hFindFile, FileData);

 Py_END_ALLOW_THREADS

 /* FindNextFile sets error to ERROR_NO_MORE_FILES if

it got to the end of the directory. */

 if (!result  GetLastError() != ERROR_NO_MORE_FILES) {



 That doesn´t work.  (This particular site is where I noticed the
 problem, running the testsuite in a debug build).

 Now, the thread swith macro does take care to preserve „errno“, but not
 the windows system error.  This is easy to add, but it requires that
 windows.h be included by ceval.c and pystate.c

 The alternative fix is to find all these cases and manually preserve the
 error state, or query it right after the function call if needed.

 Any preferences?

Please see http://bugs.python.org/issue4906 :-)
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [Python-checkins] r66863 - python/trunk/Modules/posixmodule.c

2008-10-10 Thread Hirokazu Yamamoto



It seems to me that Skip was asking whether the memory leak impacted
the 2.6 branch, and the answer should have been No: the change that
introduced the memory leak had just been committed 10 minutes before.



You are probably right (although it's not quite clear from Skip's question).
  
Umm, sorry for misunderstandings.  I thought he indicated the set of two 
patches.

- Because of this misunderstanding, the changes to this
GetCurrentDirectoryW were backported to the release2.6 branch, despite
the fact that it's not a regression from a previous version, the NEWS
entry explicitly expresses doubts about the correction (which I happen
to share), there is no unit test and no item in the issue tracker.



I think it is fine that this fix was backported (assuming, without
review, that the fix is actually correct).

It is a bugfix, and it shouldn't realistically break existing applications.

IOW, PEP 6 was followed (except that there is no Patch Czar).
  
Thanks, I'm a bit relaxed. :-)

- The backport to release26-maint http://svn.python.org/view?rev=66865view=rev
also merged other changes (new unrelated unit tests). IMO unrelated
changes should be committed separately: different commit messages help
to understand the motivation of each backport.



Yes, that is unfortunate.

I'm skeptical that new tests actually need backporting at all. Python
doesn't really get better by new tests being added to an old branch.
Near-term, it might get worse because the new tests might cause false
positives, making users worried for no reason.
  
OK, I'll do separate commit for release26-maint even via svnmerge.py  (I 
did same way as in py3k)
But I'm bit confused. This is difficult problem for me, so I 'll commit 
to only trunk until some consensus

will be established.
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Not releasing rc1 tonight

2008-09-05 Thread Hirokazu Yamamoto
issue1040026 os.times() is bogus won't be fixed?
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Releasing alphas tonight

2008-05-07 Thread Hirokazu Yamamoto
Hello.

 The py3k branch has a major show stopper, It's leaking references to the
 max.

Is there any chance this leak also will be fixed?
http://bugs.python.org/issue

Thank you.
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com