[issue46562] Add typeof or enum behavior in the typing module

2022-01-28 Thread Pedro Torres


Change by Pedro Torres :


--
title: Add typeof or enum behavior for in the Typing module -> Add typeof or 
enum behavior in the typing module

___
Python tracker 
<https://bugs.python.org/issue46562>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46562] Add typeof or enum behavior for in the Typing module

2022-01-28 Thread Pedro Torres


Change by Pedro Torres :


--
title: Add typeof or eum behavior for in the Typing module -> Add typeof or 
enum behavior for in the Typing module

___
Python tracker 
<https://bugs.python.org/issue46562>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46562] Add typeof or eum behavior for in the Typing module

2022-01-28 Thread Pedro Torres


New submission from Pedro Torres :

Currently, the addition of Annotated in PEP 593 on Python 3.9 allows adding 
arbitrary metadata for type hints.

Let's consider the following

time_available_online: list[str] =
[
'1m',
'5m',
'1d'
]


```
Hour = Annotated(str, "time available online")

```

Another way to consider this is if the selection was an Enum, since we know the 
only available options that can be selected (ie. it is not all possible 'str', 
only the 'str' from a list, which can be defined by the user)

It would save time and simplify things if the following was possible.

---

from typing import Enum  # we save time by not making a duplicate Class, or 
converting a constant variable to a Class


```
Hour = Enum[time_available_online, "time available online"]
```

--
components: Library (Lib)
messages: 411995
nosy: Corfucinas
priority: normal
severity: normal
status: open
title: Add typeof or eum behavior for in the Typing module
type: enhancement
versions: Python 3.10

___
Python tracker 
<https://bugs.python.org/issue46562>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44954] Bug in float.fromhex

2021-08-20 Thread Pedro Gimeno


Pedro Gimeno  added the comment:

> @Pedro Thanks again for the report! Just out of curiosity, how did you manage 
> to find this?

I'm writing a C strtod implementation and I was adding corner cases to the unit 
testing (now published here: 
https://codeberg.org/pgimeno/ACSL/src/branch/master/tests/test-strtod.c). 
Sometimes I get confused by whether to add one or subtract one to the exponent 
as digits are moved, and since I have an interactive Python shell always open 
as a calculator, I used it to make sure that the test I was writing had the 
correct exponent. But the result I got was not the one I expected, and upon 
verification, I soon became convinced that it was a bug, so I dug a bit more 
(at first I didn't notice it only happened if the leading zero was left out) 
and finally submitted the bug.

Thanks for the quick fix, by the way.

--
resolution: fixed -> 
status: closed -> open
type: behavior -> 
versions:  -Python 3.10, Python 3.11

___
Python tracker 
<https://bugs.python.org/issue44954>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44954] Bug in float.fromhex

2021-08-19 Thread Pedro Gimeno


New submission from Pedro Gimeno :

>>> float.fromhex('0x0.8p-1074')
0.0
>>> float.fromhex('0x.8p-1074')
5e-324

One of them is obviously wrong. It's the second one, because:
- The smallest denormal is 0x1p-1074
- Therefore, 0x0.8p-1074 is a tie for rounding purposes.
- The digit in the last place is even because the number is zero, and there is 
a tie, which implies rounding down.

--
components: Library (Lib)
messages: 399909
nosy: pgimeno
priority: normal
severity: normal
status: open
title: Bug in float.fromhex
versions: Python 3.9

___
Python tracker 
<https://bugs.python.org/issue44954>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42382] No easy way to get the distribution which provided a importlib.metadata.EntryPoint

2020-12-06 Thread Pedro Algarvio


Pedro Algarvio  added the comment:

Our software uses a plug-in based approach.
Plugins are able to add/modify internal behavior, and, as part of bug 
submission process we have a CLI flag which provides information about the core 
app as well as any intervening plugins.

This is where we need to "map" an entry point to it's distribution, so we know 
the name and version of it to display on this report.

--

___
Python tracker 
<https://bugs.python.org/issue42382>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42382] No easy way to get the distribution which provided a importlib.metadata.EntryPoint

2020-11-17 Thread Pedro Algarvio


Pedro Algarvio  added the comment:

Guess I jumped too fast :)

Will the changes in CPythom be included in `importlib_metadata`?

--

___
Python tracker 
<https://bugs.python.org/issue42382>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42382] No easy way to get the distribution which provided a importlib.metadata.EntryPoint

2020-11-16 Thread Pedro Algarvio


Change by Pedro Algarvio :


--
keywords: +patch
pull_requests: +2
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/23334

___
Python tracker 
<https://bugs.python.org/issue42382>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42382] No easy way to get the distribution which provided a importlib.metadata.EntryPoint

2020-11-16 Thread Pedro Algarvio


New submission from Pedro Algarvio :

With `pkg_resources` an `EntryPoint` has a dist attribute which allows you to 
get the distribution that provided that specific entry-point, however, with 
`importlib.metafata` and `importlib_metadata` that's not an east task.

```python
USE_IMPORTLIB_METADATA_STDLIB = USE_IMPORTLIB_METADATA = False
try:
# Py3.8+
import importlib.metadata

USE_IMPORTLIB_METADATA_STDLIB = True
except ImportError:
# < Py3.8 backport package
import importlib_metadata

USE_IMPORTLIB_METADATA = True


def get_distribution_from_entry_point(entry_point):
loaded_entry_point = entry_point.load()
if isinstance(loaded_entry_point, types.ModuleType):
module_path = loaded_entry_point.__file__
else:
module_path = sys.modules[loaded_entry_point.__module__].__file__
if USE_IMPORTLIB_METADATA_STDLIB:
distributions = importlib.metadata.distributions
else:
distributions = importlib_metadata.distributions

for distribution in distributions():
try:
relative = pathlib.Path(module_path).relative_to(
distribution.locate_file("")
)
except ValueError:
pass
else:
if relative in distribution.files:
return distribution
```

The above solution has the additional drawback that you're iterating the 
distributions list, once per EntryPoint, which, was already iterated to get the 
entry-points listing.

I propose we attach the Distribution instance to each of the found EntryPoint 
to avoid this low performance workaround.

I don't have an issue with providing a pull-request, but should that pull 
request be done against `importlib_metadata` or `importlib.metadata`?

--
components: Library (Lib)
messages: 381211
nosy: jaraco, s0undt3ch
priority: normal
severity: normal
status: open
title: No easy way to get the distribution which provided a 
importlib.metadata.EntryPoint
type: enhancement

___
Python tracker 
<https://bugs.python.org/issue42382>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38263] [Windows] multiprocessing: DupHandle.detach() race condition on DuplicateHandle(DUPLICATE_CLOSE_SOURCE)

2020-02-22 Thread Pedro Algarvio

Pedro Algarvio  added the comment:

What I'm able to copy from the console(though I doubt I'm getting all of
the traceback):

Traceback (most recent call last):

  File "", line 1, in 

  File
"c:\hostedtoolcache\windows\python\3.5.4\x64\lib\multiprocessing\spawn.py",
line 106, in spawn_main

exitcode = _main(fd)

  File
"c:\hostedtoolcache\windows\python\3.5.4\x64\lib\multiprocessing\spawn.py",
line 116, in _main

self = pickle.load(from_parent)

  File
