Re: [Python-Dev] Unicode support of the curses module in Python 3.3

2012-09-02 Thread Victor Stinner
>> For example, if the Python curses module is not linked to libncursesw,
>> get_wch() is not available and addch("é") raises an OverflowError if
>> the locale encoding is UTF-8 (because "é".encode("utf-8") is longer
>> than 1 byte).
>
> OverflowError? That is very surprising. I wouldn't guess that calling
> addch could raise OverflowError.
>
> Could you use a less surprising exception, or at least make sure that
> it is clearly and obviously documented?

Which exception would you expect? ValueError? Another error?

I used the same exception for addch(int) and addch(str). addch(int)
already raises an OverflowError on Python 3.2 if the value doesn't fit
in a C long type (which may be bigger than chtype, Python 3.3 is more
strict), so applications don't need to be changed for the "new" error
(on addch(str)).

Victor
___
Python-Dev mailing list
[email protected]
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-ideas] itertools.chunks(iterable, size, fill=None)

2012-09-02 Thread anatoly techtonik
On Sat, Sep 1, 2012 at 5:42 PM, Miki Tebeka  wrote:
> See the "grouper" example in http://docs.python.org/library/itertools.html

As was discussed before, the problem is visibility of the solution,
not the implementation. If we can divide core Python API into levels
where 0 is the less important and 10 is more, then `chunks` should be
level above than it is now.
--
anatoly t.
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Should 2to3 convert Exceptions from

2012-09-02 Thread anatoly techtonik
I work offline from remote location about 2000m above the sea level. There
is no internet connection here, so I can not use tracker online. I need a
Python editor here, and I have Spyder checkout. The problem is that my
installation has only Python3. I've tried using 2to3 from setup.py
(attached), but it fails when I execute:

$ sudo python3 setup.py install

stderr.log and stdout.log are attached. Is it the intended behavior?
It is also hard find "Porting Python 2 Code to Python 3" article, because
it is not referenced from "Porting to Python 3.x" chapters.



-- 
-- 
anatoly t.
# -*- coding: utf-8 -*-
#
# Copyright © 2009-2010 Pierre Raybaut
# Licensed under the terms of the MIT License
# (see spyderlib/__init__.py for details)

"""
Spyder
==

The Scientific PYthon Development EnviRonment
"""

from distutils.core import setup
from distutils.command.build import build
try: # Python 3
  from distutils.command.build_py import build_py_2to3 as build_py
except ImportError: # Python 2
  from distutils.command.build_py import build_py

import os
import os.path as osp
import sys

try:
from sphinx import setup_command as sphinx_setup_command
except ImportError:
sphinx_setup_command = False
sys.stderr.write("Sphinx not installed. Documentation won't be built.\n")


def get_package_data(name, extlist):
"""Return data files for package *name* with extensions in *extlist*"""
flist = []
# Workaround to replace os.path.relpath (not available until Python 2.6):
offset = len(name)+len(os.pathsep)
for dirpath, _dirnames, filenames in os.walk(name):
for fname in filenames:
if not fname.startswith('.') and osp.splitext(fname)[1] in extlist:
flist.append(osp.join(dirpath, fname)[offset:])
return flist


def get_subpackages(name):
"""Return subpackages of package *name*"""
splist = []
for dirpath, _dirnames, _filenames in os.walk(name):
if osp.isfile(osp.join(dirpath, '__init__.py')):
splist.append(".".join(dirpath.split(os.sep)))
return splist


# for 2to3
cmdclass = {'build_py':build_py}

# Sphinx build (documentation)
if sphinx_setup_command:
class MyBuild(build):
def has_doc(self):
setup_dir = os.path.dirname(os.path.abspath(__file__))
return os.path.isdir(os.path.join(setup_dir, 'doc'))
sub_commands = build.sub_commands + [('build_doc', has_doc)]


class MyBuildDoc(sphinx_setup_command.BuildDoc):
def run(self):
build = self.get_finalized_command('build')
sys.path.insert(0, os.path.abspath(build.build_lib))
dirname = self.distribution.get_command_obj('build').build_purelib
self.builder_target_dir = osp.join(dirname, 'spyderlib', 'doc')
try:
setup_command.BuildDoc.run(self)
except UnicodeDecodeError:
sys.stderr.write(   "ERROR: unable to build documentation "\
"because Sphinx do not handle source path "\
"with non-ASCII characters. Please try to "\
"move the source package to another location "\
"(path with *only* ASCII characters).\n")
sys.path.pop(0)

cmdclass.update( {'build': MyBuild, 'build_doc': MyBuildDoc} )


NAME = 'spyder'
LIBNAME = 'spyderlib'
from spyderlib import __version__, __project_url__


def get_packages():
"""Return package list"""
packages = get_subpackages(LIBNAME)+get_subpackages('spyderplugins')
if os.name == 'nt':
# Adding pyflakes and rope to the package if available in the 
# repository (this is not conventional but Spyder really need 
# those tools and there is not decent package manager on 
# Windows platforms, so...)
for name in ('rope', 'pyflakes'):
if osp.isdir(name):
packages += get_subpackages(name)
return packages


setup(name=NAME,
  version=__version__,
  description='Scientific PYthon Development EnviRonment',
  long_description=\
"""The spyderlib library includes Spyder, a free open-source Python 
development environment providing MATLAB-like features in a simple 
and light-weighted software.
It also provides ready-to-use pure-Python widgets to your PyQt4 or 
PySide application: source code editor with syntax highlighting and 
code introspection/analysis features, NumPy array editor, dictionary 
editor, Python console, etc.""",
  download_url='%s/files/%s-%s.zip' % (__project_url__, NAME, __version__),
  author="Pierre Raybaut",
  url=__project_url__,
  license='MIT',
  keywords='PyQt4 PySide editor shell console widgets IDE',
  platforms=['any'],
  packages=get_packages(),
  package_data={LIBNAME:
get_package_data(LIBNAME, ('.mo', '.svg', '.png', '.css',
   '.html', '.js')),

Re: [Python-Dev] Should 2to3 convert Exceptions from

2012-09-02 Thread Lennart Regebro
Switched from python-dev to python-porting.

On Sun, Sep 2, 2012 at 9:48 PM, anatoly techtonik  wrote:
> I work offline from remote location about 2000m above the sea level. There
> is no internet connection here, so I can not use tracker online. I need a
> Python editor here, and I have Spyder checkout. The problem is that my
> installation has only Python3. I've tried using 2to3 from setup.py
> (attached), but it fails when I execute:
>
> $ sudo python3 setup.py install
>
> stderr.log and stdout.log are attached. Is it the intended behavior?
> It is also hard find "Porting Python 2 Code to Python 3" article, because it
> is not referenced from "Porting to Python 3.x" chapters.

2to3 has not been run on the code that gives you errors. The traceback
seems incomplete, and gives no indication of where in the install you
get the errors. From the stdout it seems like it just installs the
code without using 2to3.

The only idea I have at this moment i sto make sure that the build
directories are empty.

//Lennart
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com