Antoine Pitrou added the comment:
Shouldn't this issue be closed now?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17137
___
___
STINNER Victor added the comment:
Shouldn't this issue be closed now?
Correct, I forgot to close it.
--
resolution: - fixed
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17137
Jan Lachnitt added the comment:
Knowing that the problem is related to the internal representation of the
strings, I have written a short script which reproduces the problem. It is this
simple:
import os
name = 'sub-fcc'
wrkdir = 'D:\\Bug reports\\Python\\test'
dirname = wrkdir+os.sep+name
STINNER Victor added the comment:
It works correctly in Python 3.2.3 64-bit on Windows 8.
Can you reproduce the issue on other Windows versions?
2013/2/7 Jan Lachnitt rep...@bugs.python.org:
Jan Lachnitt added the comment:
Knowing that the problem is related to the internal representation
STINNER Victor added the comment:
Can you try to following command to get the size in bytes of the wchar_t type?
import types
ctypes.sizeof(ctypes.c_wchar)
4
You can also use _PyObject_Dump() to dump your string:
import ctypes
x=abc
_PyObject_Dump=ctypes.pythonapi._PyObject_Dump
Mark Dickinson added the comment:
I don't think this is just windows; I see similarly odd results on OS X. The
first encode call gives expected results; the second ends in garbage.
Python 3.4.0a0 (default:eb0370d4686c+, Feb 7 2013, 14:59:41)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Jan Lachnitt added the comment:
On Windows XP 32-bit: 3.2.3 works, 3.3.0 fails.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17137
___
___
Florent Xicluna added the comment:
Confirmed on OSX 64bits with Mark's sample.
$ python3.3
Python 3.3.0 (default, Jan 24 2013, 08:28:09)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type help, copyright, credits or license for more information.
dir1 = D:\\Bug
Jan Lachnitt added the comment:
...
print(ctypes.sizeof(ctypes.c_wchar))
_PyObject_Dump=ctypes.pythonapi._PyObject_Dump
_PyObject_Dump.argtypes=(ctypes.py_object,)
print(_PyObject_Dump(dirname))
print(list(dirname))
in Python 3.3.0 64-bit on Windows 8 produces:
2
object : 'D:\\Bug
Changes by Florent Xicluna florent.xicl...@gmail.com:
--
components: -Windows
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17137
___
___
STINNER Victor added the comment:
Ok, it's a bug in the function resize a compact Unicode string,
resize_compact(): wstr field is not updated to the new size.
Attached patch should fix it. The bug was introduced by me in Python 3.3.
I don't think that it's possible to resize wstr buffer
STINNER Victor added the comment:
@Jan Lachnitt: Thanks for your patience and having executed all my commands :-)
Thanks for the short script reproducing the issue.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17137
Changes by STINNER Victor victor.stin...@gmail.com:
--
nosy: +larry
priority: high - release blocker
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17137
___
Antoine Pitrou added the comment:
The import random isn't needed in your patch.
--
nosy: +pitrou
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17137
___
Roundup Robot added the comment:
New changeset 3b316ea5aa82 by Victor Stinner in branch '3.3':
Issue #17137: When an Unicode string is resized, the internal wide character
http://hg.python.org/cpython/rev/3b316ea5aa82
New changeset c10a3ddba483 by Victor Stinner in branch 'default':
(Merge 3.3)
Jan Lachnitt added the comment:
Here is a part of my code (with some comments added):
for struct in ini_structures:
dirname = wrkdir+os.sep+struct.name
if not os.path.isdir(dirname): # This works fine. If the directory
doesn't exist,...
try:
STINNER Victor added the comment:
I'm interested by your struct.name string: can you also dump it? Where
does it come from? Does it use ctypes?
* print(ascii(struct.name))
* print(ascii(struct.name.encode(unicode_internal)))
* print(ascii(struct.name.encode(utf-8)))
I'm interested by all
Jan Lachnitt added the comment:
print(ascii(struct.name))
print(ascii(struct.name.encode(unicode_internal)))
print(ascii(struct.name.encode(utf-8)))
produces:
'sub-fcc'
b's\x00u\x00b\x00-\x00f\x00c\x00c\x00'
b'sub-fcc'
and that looks correct.
struct.name originally comes from
STINNER Victor added the comment:
It would really help if you can write a short script reproducing the problem.
Can you reproduce the problem with Python 3.2 on Windows 8, or with Python 3.3
on Windows XP or 7?
--
___
Python tracker
New submission from Jan Lachnitt:
Python 3.3 64-bit seems to compile one of my files incorrectly. Specifically,
os.path.isdir returns True for a nonexistent folder. The important point is
that the code works correctly when it is performed step-by-step in pdb.
Python version:
Python 3.3.0
Mark Dickinson added the comment:
Reminds me of this question on StackOverflow:
http://stackoverflow.com/questions/14135846/string-concatenation-with-python-33-isdir-always-returns-true-3-hours-head
--
nosy: +mark.dickinson
___
Python tracker
Georg Brandl added the comment:
The SO post is scary. Maybe a non-normalized (smallest representation) PEP393
string is escaping into the wild?
--
nosy: +georg.brandl
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17137
Changes by Georg Brandl ge...@python.org:
--
nosy: +loewis
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17137
___
___
Python-bugs-list mailing
Changes by Florent Xicluna florent.xicl...@gmail.com:
--
keywords: +3.3regression
nosy: +flox, haypo
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17137
___
Changes by Georg Brandl ge...@python.org:
--
priority: normal - high
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17137
___
___
Python-bugs-list
Changes by STINNER Victor victor.stin...@gmail.com:
--
components: +Unicode, Windows
nosy: +ezio.melotti
versions: +Python 3.4
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17137
___
STINNER Victor added the comment:
On Windows, os.path.isdir calls nt._isdir(). Core of this C function:
wchar_t *wpath = PyUnicode_AsUnicode(po);
if (wpath == NULL)
return NULL;
attributes = GetFileAttributesW(wpath);
if (attributes ==
27 matches
Mail list logo