"c:\hostedtoolcache\windows\python\3.5.4\x64\lib\multiprocessing\connection.py",
line 942, in rebuild_pipe_connection

handle = dh.detach()

  File
"c:\hostedtoolcache\windows\python\3.5.4\x64\lib\multiprocessing\reduction.py",
line 128, in detach

self._access, False, _winapi.DUPLICATE_CLOSE_SOURCE)

PermissionError: [WinError 5] Access is denied

Pedro Algarvio @ Phone

A sábado, 22/02/2020, 13:44, Eryk Sun  escreveu:

>
> Eryk Sun  added the comment:
>
> > I seem to be consistingly hitting this issue.
>
> It will help with test development if you can provide a minimal example
> that reliably reproduces the problem.
>
> In msg353064 I see DuplicateHandle calls failing with ERROR_ACCESS_DENIED
> (5). Assuming the process handles have the required PROCESS_DUP_HANDLE
> access, it's most likely the case that the underlying NtDuplicateObject
> system call is failing with STATUS_PROCESS_IS_TERMINATING (0xC10A). For
> example:
>
> import ctypes
> ntdll = ctypes.WinDLL('ntdll')
> from subprocess import Popen, PIPE
> from _winapi import GetCurrentProcess, TerminateProcess
> from _winapi import DuplicateHandle, DUPLICATE_SAME_ACCESS
>
> p = Popen('cmd.exe', stdin=PIPE, stdout=PIPE, stderr=PIPE)
> TerminateProcess(p._handle, 0)
>
> Try to duplicate the process handle into the terminated process:
>
> >>> source = GetCurrentProcess()
> >>> target = handle = p._handle
> >>> try:
> ... DuplicateHandle(source, handle, target,
> ... 0, False, DUPLICATE_SAME_ACCESS)
> ... except:
> ... status = ntdll.RtlGetLastNtStatus()
> ... print(f'NTSTATUS: {status & (2**32-1):#010x}')
> ... raise
> ...
> NTSTATUS: 0xc10a
> Traceback (most recent call last):
>   File "", line 2, in 
> PermissionError: [WinError 5] Access is denied
>
> --
> nosy: +eryksun
>
> ___
> Python tracker 
> <https://bugs.python.org/issue38263>
> ___
>

--

___
Python tracker 
<https://bugs.python.org/issue38263>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38263] [Windows] multiprocessing: DupHandle.detach() race condition on DuplicateHandle(DUPLICATE_CLOSE_SOURCE)

2020-02-22 Thread Pedro Algarvio


Pedro Algarvio  added the comment:

Any possible workaround for this issue?
I seem to be consistingly hitting this issue.

--
nosy: +s0undt3ch

___
Python tracker 
<https://bugs.python.org/issue38263>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38800] Resume position for UTF-8 codec error handler not working

2019-11-14 Thread Pedro Gimeno


Pedro Gimeno  added the comment:

Python 3.5 from Debian stretch (oldstable). You're right, I can't reproduce it 
in 3.7 from Buster. Sorry for the bogus report.

--

___
Python tracker 
<https://bugs.python.org/issue38800>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38800] Resume position for UTF-8 codec error handler not working

2019-11-14 Thread Pedro Gimeno


Pedro Gimeno  added the comment:

I forgot the quotes in the assertion, it should have been "b'xz'".

--

___
Python tracker 
<https://bugs.python.org/issue38800>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38800] Resume position for UTF-8 codec error handler not working

2019-11-14 Thread Pedro Gimeno


New submission from Pedro Gimeno :

When implementing an error handler, it must return a tuple consisting of a 
substitution string and a position where to resume decoding. In the case of the 
UTF-8 codec, the resume position is ignored, and it always resumes immediately 
after the character that caused the error.

To reproduce, use this code:

import codecs
codecs.register_error('err', lambda err: (b'x', err.end + 1))
assert repr(u'\uDD00yz'.encode('utf8', errors='err')) == b'xz'

The above code fails the assertion because the result is b'xyz'.

It works OK for some other codecs. I have not tried to make an exhaustive list 
of which ones work and which ones don't, therefore this problem might apply to 
others.

--
messages: 356610
nosy: pgimeno
priority: normal
severity: normal
status: open
title: Resume position for UTF-8 codec error handler not working
type: behavior

___
Python tracker 
<https://bugs.python.org/issue38800>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22253] ConfigParser does not handle files without sections

2019-11-05 Thread Pedro Lacerda


Pedro Lacerda  added the comment:

Hi, there is a working PR at https://github.com/python/cpython/pull/2735. 

I was in doubt about get the default section with `__init__(..., 
allow_unnamed_section=True)` and `config.get('', 'option')` or with 
`config.get(DEFAULT_SECTION, 'option')`. I'd prefer the later.

--

___
Python tracker 
<https://bugs.python.org/issue22253>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35135] pip install --download option does not exist

2018-11-01 Thread Pedro


New submission from Pedro :

https://pip.pypa.io/en/stable/user_guide/#installing-from-local-packages states 
that you can use a --directory option with the install subcommand. This fails 
with pip 18.1 on both Python 2.7 on SLES12 and Python 3.6 on Windows 10:

==

pip install --download my_dir -r reqs.txt

Usage:
  pip install [options]  [package-index-options] ...
  pip install [options] -r  [package-index-options] ...
  pip install [options] [-e]  ...
  pip install [options] [-e]  ...
  pip install [options]  ...

no such option: --download

--
assignee: docs@python
components: Documentation
messages: 329069
nosy: docs@python, pgacv2
priority: normal
severity: normal
status: open
title: pip install --download option does not exist
type: behavior
versions: Python 2.7, Python 3.6

___
Python tracker 
<https://bugs.python.org/issue35135>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32846] Deletion of large sets of strings is extra slow

2018-02-17 Thread Luis Pedro Coelho

Luis Pedro Coelho <l...@luispedro.org> added the comment:

I think some of this conversation is going off-topic, but there is no 
disk-swapping in my case.

I realize ours is not a typical setup, but our normal machines have 256GB of 
RAM and the "big memory" compute nodes are >=1TB. Normally, swap is outright 
disabled.

This really is an impressive case study on how much difference cache-locality 
can make.

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32846>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32846] Deletion of large sets of strings is extra slow

2018-02-16 Thread Luís Pedro Coelho

Luís Pedro Coelho <l...@luispedro.org> added the comment:

Original poster here.

The benchmark is artificial, but the problem setting is not. I did have a 
problem that is roughly:

interesting = set(line.strip() for line in open(...))
for line in open(...):
key,rest = line.split('\t', 1)
if key in interesting:
 process(rest)

Deleting the set (when it goes out of scope) was a significant chunk of the 
time. Surprisingly, deleting a very large set takes much longer than creating 
it.

Here are my controlled measurements (created with the attached script, which 
itself uses Jug http://jug.rtfd.io and assumes a file `input.txt` is present).


Ncreate (s) delete (s)
   1 0.00 0.00
  10 0.00 0.00
 100 0.00 0.00
1000 0.00 0.00
   1 0.01 0.00
  10 0.15 0.01
 100 1.14 0.12
100011.44 2.24
   1   126.4170.34
   2   198.04   258.44
   3   341.27   646.81
   4   522.70  1044.97
   5   564.07  1744.54
   6  1380.04  3364.06
   7  1797.82  3300.20
   8  1294.20  4410.22
   9  3045.38  7646.59
  10  3467.31 11042.97
  11  5162.35 13750.22
  12  6581.90 12544.67
  13  1612.60 17204.67
  14  1788.13 23772.84
  15  6922.16 25068.49

--
nosy: +l...@luispedro.org
Added file: https://bugs.python.org/file47448/time-set.py

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32846>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32789] Note missing from logging.debug() docs

2018-02-07 Thread Pedro

Pedro <pgacv2+pythonb...@gmail.com> added the comment:

Might be cleaner to just say, "The arguments are interpreted as for 
debug/info/warning/error/critical/exception/log," but with the bookmark URL 
pointing to the Logger methods.

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32789>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32789] Note missing from logging.debug() docs

2018-02-07 Thread Pedro

New submission from Pedro <pgacv2+pythonb...@gmail.com>:

The docs for Logger.debug() 
(https://docs.python.org/3/library/logging.html#logging.Logger.debug) specify 
that exc_info can take an exception instance as of version 3.5.

However, the docs for logging.debug() 
(https://docs.python.org/3/library/logging.html#logging.debug) do not, even 
though logging.debug() redirects to an instance of Logger and so can take the 
same types of arguments.

--
assignee: docs@python
components: Documentation
messages: 311792
nosy: docs@python, pgacv2
priority: normal
severity: normal
status: open
title: Note missing from logging.debug() docs
type: enhancement
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32789>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32573] All sys attributes (.argv, ...) should exist in embedded environments

2018-01-19 Thread Pedro

Pedro <pgacv2+pythonb...@gmail.com> added the comment:

I agree that an empty list, instead of a list with an empty string, makes more 
sense. Leaving _xoptions as {} would be the same as when it runs non-embedded 
without any -X arguments, but I guess there's no way of making {} any more 
empty.

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32573>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32573] sys.argv documentation should include caveat for embedded environments

2018-01-16 Thread Pedro

Pedro <pgacv2+pythonb...@gmail.com> added the comment:

My comment above uses "code that we provide for supporting embedding," not 
"third party code," as the definition of embedded.

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32573>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32573] sys.argv documentation should include caveat for embedded environments

2018-01-16 Thread Pedro

Pedro <pgacv2+pythonb...@gmail.com> added the comment:

My first inclination would be no. An argv value of [''] means "zero 
command-line arguments" (not even a filename), which implies the following as 
far as I know:
1. Python was called as an executable rather than a library, because you can't 
pass command-line arguments to a library
2. No arguments were passed to the executable
3. You are running from inside the REPL

All three are false in an embedded context.

A not-much-better-but-maybe-worth-considering question might also be: should 
scripts be able to tell whether they are being run from an embedded 
interpreter? If so, do they have any other way of doing so if an initialization 
is forced for argv?

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32573>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32573] sys.argv documentation should include caveat for embedded environments

2018-01-16 Thread Pedro

New submission from Pedro <pgacv2+pythonb...@gmail.com>:

Embedded Python interpreters, such as Boost.Python, do not have sys.argv 
available. (sys itself works fine.) This causes the interpreter to crash with 
the following exception when you try to access argv:

AttributeError: 'module' object has no attribute 'argv'

I'm not sure how closely related this is to #15577 or PEP 432. A simple 
workaround is to manually assign a list with an empty string to argv, as 
suggested by https://github.com/google/oauth2client/issues/642. However, the 
documentation for the sys module makes no mention of this special case for 
argv, and the line at the top that says "It is always available" can easily be 
interpreted to mean that *all* of sys's attributes will always be available. I 
suggest adding the following to the documentation for sys.argv:



Since `argv` contains the list of **command line** arguments passed to the 
Python interpreter, `argv` is not available within embedded interpreters, and 
scripts that run in embedded environments will raise an `AttributeError` when 
they attempt to access `argv`. As a workaround, assign a list with an empty 
string manually:
```
import sys

if not hasattr(sys, 'argv'):
sys.argv  = ['']
```

--
assignee: docs@python
components: Documentation
messages: 310105
nosy: docs@python, pgacv2
priority: normal
severity: normal
status: open
title: sys.argv documentation should include caveat for embedded environments
type: enhancement
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32573>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32054] Creating RPM on Python 2 works, but Python 3 fails because of sys.implementation.cache_tag

2017-11-16 Thread Pedro

New submission from Pedro <pgacv2+pythonb...@gmail.com>:

I am trying to create an RPM on SLES12 SP2. (I think that corresponds to 
OpenSUSE 42.2.) This is my setup.py file, nothing special:

import setuptools
setuptools.setup(name='MyApp',
 version='1.2.3',
 options={'bdist_rpm': {'post_install': 'post_install.sh',
'post_uninstall': 
'post_uninstall.sh'}})

Running `python setup.py bdist_rpm` with Python 2 works. However, running 
`python3 setup.py bdist_rpm` outputs the following:

running bdist_rpm
running egg_info
writing top-level names to MyApp.egg-info/top_level.txt

...

byte-compiling 
/home/pedro/MyApp/build/bdist.linux-x86_64/rpm/BUILDROOT/MyApp-1.2.3-1.x86_64/usr/lib/python3.4/site-packages/MyApp/my_file.py
 to my_file.cpython-34.pyc

...

Processing files: MyApp-1.2.3-1.noarch
error: File not found: 
/home/pedro/MyApp/build/bdist.linux-x86_64/rpm/BUILDROOT/MyApp-1.2.3-1.x86_64/usr/lib/python3.4/site-packages/MyApp/my_file.py

RPM build errors:
File not found: 
/home/pedro/MyApp/build/bdist.linux-x86_64/rpm/BUILDROOT/MyApp-1.2.3-1.x86_64/usr/lib/python3.4/site-packages/MyApp/my_file.py
error: command 'rpmbuild' failed with exit status 1

The problem appears to be that setuptools is generating a file that ends in 
`.cpython-34.pyc`, and later looks for a file without the `.cpython-34` but 
can't find it.

The RPM generation process on Python 3 goes through 
`distutils.util.byte_compile()`, which in turn calls 
`importlib.util.cache_from_source(path)`, where `path` is the file to be 
byte-compiled. `cache_from_source()` injects the value of 
`sys.implementation.cache_tag` (which is equal to 'cpython-34' on SLES12 SP2) 
into the filename of the compiled file. This attribute of `sys` does not exist 
in Python 2. So it looks like `setuptools` alters the filename with that tag 
during byte compilation, but later forgets that it modified the filename and 
fails because it's looking for the original name.

I ended up working around this by patching `distutils.file_util.write_file` to 
eliminate the .pyc entries from INSTALLED_FILES:

orig_bytecode_var = os.environ.get('PYTHONDONTWRITEBYTECODE', '')
os.environ['PYTHONDONTWRITEBYTECODE'] = '1'
orig_write_file = distutils.file_util.write_file

def my_patch(*args, **kwargs):
new_args = list(args)
if args[0] == 'INSTALLED_FILES':
new_args[1] = [fname for fname in args[1] if fname[-4:] not in 
('.pyc', '.pyo')]
orig_write_file(*new_args, **kwargs)
distutils.file_util.write_file = my_patch

setuptools.setup(name='MyApp',
 version='1.2.3',
 options={'bdist_rpm': {'post_install': 'post_install.sh',
'post_uninstall': 
'post_uninstall.sh'}})

os.environ['PYTHONDONTWRITEBYTECODE'] = orig_bytecode_var
distutils.file_util.write_file = orig_write_file


But I don't think I should have to do anything special to build an RPM on 
Python 3 vs. Python 2. Is this expected behavior?

--
components: Distutils
messages: 306400
nosy: dstufft, eric.araujo, pgacv2
priority: normal
severity: normal
status: open
title: Creating RPM on Python 2 works, but Python 3 fails because of 
sys.implementation.cache_tag
type: behavior
versions: Python 3.4

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32054>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27268] Incorrect error message on float('')

2017-07-17 Thread Pedro Lacerda

Changes by Pedro Lacerda <pslace...@gmail.com>:


--
pull_requests: +2805

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27268>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22253] ConfigParser does not handle files without sections

2017-07-16 Thread Pedro Lacerda

Pedro Lacerda added the comment:

Thank you 林自均! I just made a pull-request with the relevant bits.

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22253>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11588] Add "necessarily inclusive" groups to argparse

2017-05-26 Thread Pedro

Pedro added the comment:

Just voicing my support for this. I was also looking for a solution on 
StackOverflow and ended up here.

--
nosy: +pgacv2

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11588>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30220] Why are custom messages for ValueError, TypeError suppressed in argparse?

2017-05-05 Thread Pedro

Pedro added the comment:

Paul,

There are a number of scenarios in which you need to check a value and not just 
a type. For instance, I have a tool with several command-line arguments that 
need to be *nonnegative* integers, and a call to int() would not catch that. 
Many other utilities that ask for an argument of "how many times do you want to 
do X?" only make sense if you provide a nonnegative number.

Entering dates is another one. There is no callable in the datetime module or 
built-in that takes only one argument that can be used to validate a date. And 
if you write your own, you may need to make sure the date is within a specified 
range: only in the future, only in the past, no more/fewer than X days away 
from today, etc. My tool receives a date to execute a database query in the 
form of "select * from table where created_date >= argument_date." I can 
perform the validation further into the script, but performing as much 
validation up front when the arguments are parsed allows you to fail more 
quickly in the case of invalid input.

I can understand that ArgumentTypeError is available to be used when there is a 
problem with the arguments' type. But disallowing the use of custom messages in 
TypeError and ValueError seems like an arbitrary restriction with no pros and 
at least some cons. I assume that this was not an arbitrary decision and there 
really was a reason for it, but I can't see what that reason is.

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30220>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30220] Why are the custom messages for ValueError and TypeError suppressed in argparse?

2017-05-01 Thread Pedro

Pedro added the comment:

You can get around the message suppression by raising anything that isn't a 
ValueError, TypeError, or subclass thereof. It will propagate up past 
_get_value(). I still don't see the reason for giving special treatment to 
ValueError and TypeError.

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30220>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30220] Why are the custom messages for ValueError and TypeError suppressed in argparse?

2017-05-01 Thread Pedro

New submission from Pedro:

ArgumentParser._get_value() has two exception handlers: one for 
ArgumentTypeError, and one for (TypeError, ValueError). But in the latter case, 
any custom message I include the TypeError or ValueError is ignored and 
replaced with a generic "invalid value" message.

I don't see why the module wouldn't first check for a custom message in a 
TypeError or ValueError exception, as it does for ArgumentTypeError, and only 
use the generic message if a custom one is not specified. The current behavior 
does not let you to give the user a detailed reason for the exception unless 
you raise ArgumentTypeError, which is considered an implementation detail as 
mentioned in #20039, and also doesn't feel right for errors that are not 
related to the argument's type.


Code to reproduce:

import argparse

def nonnegative_not_suppressed(arg):
  try:
x = int(arg)
if x >= 0:
  return x
else:
  raise argparse.ArgumentTypeError('Enter a nonnegative integer')
  except:
raise argparse.ArgumentTypeError('Enter a nonnegative integer')

def nonnegative_suppressed(arg):
  try:
x = int(arg)
if x >= 0:
  return x
else:
  raise ValueError('Enter a nonnegative integer')
  except:
raise ValueError('Enter a nonnegative integer')

p = argparse.ArgumentParser('parser')
p.add_argument('--no-suppress', type=nonnegative_not_suppressed)
p.add_argument('--suppress', type=nonnegative_suppressed)
p.parse_args(['--no-suppress', '-4']) # Displays "Enter a nonnegative integer"
p.parse_args(['--suppress', '-4']) # Displays "invalid nonnegative_suppressed 
value: '-4'"

--
components: Extension Modules
messages: 292669
nosy: pgacv2
priority: normal
severity: normal
status: open
title: Why are the custom messages for ValueError and TypeError suppressed in 
argparse?
type: enhancement
versions: Python 3.5

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30220>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29632] argparse values for action in add_argument() should be flags instead of (or in addition to) strings

2017-03-24 Thread Pedro

Changes by Pedro <pgacv2+pythonb...@gmail.com>:


--
resolution:  -> wont fix
stage:  -> resolved
status: open -> closed

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29632>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29632] argparse values for action in add_argument() should be flags instead of (or in addition to) strings

2017-03-24 Thread Pedro

Pedro added the comment:

I guess I'm a little allergic to magic strings. I think there is value in 
greater consistency across modules, but agree it's not a big deal because the 
Action classes are already accessible that way.

I was unaware of the details behind `action` and actually just found an 
opportunity to use an Action subclass, so thank you for clarifying.

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29632>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29632] argparse values for action in add_argument() should be flags instead of (or in addition to) strings

2017-02-23 Thread Pedro

New submission from Pedro:

The possible values for action are currently:
'store'
'store_true'
'store_false'
'store_const'
'append'
'append_const'
'count'
'help'
'version'
a subclass of argparse.Action

The string values are evidently for backward compatibility with optparse. 
However, adding the ability to specify these options as flags would make 
argparse code more maintainable (e.g. IDEs are better at refactoring symbols 
than strings), bring it in line with other places where a module has built-in 
flags, like the regex module (re.MULTILINE, re.IGNORECASE, etc.), and expand 
the use of flags that already exist in argparse (e.g. argparse.SUPPRESS, 
argparse.REMAINDER).

The string values need not be immediately deprecated, but can be made available 
as the preferred option for new development. See, for example, getName() and 
setName() in the threading module, which are documented as follows: "Old 
getter/setter API for name; use it directly as a property instead." A similar 
suggestion can be provided for argparse flags: "Old action values for backward 
compatibility; use the flags instead."

--
messages: 288445
nosy: pgacv2
priority: normal
severity: normal
status: open
title: argparse values for action in add_argument() should be flags instead of 
(or in addition to) strings
type: enhancement
versions: Python 2.7, Python 3.6, Python 3.7

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29632>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29506] Incorrect documentation for the copy module

2017-02-09 Thread Pedro

Pedro added the comment:

"Because deepcopy copies everything it may copy too much, such as data which is 
intended to be shared (instead of duplicated) between copies."

A bit more explicit?

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29506>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29506] Incorrect documentation for the copy module

2017-02-08 Thread Pedro

New submission from Pedro:

The docs for the copy module contain a bullet that says the following:

"Because deep copy copies everything it may copy too much, e.g., even 
administrative data structures that should be shared even between copies."

There should be a "not" between "should" and "be shared." I think the second 
"even" can be dropped, too.

--
assignee: docs@python
components: Documentation
messages: 287367
nosy: docs@python, pgacv2
priority: normal
severity: normal
status: open
title: Incorrect documentation for the copy module
versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29506>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21423] concurrent.futures.ThreadPoolExecutor/ProcessPoolExecutor should accept an initializer argument

2016-10-30 Thread Pedro Algarvio

Pedro Algarvio added the comment:

Would also love to see this in the stdlib soon. My use case is logging 
setup(forward logs to the main process).

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue21423>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21423] concurrent.futures.ThreadPoolExecutor/ProcessPoolExecutor should accept an initializer argument

2016-10-30 Thread Pedro Algarvio

Changes by Pedro Algarvio <pe...@algarvio.me>:


--
nosy: +Pedro.Algarvio

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue21423>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27258] Exception in BytesGenerator.flatten

2016-06-18 Thread Pedro Lacerda

Pedro Lacerda added the comment:

Now the file is back! If any previous header has a newline before the value the 
error will not happen. But even with the output correct it isn't as expected.

--
Added file: http://bugs.python.org/file43457/flatten-no-exception.mail

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27258>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27258] Exception in BytesGenerator.flatten

2016-06-18 Thread Pedro Lacerda

Pedro Lacerda added the comment:

Now the file is back! If any previous header has a newline before the value the 
error will not happen. But even with the output correct it isn't as expected.

--
Added file: http://bugs.python.org/file43456/flatten-no-exception.mail

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27258>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27258] Exception in BytesGenerator.flatten

2016-06-17 Thread Pedro Lacerda

Pedro Lacerda added the comment:

Seems that ``token.has_fws`` evaluates to True in the following condition

if token.has_fws:

causing ``token._fold(self)`` where isn't needed and raising the exception. 
Hope it helps!

By the way, why the _header_value_parser.py was removed from the repository?
https://github.com/python/cpython/blob/master/Lib/email/_header_value_parser.py#L144

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27258>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27258] Exception in BytesGenerator.flatten

2016-06-16 Thread Pedro Lacerda

Pedro Lacerda added the comment:

I was unable to reproduce this bug using the following snippet

import email, sys
from email.generator import BytesGenerator
from email.mime.text import MIMEText

fp = open('flatten-exception.mail', 'rb')
email.message_from_binary_file(fp)
bs = BytesGenerator(sys.stdout.buffer)
bs.flatten(MIMEText('msg', 'plain', 'utf-8'))

--
nosy: +Pedro Lacerda

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27258>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27268] Incorrect error message on float('')

2016-06-16 Thread Pedro Lacerda

Pedro Lacerda added the comment:

Following the bug pointed by Adam and Eryk.

--
keywords: +patch
nosy: +Pedro Lacerda
Added file: http://bugs.python.org/file43405/float.patch

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27268>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26836] Add memfd_create to os module

2016-06-16 Thread Pedro Lacerda

Pedro Lacerda added the comment:

Maybe useful at mmapmodule.c replacing

/* SVR4 method to map anonymous memory is to open /dev/zero */
fd = devzero = _Py_open("/dev/zero", O_RDWR);

tagname is unused at UNIX version of new_mmap_object() so if provided something 
like could be added for Linux only
fd = memfd_create(tagname, O_RDWR);

--
nosy: +Pedro Lacerda

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26836>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27320] ./setup.py --help-commands should sort extra commands

2016-06-15 Thread Pedro Lacerda

Pedro Lacerda added the comment:

Please look if these simple patches are acceptable. I don't know if standard 
commands are already in a sane order or if it also need to be sorted.

--
keywords: +patch
nosy: +Pedro Lacerda
Added file: http://bugs.python.org/file43402/sortextra.patch

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27320>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27320] ./setup.py --help-commands should sort extra commands

2016-06-15 Thread Pedro Lacerda

Changes by Pedro Lacerda <pslace...@gmail.com>:


Added file: http://bugs.python.org/file43403/sortcommands.patch

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27320>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22253] ConfigParser does not handle files without sections

2016-06-11 Thread Pedro Lacerda

Pedro Lacerda added the comment:

I also never found a mixture of sectionless options followed by sectioned 
options. So an unnamed section that is also the DEFAULTSECTION will probably 
work.

In this patch when `default_section=None` is passed to `RawConfigParser` it 
will parse top level options into the default section and skip writing its 
title.

As drawback, default options is not showed in `options()` or `has_section()` 
reducing it usefulness. It works with `items()` and `keys()` however.

> Using DEFAULTSECT for this purpose is equally wrong since it would
> silently inject default values to every section

I disagree with that because I really *never* found in wild a file where it 
will happen.

> All in all, it comes down to the question whether the programmer
> expects section-less configuration. If not, the '' section will not be 
> helpful anyway. If yes, then it's desirable to be able to specify a
> section name for global options at *read time*.

Pass a name at read time will improve the API as `sections()` and 
`has_section()` will work as usual and not like a DEFAULTSECTION.

Please look my patch and tell if it's acceptable, if you prefer that a section 
name must be given at read and write time we can manage it.

It's my first post in this tracker and I'm very glad that I got it working even 
if not merged!

--
keywords: +patch
nosy: +Pedro Lacerda
versions:  -Python 3.5
Added file: http://bugs.python.org/file43345/nosection.patch

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22253>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2506] Add mechanism to disable optimizations

2014-06-22 Thread Pedro Gimeno

Pedro Gimeno added the comment:

I consider peephole optimization when no optimization was requested a bug.

Documentation for -O says it Turns on basic optimizations. Peephole 
optimization is a basic optimization, yet it is performed even when no basic 
optimizations were requested.

No need to add a switch. Just don't optimize if not requested.

--
nosy: +pgimeno

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue2506
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7300] Unicode arguments in str.format()

2012-12-30 Thread Pedro Algarvio

Pedro Algarvio added the comment:

This is not a 2.7 issue only:

 import sys
 sys.version_info
(2, 6, 5, 'final', 0
 'Foo {0}'.format(u'bár')
Traceback (most recent call last):
  File stdin, line 1, in module
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 1: 
ordinal not in range(128)


--
nosy: +Pedro.Algarvio

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7300
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15853] IDLE crashes selecting Preferences menu with OS X ActiveState Tcl/Tk 8.5.12.1

2012-10-21 Thread Pedro Meirelles

Pedro Meirelles added the comment:

Hello,

I am biologist I am just starting to learn Python.

I have a mac and I am using OS X 10.8.2. I have installed Python 2.7.3 and when 
I try to copy and paste (use command) or go to preferences IDLE crashes. I did 
what Ned Deily said in msg169739:

sudo mv /Library/Frameworks/Tk.framework /Library/Frameworks/Tk_disabled

It worked. Now I can copy and paste in IDLE. But when I type quots ( or ') it 
crashes. 

What you think I can do to work in IDLE using both command and typing  and '?

Sorry if my question is too elementary.

I appreciate a lot all the comments and answers. It is very useful and 
enlightening.

Kind regards

--
nosy: +pedrommeirelles

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15853
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15853] IDLE crashes selecting Preferences menu with OS X ActiveState Tcl/Tk 8.5.12.1

2012-10-21 Thread Pedro Meirelles

Pedro Meirelles added the comment:

Thank you very much, Ned!

It worked, awesome!

All the best

2012/10/20 Ned Deily rep...@bugs.python.org


 Ned Deily added the comment:

 Pedro, try installing the older ActiveTcl 8.5.11.1 from here:

 http://downloads.activestate.com/ActiveTcl/releases/8.5.11.1/

 It is not perfect but does not have the Preferences regression and does
 have fixes for crashes when typing composite input characters.

 --

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue15853
 ___


--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15853
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14670] subprocess.call with pipe character in argument

2012-04-25 Thread Pedro Larroy

New submission from Pedro Larroy pedro.lar...@gmail.com:

When running a command with pipe character as argument the result is not the 
same as in commandline

For example:

 subprocess.call([rC:\Program Files (x86)\Microsoft Visual Studio 10.0\Commo
n7\IDE\devenv,/build,rDebug|x64,gpc10.sln], shell=False)

Chockes on Debug|x64 and just exits with 1.

Running python 2.7.1  r271:86832

--
components: Windows
messages: 159322
nosy: Pedro.Larroy
priority: normal
severity: normal
status: open
title: subprocess.call with  pipe character in argument
type: behavior
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14670
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14256] test_logging fails if zlib is not present

2012-03-11 Thread Pedro Kroger

Pedro Kroger kro...@pedrokroger.net added the comment:

Attached patch to fix this issue.

--
keywords: +patch
nosy: +kroger
Added file: http://bugs.python.org/file24791/issue14256.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14256
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13796] use 'text=...' to define the text attribute of and xml.etree.ElementTree.Element

2012-01-18 Thread Pedro Andres Aranda Gutierrez

Pedro Andres Aranda Gutierrez paag...@gmail.com added the comment:

Thanks a lot again :-)
We have a saying here: you'll never go to sleep without having learnt
something new :-)

On Tue, Jan 17, 2012 at 4:11 PM, patrick vrijlandt
rep...@bugs.python.org wrote:

 patrick vrijlandt patrick.vrijla...@gmail.com added the comment:

 Hi,

 Did you look at lxml (http://lxml.de)?

 from lxml.builder import E
 from lxml import etree

 tree = etree.ElementTree(
    E.Hello(
        Good morning!,
        E.World(How do you do, humour = excellent),
        Fine,
        E.Goodbye(),
        ),
    )

 print(etree.tostring(tree, pretty_print=True).decode())

 # output, even more prettified

 Hello
    Good morning!
    World humour=excellent
          How do you do
    /World
          Fine
    Goodbye/
 /Hello

 By the way, your Element enhancement is buggy, because all newly create
 elements will share the same attrib dictionary (if attrib is not given).
 Notice that Donald Duck will be sad; by the time we print even Hello is sad.

 import xml.etree.ElementTree as etree

 class Element(etree.Element):
    def __init__(self, tag, attrib={}, **extra):
        super().__init__(tag)
        self.tag = tag
        self.attrib = attrib
        self.attrib.update(extra)
        self.text = self.attrib.pop('text', None)
        self.tail = self.attrib.pop('tail', None)
        self._children = []

 if __name__ == '__main__':

    test = Element('Hello',)
    test2 = Element('World',{'humour':'excelent'},text = 'How do you do',
 tail=Fine)
    test3 = Element('Goodbye', humour='sad')
    test4 = Element('Donaldduck')
    test.append(test2)
    test.append(test3)
    test.append(test4)
    tree = etree.ElementTree(test)
    print(etree.tostring(test, encoding=utf-8, method=xml))

 Hello humour=sad
    World humour=excelentHow do you do/WorldFine
    Goodbye humour=sad /
    Donaldduck humour=sad /
 /Hello'

 The correct idiom would be:

    def __init__(self, tag, attrib=None, **extra):
        if attrib is None:
            attrib = {}
        super().__init__(tag)

 Cheers,

 Patrick

 2012/1/16 Pedro Andres Aranda Gutierrez rep...@bugs.python.org


 Pedro Andres Aranda Gutierrez paag...@gmail.com added the comment:

 Touché :-)
 I was just frustrated because my XMLs never have tail or text as
 attributes and I wanted to have more compact code...

 On Mon, Jan 16, 2012 at 12:14 PM, patrick vrijlandt
 rep...@bugs.python.org wrote:
 
  patrick vrijlandt patrick.vrijla...@gmail.com added the comment:
 
  I agree the Element syntax is sometimes awkward.
 
  But how would you represent text or tail attributes within this enhanced
 element?
  animal name=cat tail=yes comes to mind ...
 
  --
  nosy: +patrick.vrijlandt
 
  ___
  Python tracker rep...@bugs.python.org
  http://bugs.python.org/issue13796
  ___

 --

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue13796
 ___


 --

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue13796
 ___

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13796
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13796] use 'text=...' to define the text attribute of and xml.etree.ElementTree.Element

2012-01-16 Thread Pedro Andres Aranda Gutierrez

Pedro Andres Aranda Gutierrez paag...@gmail.com added the comment:

Touché :-)
I was just frustrated because my XMLs never have tail or text as
attributes and I wanted to have more compact code...

On Mon, Jan 16, 2012 at 12:14 PM, patrick vrijlandt
rep...@bugs.python.org wrote:

 patrick vrijlandt patrick.vrijla...@gmail.com added the comment:

 I agree the Element syntax is sometimes awkward.

 But how would you represent text or tail attributes within this enhanced 
 element?
 animal name=cat tail=yes comes to mind ...

 --
 nosy: +patrick.vrijlandt

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue13796
 ___

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13796
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13795] CDATA Element missing

2012-01-15 Thread Pedro Andres Aranda Gutierrez

New submission from Pedro Andres Aranda Gutierrez paag...@gmail.com:

When creating ElementTree objects that hold SVG drawings, I need a CDATA object 
similar to the ProcessingInstruction object. There was a circumvention of the 
problem for Python 2.6:

http://stackoverflow.com/questions/174890/how-to-output-cdata-using-elementtree

This workaround doesn't work in Python 2.7 and above

--
messages: 151334
nosy: paaguti
priority: normal
severity: normal
status: open
title: CDATA Element missing
versions: Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13795
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13796] use 'text=...' to define the text attribute of and xml.etree.ElementTree.Element

2012-01-15 Thread Pedro Andres Aranda Gutierrez

New submission from Pedro Andres Aranda Gutierrez paag...@gmail.com:

I have extended the xml.etree.ElementTree.Element class and pass the text 
attribute in the arguments. This creates much more compact code:

import xml.etree.ElementTree as xml


class Element(xml.Element):
def __init__(self,tag,attrib={},**attrs):
super(xml.Element,self).__init__()
self.tag = tag
self.attrib = attrib
self.attrib.update(attrs)
self.text = self.attrib.pop('text',None)
self.tail = self.attrib.pop('tail',None)
self._children = []

if __name__ == '__main__':
from sys import stdout

test = Element('Hello',)
test2 = Element('World',{'humour':'excelent'},text = 'How do you do', 
tail=Fine)
test.append(test2)

xml.ElementTree(test).write(stdout,encoding=utf-8,xml_declaration=yes,method=xml)

--
messages: 151336
nosy: paaguti
priority: normal
severity: normal
status: open
title: use 'text=...' to define the text attribute of and 
xml.etree.ElementTree.Element
type: enhancement

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13796
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12651] -O2 or -O3? this brings excitement to computing!

2011-07-28 Thread Pedro Larroy

New submission from Pedro Larroy pedro.lar...@gmail.com:

When I build it compiles with both -O2 and -O3...

this is debian testing on amd64.

gcc -pthread -c -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall 
-Wstrict-prototypes  -I. -IInclude -I./Include   -DPy_BUILD_CORE -o 
Python/getcompiler.o Python/getcompiler.c

--
components: Build
messages: 141318
nosy: Pedro.Larroy
priority: normal
severity: normal
status: open
title: -O2 or -O3? this brings excitement to computing!
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12651
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9689] threading.Timer poorly documented

2010-08-25 Thread Pedro Mendes

New submission from Pedro Mendes pedrorm2...@gmail.com:

The documentation existent ( 
http://docs.python.org/library/threading.html#threading.Timer ) is not very 
helpful. The user is left wondering about the exact syntax of this function, 
what types of parameter it accepts etc. Could this possibly be fixed?

--
messages: 114941
nosy: pedro3005
priority: normal
severity: normal
status: open
title: threading.Timer poorly documented
type: feature request
versions: Python 2.5, Python 2.6, Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9689
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7704] Math calculation problem (1.6-1.0)0.6, python said TRUE

2010-01-14 Thread pedro flores

New submission from pedro flores pflore...@gmail.com:

this simple comparison (1.6-1.0)0.6 , python answer TRUE, and that isnt true.

--
components: Windows
files: bug.py
messages: 97785
nosy: DhaReaL
severity: normal
status: open
title: Math calculation problem (1.6-1.0)0.6, python said TRUE
type: behavior
versions: Python 3.1
Added file: http://bugs.python.org/file15883/bug.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7704
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7704] Math calculation problem (1.6-1.0)0.6, python said TRUE

2010-01-14 Thread pedro flores

pedro flores pflore...@gmail.com added the comment:

kk, then i cannot use this comparison?, and this not happen
with8.6-80.6 this is false, according to python.

2010/1/14 Mark Dickinson rep...@bugs.python.org


 Mark Dickinson dicki...@gmail.com added the comment:

 This is not a bug:  Python, like many other computer languages, stores
 floats in binary.  The values 1.6 and 0.6 aren't exactly representable in
 the internal format used, so the stored versions of 1.6 and 0.6 are actually
 just very close approximations to those values.  It just so happens that the
 approximation for 1.6 is a tiny amount larger than 1.6 (the exact value
 stored is 1.600088817841970012523233890533447265625), while the
 approximation for 0.6 is a tiny amount smaller than 0.6 (the exact value is
 0.59997779553950749686919152736663818359375).

 I recommend looking at the appendix to the Python tutorial for more
 information about floating point:

 http://docs.python.org/tutorial/floatingpoint.html

 --
 nosy: +mark.dickinson
 resolution:  - invalid
 status: open - closed

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue7704
 ___


--
Added file: http://bugs.python.org/file15884/unnamed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7704
___kk, then i cannot use this comparison?, and this not happen 
with8.6-8gt;0.6 this is false, according to python.brbrdiv 
class=gmail_quote2010/1/14 Mark Dickinson span dir=ltrlt;a 
href=mailto:rep...@bugs.python.org;rep...@bugs.python.org/agt;/spanbr
blockquote class=gmail_quote style=border-left: 1px solid rgb(204, 204, 
204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;br
Mark Dickinson lt;a 
href=mailto:dicki...@gmail.com;dicki...@gmail.com/agt; added the 
comment:br
br
This is not a bug:  Python, like many other computer languages, stores floats 
in binary.  The values 1.6 and 0.6 aren#39;t exactly representable in the 
internal format used, so the stored versions of 1.6 and 0.6 are actually just 
very close approximations to those values.  It just so happens that the 
approximation for 1.6 is a tiny amount larger than 1.6 (the exact value stored 
is 1.600088817841970012523233890533447265625), while the 
approximation for 0.6 is a tiny amount smaller than 0.6 (the exact value is 
0.59997779553950749686919152736663818359375).br

br
I recommend looking at the appendix to the Python tutorial for more information 
about floating point:br
br
a href=http://docs.python.org/tutorial/floatingpoint.html; 
target=_blankhttp://docs.python.org/tutorial/floatingpoint.html/abr
br
--br
nosy: +mark.dickinsonbr
resolution:  -gt; invalidbr
status: open -gt; closedbr
divdiv/divdiv class=h5br
___br
Python tracker lt;a 
href=mailto:rep...@bugs.python.org;rep...@bugs.python.org/agt;br
lt;a href=http://bugs.python.org/issue7704; 
target=_blankhttp://bugs.python.org/issue7704/agt;br
___br
/div/div/blockquote/divbrbr clear=allbr-- brPedro Flores 
C.brEstudiante Memorista de Informática 2009-2010brUniversidad de 
Concepción, ConcepciónbrChilebr
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2378] UnboundLocalError when trying to raise exceptions inside execfile

2008-05-11 Thread Pedro Werneck

Pedro Werneck [EMAIL PROTECTED] added the comment:

I get it with r63075, r63085, on Linux.

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2378
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2118] smtplib.SMTP() raises socket.error rather than SMTPConnectError

2008-05-10 Thread Pedro Werneck

Changes by Pedro Werneck [EMAIL PROTECTED]:


Removed file: http://bugs.python.org/file9499/issue_2118_smtplib.patch

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2118
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue837234] Tk.quit and sys.exit cause Fatal Error

2008-05-10 Thread Pedro Werneck

Pedro Werneck [EMAIL PROTECTED] added the comment:

I tried reproducing the bug with the info provided but neither case
worked. Since it doesn't mention platform, I'm including the file in
case anyone wants to try it on anything other than Linux/Python2.5.

--
nosy: +werneck
Added file: http://bugs.python.org/file10242/issue837234.py


Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue837234

___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue869780] curselection() in Tkinter.py should return ints

2008-05-10 Thread Pedro Werneck

Pedro Werneck [EMAIL PROTECTED] added the comment:

Just a bare self._getints will raise an exception with no item selected
and an empty string returned, so I'm adding a patch to check for it and
return an empty tuple in that case, or the tuple with ints.

It's open for discussion if we should follow Tk documentation strictly
and return an empty string if no item selected, or keep consistency with
Python and other Tkinter parts and always return a tuple.

--
keywords: +patch
nosy: +werneck
Added file: http://bugs.python.org/file10246/issue869780_2.6.patch


Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue869780

___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue869780] curselection() in Tkinter.py should return ints

2008-05-10 Thread Pedro Werneck

Changes by Pedro Werneck [EMAIL PROTECTED]:


Added file: http://bugs.python.org/file10248/issue869780_3.patch


Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue869780

___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue869780] curselection() in Tkinter.py should return ints

2008-05-10 Thread Pedro Werneck

Changes by Pedro Werneck [EMAIL PROTECTED]:


Removed file: http://bugs.python.org/file10248/issue869780_3.patch


Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue869780

___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue869780] curselection() in Tkinter.py should return ints

2008-05-10 Thread Pedro Werneck

Pedro Werneck [EMAIL PROTECTED] added the comment:

I used the tuple from splitlist() in both cases. I'm not sure if it
should return None on an empty selection since that is not documented
anywhere.

Added file: http://bugs.python.org/file10252/issue869780.py


Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue869780

___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue869780] curselection() in Tkinter.py should return ints

2008-05-10 Thread Pedro Werneck

Pedro Werneck [EMAIL PROTECTED] added the comment:

Neither I do, but the current version already returns an empty tuple.
Since the map(int, curselection) idiom is widely used, changing to int
is not likely to break any code, but returning None on empty selection is.


Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue869780

___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1410739] Add notes to the manual about `is` and methods

2008-05-10 Thread Pedro Werneck

Pedro Werneck [EMAIL PROTECTED] added the comment:

I agree it's not a good idea to be too much specific about this. The
patch attached adds the following footnote to the 'is' operator:

Due to automatic garbage-collection, free lists, and the dynamic nature
of descriptors, you may notice unusual behaviour in certain combinations
of :keyword:`is` operator, like those involving identity comparisons
between class and instancemethods, and free instances in the same
expression. Check their docs for more info.

--
nosy: +werneck
Added file: http://bugs.python.org/file10263/issue1410739.patch

_
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1410739
_
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2378] UnboundLocalError when trying to raise exceptions inside execfile

2008-05-10 Thread Pedro Werneck

Pedro Werneck [EMAIL PROTECTED] added the comment:

Just note the error happens even without the try/except block inside the
'if' statement.

--
nosy: +werneck

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2378
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue869780] curselection() in Tkinter.py should return ints

2008-05-10 Thread Pedro Werneck

Changes by Pedro Werneck [EMAIL PROTECTED]:


Removed file: http://bugs.python.org/file10252/issue869780.py


Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue869780

___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2325] isinstance(anything, MetaclassThatDefinesInstancecheck) raises instead of returning False

2008-05-02 Thread Pedro Werneck

Pedro Werneck [EMAIL PROTECTED] added the comment:

In 3.0 it happens with any class. Just the cls argument missing on the
call to instancecheck.

--
keywords: +patch
nosy: +werneck
Added file: http://bugs.python.org/file10174/issue2325.patch

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2325
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2325] isinstance(anything, MetaclassThatDefinesInstancecheck) raises instead of returning False

2008-05-02 Thread Pedro Werneck

Changes by Pedro Werneck [EMAIL PROTECTED]:


Removed file: http://bugs.python.org/file10174/issue2325.patch

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2325
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2325] isinstance(anything, MetaclassThatDefinesInstancecheck) raises instead of returning False

2008-05-02 Thread Pedro Werneck

Pedro Werneck [EMAIL PROTECTED] added the comment:

Seems like that's the wrong usage and the PEP 3119 notices that it's
hard to get the right semantics. To use it that way you need to define
the methods as a classmethod().

http://www.python.org/dev/peps/pep-3119/#one-trick-ponies

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2325
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2736] datetime needs and epoch method

2008-05-02 Thread Pedro Werneck

Pedro Werneck [EMAIL PROTECTED] added the comment:

That's expected as mktime is just a thin wrapper over libc mktime() and
it does not expect microseconds. Changing time.mktime doesn't seems an
option, so the best alternative is to implement a method in datetime
type. Is there a real demand for C code implementing this to justify it?

--
nosy: +werneck

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2736
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1193577] add server.shutdown() method and daemon arg to SocketServer

2008-02-25 Thread Pedro Werneck

Pedro Werneck added the comment:

I had some code here to do the exact same thing with XML-RPC server. The
patch adds the feature to SocketServer, with a server.shutdown() method
to stop serve_forever(), and change the unittest to use and test the
feature.

I disagree on adding the daemon_threads arg as a keyword to TCPServer
since that's a feature of ThreadingMixIn

--
keywords: +patch
nosy: +werneck
Added file: http://bugs.python.org/file9553/issue1193577.patch

_
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1193577
_
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2118] smtplib.SMTP() raises socket.error rather than SMTPConnectError

2008-02-23 Thread Pedro Werneck

Pedro Werneck added the comment:

It seems the right thing to do would be to have it raise a base
exception, but SMTPConnectError docstring states Error during
connection establishment., so I chosen to use it with the errno and
message from socket.error, even if it's supposed to happen only after
connection is already stablished, since it's a subclass of
SMTPResponseException.

As a bonus I removed a explicit raise socket.error from line 290, when
an user pass a non-integer port.

--
nosy: +werneck
Added file: http://bugs.python.org/file9499/issue_2118_smtplib.patch

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2118
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2118] smtplib.SMTP() raises socket.error rather than SMTPConnectError

2008-02-23 Thread Pedro Werneck

Pedro Werneck added the comment:

Previous patch didn't passed the tests right. This patch fixes both the
code, unindenting port number conversion to integer and the test.

Added file: http://bugs.python.org/file9509/issue_2118_fixed.patch

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2118
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1375] hotshot IndexError when loading stats

2008-02-23 Thread Pedro Werneck

Pedro Werneck added the comment:

Fixed by raising StopIteration when the stack is empty.

--
nosy: +werneck
Added file: http://bugs.python.org/file9510/issue_1375_hotshot.patch

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1375
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1697] Problems with float and 6 type

2007-12-25 Thread Pedro Clemente Pereira Neto

New submission from Pedro Clemente Pereira Neto:

Problems with float and 6 type

Hi, I am having problems both in the Windows version on the Linux
version of Python as put some number with some 6 type that it always
returns a value me, following examples:

 2.0
2.0
 1.55
1.55
 1.56
1.5601
 1.6
1.6001
 1.63
1.6299
 1.64
1.6399
 1.71
1.71
 6.0
6.0

Recalling that the error happens only with the digit 6 in float.
Thanks for attention.

Pedro Clemente Pereira Neto 
Brasil
pedrocpneto at gmail.com

--
components: Interpreter Core
messages: 58989
nosy: pedrocpneto
severity: normal
status: open
title: Problems with float and 6 type
type: resource usage
versions: Python 2.5

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1697
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1149] fdopen does not work as expected

2007-09-11 Thread Luís Pedro Coelho

New submission from Luís Pedro Coelho:

from os import *

def Fork():
b = fork()
if b  0:
raise Exception('fork() failed')
return b


r,w=pipe()
b = Fork()
if b == 0:
   dup2(w,1)
   close(w)
   execlp('echo',\
   'echo',\
'Hello world')
else:
   for line in fdopen(r):
   print 'Read %s' % line

I was expecting this code to print Read Hello World. Instead, it 
hangs forever.

Changing for line in fdopen(r): print 'Read %s' % line 
to line=read(r,100); print 'Read %s' % line makes the program work 
as expected. This is what I did on my actual production code, but it 
seems funny behaviour on the part of fdopen.

I am running on Ubuntu on PowerPC.

--
components: Library (Lib)
messages: 55829
nosy: [EMAIL PROTECTED]
severity: normal
status: open
title: fdopen does not work as expected
type: behavior
versions: Python 2.3, Python 2.4, Python 2.5

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1149
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com