[issue46070] _PyImport_FixupExtensionObject() regression causing a crash in subintepreters

2021-12-30 Thread Manuel Reimer


Change by Manuel Reimer :


--
nosy: +M-Reimer

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



[issue45523] Python3 ThreadingHTTPServer fails to send chunked encoded response

2021-10-19 Thread Manuel


New submission from Manuel :

I'm implementing an HTTPServer class that produces a response with 
transfer-encoding chunked mode.

I'm sending the chunks as described in 
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Transfer-Encoding#chunked_encoding

If I send chunks of length <= 9 bytes the message is received correctly by the 
client, otherwise when sending chunks of length >= 10 bytes, it seems that some 
of them are not received and the message remains stuck in the client waiting 
indefinitely

In attachment an example of the complete code to reproduce the issue, but in 
short, the following code:

# writing 5 chunks of length 10
for i in range(5):
text = str(i+1) * 10  # concatenate 10 chars
chunk = '{0:d}\r\n'.format(len(text)) + text + '\r\n'
self.wfile.write(chunk.encode(encoding='utf-8'))

# writing close sequence
close_chunk = '0\r\n\r\n'
self.wfile.write(close_chunk.encode(encoding='utf-8'))

Produces:
10\r\n
11\r\n
10\r\n
22\r\n
10\r\n
33\r\n
10\r\n
44\r\n
10\r\n
55\r\n
0\r\n
\r\n

In this case the client hangs several minutes without a response 

But if I use length 9 or less instead for example with

text = str(i+1) * 9

the client receives the correct body and the communication ends correctly (in 
about 6ms)

The problem persists with both http.server.ThreadingHTTPServer and 
http.server.HTTPServer
I tried also passing the body as an hard-coded binary string

some version informations:
Python 3.9.2
HTTP Client used: Postman 8.10, curl, Chrome


Thanks a lot for any help
Manuel

--
files: myserver.py
messages: 404300
nosy: manuel_b
priority: normal
severity: normal
status: open
title: Python3 ThreadingHTTPServer fails to send chunked encoded response
type: behavior
versions: Python 3.9
Added file: https://bugs.python.org/file50369/myserver.py

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



[issue41631] _ast module: get_global_ast_state() doesn't work with Mercurial lazy import

2020-09-08 Thread Manuel Jacob


Manuel Jacob  added the comment:

I was running "make all" and I also ran the documentation generator command 
without an error.

However, I tried it again and now it failed the same way as reported. With a 
debug build, I get "Python/Python-ast.c:231: get_ast_state: Assertion `state != 
NULL' failed.".

Sorry for the noise!

--

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



[issue41631] _ast module: get_global_ast_state() doesn't work with Mercurial lazy import

2020-09-08 Thread Manuel Jacob

Manuel Jacob  added the comment:

I couldn’t reproduce the problem with a freshly compiled Python 3.9.0rc1 on 
Arch Linux. Was this ever reproduced on a non-Red Hat system?

--
nosy: +mjacob

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



[issue33660] pathlib.Path.resolve() returns path with double slash when resolving a relative path in root directory

2020-08-26 Thread Manuel Barkhau


Manuel Barkhau  added the comment:

This issue cropped up recently in the black project: 
https://github.com/psf/black/issues/1631

It appears to me that PR 7666 was closed without being merged.

I created https://github.com/python/cpython/pull/21971 before I had found this 
issue.

--
versions: +Python 3.10, Python 3.9

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



[issue33660] pathlib.Path.resolve() returns path with double slash when resolving a relative path in root directory

2020-08-26 Thread Manuel Barkhau


Change by Manuel Barkhau :


--
nosy: +mbarkhau
nosy_count: 6.0 -> 7.0
pull_requests: +21079
pull_request: https://github.com/python/cpython/pull/21971

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



[issue41221] Output of print() might get truncated in unbuffered mode

2020-07-07 Thread Manuel Jacob

Manuel Jacob  added the comment:

It’s possible to trigger the problem on Unix with much smaller sizes, e.g. by 
interrupting the write() with a signal handler (even if the signal handler 
doesn’t do anything). The following script starts a subprocess doing a 16MiB 
write and sends a signal, which is handled but is a no-op, after reading a bit 
from the pipe:

import signal
import subprocess
import sys

CHILD_PROCESS = '''
import signal, sys
signal.signal(signal.SIGINT, lambda *x: None)
written = sys.stdout.write('x' * 16777216)
print('written:', written, file=sys.stderr, flush=True)
'''

proc = subprocess.Popen(
[sys.executable, '-u', '-c', CHILD_PROCESS],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
read = len(proc.stdout.read(1))
proc.send_signal(signal.SIGINT)
read += len(proc.stdout.read())
stdout, stderr = proc.communicate()
assert stdout == b''
print('stderr:', stderr)
assert read == 16777216, "read: {}".format(read)


% python3 test_interrupted_write.py
stderr: b'written: 16777216\n'
Traceback (most recent call last):
  File "test_interrupted_write.py", line 24, in 
assert read == 16777216, "read: {}".format(read)
AssertionError: read: 69632

If I remove the '-u' that gets passed to the subprocess:

% python3 test_interrupted_write.py
stderr: b'written: 16777216\n'

--

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



[issue41221] Output of print() might get truncated in unbuffered mode

2020-07-06 Thread Manuel Jacob


Manuel Jacob  added the comment:

`io.TextIOWrapper.write()` returns the length of the passed string instead of 
the actually written number of characters.

% python -u -c "import sys; print(sys.stdout.write('x'*4294967296), 
file=sys.stderr)" | wc -c 
4294967296
2147479552

So the possibility "users of `io.TextIOWrapper` call `write()` until all 
characters have been written" would not be sufficient.

--

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



[issue41221] Output of print() might get truncated in unbuffered mode

2020-07-06 Thread Manuel Jacob

Manuel Jacob  added the comment:

2147479552 is the 0x7000 bytes limit documented for write() on Linux 
(source: https://man7.org/linux/man-pages/man2/write.2.html). The limit could 
be even smaller in other circumstances or other systems.

I’m adding Victor Stinner to the nosy list, as he added the code limiting 
writes to the console on Windows in e0daff1c61e323d2a39dd8241de67082d1f10fd7, 
and he might have an opinion on the topic.

--
nosy: +vstinner

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



[issue41221] Output of print() might get truncated in unbuffered mode

2020-07-06 Thread Manuel Jacob

New submission from Manuel Jacob :

Without unbuffered mode, it works as expected:

% python -c "import sys; sys.stdout.write('x'*4294967296)" | wc -c
4294967296

% python -c "import sys; print('x'*4294967296)" | wc -c 
4294967297

With unbuffered mode, writes get truncated to 2147479552 bytes on my Linux 
machine:

% python -u -c "import sys; sys.stdout.write('x'*4294967296)" | wc -c   
2147479552

% python -u -c "import sys; print('x'*4294967296)" | wc -c 
2147479553

I didn’t try, but it’s probably an even bigger problem on Windows, where writes 
might be limited to 32767 bytes: 
https://github.com/python/cpython/blob/v3.9.0b4/Python/fileutils.c#L1585

Without unbuffered mode, `sys.stdout.buffer` is a `io.BufferedWriter` object.

% python -c 'import sys; print(sys.stdout.buffer)'
<_io.BufferedWriter name=''>

With unbuffered mode, `sys.stdout.buffer` is a `io.FileIO` object.

% python -u -c 'import sys; print(sys.stdout.buffer)' 
<_io.FileIO name='' mode='wb' closefd=False>

`io.BufferedWriter` implements the `io.BufferedIOBase` interface. 
`io.BufferedIOBase.write()` is documented to write all passed bytes. 
`io.FileIO` implements the `io.RawIOBase` interface. `io.RawIOBase.write()` is 
documented to be able to write less bytes than passed.

`io.TextIOWrapper.write()` is not documented to write all characters it has 
been passed, but e.g. `print()` relies on that.

To fix the problem, it has to be ensured that either
* `sys.stdout.buffer` is an object that guarantees that all bytes passed to its 
`write()` method are written (e.g. deriving from `io.BufferedIOBase`), or
* `io.TextIOWrapper` calls the `write()` method of its underlying binary stream 
until all bytes have been written, or
* users of `io.TextIOWrapper` call `write()` until all characters have been 
written.

In the first two possibilities it probably makes sense to tighten the contract 
of `io.TextIOBase.write` to guarantee that all passed characters are written.

--
components: IO
messages: 373151
nosy: mjacob
priority: normal
severity: normal
status: open
title: Output of print() might get truncated in unbuffered mode
type: behavior
versions: Python 3.8

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



[issue41091] Remove recommendation in curses module documentation to initialize LC_ALL and encode strings

2020-06-25 Thread Manuel Jacob


Change by Manuel Jacob :


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

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



[issue41091] Remove recommendation in curses module documentation to initialize LC_ALL and encode strings

2020-06-23 Thread Manuel Jacob

New submission from Manuel Jacob :

The documentation for the curses module 
(https://docs.python.org/3.9/library/curses.html) has the following note:

> Since version 5.4, the ncurses library decides how to interpret non-ASCII 
> data using the nl_langinfo function. That means that you have to call 
> locale.setlocale() in the application and encode Unicode strings using one of 
> the system’s available encodings. This example uses the system’s default 
> encoding:
> 
> import locale
> locale.setlocale(locale.LC_ALL, '')
> code = locale.getpreferredencoding()
> 
> Then use code as the encoding for str.encode() calls.

The recommendation to call `locale.setlocale(locale.LC_ALL, '')` is problematic 
as it initializes all locale categories to the user settings, which might be 
unintended and is not necessary for curses to work correctly. Initializing 
LC_CTYPE is sufficient for nl_langinfo() to return the correct encoding. 
Current versions of Python (*) initialize LC_CTYPE at interpreter startup. 
Therefore calling locale.setlocale() should not be necessary at all.

The curses module automatically encodes strings. Therefore the recommendation 
to manually encode strings is outdated.

(*) It seems to be the case since 177d921c8c03d30daa32994362023f777624b10d. Why 
was is not previously done on Python 2 and on Python 3 on Windows?

--
assignee: docs@python
components: Documentation
messages: 372178
nosy: docs@python, mjacob
priority: normal
severity: normal
status: open
title: Remove recommendation in curses module documentation to initialize 
LC_ALL and encode strings

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



[issue41051] Flush file after warning is written

2020-06-20 Thread Manuel Jacob


Change by Manuel Jacob :


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

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



[issue41051] Flush file after warning is written

2020-06-20 Thread Manuel Jacob

New submission from Manuel Jacob :

Calling warnings.warn() will write to a file, but not flush it. On Python 3.9+, 
it won’t usually be a problem because the file is most likely stderr, which is 
always line-buffered. However, on older Python versions or if a different file 
is used, the current behavior unnecessarily delays the output of the warning. 
This is especially problematic if the warning is about buffering behavior 
itself, as e.g. caused by `open('/tmp/test', 'wb', buffering=1)`.

--
messages: 371934
nosy: mjacob
priority: normal
severity: normal
status: open
title: Flush file after warning is written

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



[issue17110] sys.argv docs should explaining how to handle encoding issues

2020-06-18 Thread Manuel Jacob


Manuel Jacob  added the comment:

If the encoding supports it, since which Python version do Py_DecodeLocale() 
and os.fsencode() roundtrip?

The background of my question is that Mercurial goes some extra rounds to 
determine the correct encoding to emulate what Py_EncodeLocale() would do: 
https://www.mercurial-scm.org/repo/hg/file/5.4.1/mercurial/pycompat.py#l157 . 
If os.fsencode() could be used, it would simplify the code. Mercurial supports 
Python 3.5+.

--

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



[issue41012] Some code comments refer to removed initfsencoding()

2020-06-17 Thread Manuel Jacob


New submission from Manuel Jacob :

Some code comments refer to initfsencoding(), which was however removed after 
Python 3.7.

--
messages: 371779
nosy: mjacob
priority: normal
severity: normal
status: open
title: Some code comments refer to removed initfsencoding()

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



Problems with python383.dll

2020-06-17 Thread Manuel Fernandez - Università

Dear Sirs,
I tried to install the software Python 3.8.3 (32 bit), but after it 
finished and I tried to start it, there appeared a message in which it 
was written that it couldn't find the file python383.dll and stopped.

What can I do? Do you have this file so that I can insert it manually.
I thank you for your help.
Best wishes,
Manuel Fernandez


--

--
https://mail.python.org/mailman/listinfo/python-list


[issue17110] sys.argv docs should explaining how to handle encoding issues

2020-06-17 Thread Manuel Jacob


Manuel Jacob  added the comment:

The actual startup code uses Py_DecodeLocale() for converting argv from bytes 
to unicode. Since which Python version is it guaranteed that Py_DecodeLocale() 
and os.fsencode() roundtrip?

--
nosy: +mjacob

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



[issue40983] urllib.request.url2pathname() unconditionally uses utf-8 encoding and "replace" error handler

2020-06-16 Thread Manuel Jacob

Manuel Jacob  added the comment:

I’ve created issue40996, which suggests that urllib should fsdecode 
percent-encoded parts of file URIs on Unix. Since the two tickets are very 
related and I’d prefer if the issue was solved more generally for the whole 
module, I close this as a duplicate.

--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed

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



[issue40996] urllib should fsdecode percent-encoded parts of file URIs on Unix

2020-06-16 Thread Manuel Jacob

New submission from Manuel Jacob :

On Unix, file names are bytes. Python mostly prefers to use unicode for file 
names. On the Python <-> system boundary, os.fsencode() / os.fsdecode() are 
used.

In URIs, bytes can be percent-encoded. On Unix, most applications pass the 
percent-decoded bytes in file URIs to the file system unchanged. The remainder 
of this issue description is about Unix, except for the last paragraph.

Pathlib fsencodes the path when making a file URI, roundtripping the bytes e.g. 
passed as an argument:
% python3 -c 'import pathlib, sys; print(pathlib.Path(sys.argv[1]).as_uri())' 
/tmp/a$(echo -e '\xE4')
file:///tmp/a%E4

Example with curl using this URL:
% echo 'Hello, World!' > /tmp/a$(echo -e '\xE4')
% curl file:///tmp/a%E4
Hello, World!

Python 2’s urllib works the same:
% python2 -c 'from urllib import urlopen; 
print(repr(urlopen("file:///tmp/a%E4").read()))'
'Hello, World!\n'

However, Python 3’s urllib fails:
% python3 -c 'from urllib.request import urlopen; 
print(repr(urlopen("file:///tmp/a%E4").read()))' 
Traceback (most recent call last):
  File "/usr/lib/python3.8/urllib/request.py", line 1507, in open_local_file
stats = os.stat(localfile)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/a�'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.8/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
  File "/usr/lib/python3.8/urllib/request.py", line 525, in open
response = self._open(req, data)
  File "/usr/lib/python3.8/urllib/request.py", line 542, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
  File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
result = func(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 1485, in file_open
return self.open_local_file(req)
  File "/usr/lib/python3.8/urllib/request.py", line 1524, in open_local_file
raise URLError(exp)
urllib.error.URLError: 

urllib.request.url2pathname() is the function converting the path of the file 
URI to a file name. On Unix, it uses urllib.parse.unquote() with the default 
settings (UTF-8 encoding and the "replace" error handler).

I think that on Unix, the settings from os.fsdecode() should be used, so that 
it roundtrips with pathlib.Path.as_uri() and so that the percent-decoded bytes 
are passed to the file system as-is.

On Windows, I couldn’t do experiments, but using UTF-8 seems like the right 
thing (according to https://en.wikipedia.org/wiki/File_URI_scheme#Windows_2). 
I’m not sure that the "replace" error handler is a good idea. I prefer "errors 
should never pass silently" from the Zen of Python, but I don’t a have a strong 
opinion on this.

--
components: Library (Lib), Unicode
messages: 371702
nosy: ezio.melotti, mjacob, vstinner
priority: normal
severity: normal
status: open
title: urllib should fsdecode percent-encoded parts of file URIs on Unix
type: behavior

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



[issue40983] urllib.request.url2pathname() unconditionally uses utf-8 encoding and "replace" error handler

2020-06-16 Thread Manuel Jacob

Change by Manuel Jacob :


--
title: Can’t configure encoding used by urllib.request.url2pathname() -> 
urllib.request.url2pathname() unconditionally uses utf-8 encoding and "replace" 
error handler

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



[issue40983] Can’t configure encoding used by urllib.request.url2pathname()

2020-06-15 Thread Manuel Jacob

New submission from Manuel Jacob :

On Python 2, it was possible to recover a percent-encoded byte:
>>> from urllib import url2pathname
>>> url2pathname('%ff')
'\xff'

On Python 3, the byte is decoded using the utf-8 encoding and the "replace" 
error handler (therefore there’s no way to recover the byte):
>>> from urllib.request import url2pathname
>>> url2pathname('%ff')
'�'

For my use case (getting the pathname as bytes), it would be sufficient to 
specify a different encoding (e.g. latin-1) or a different error handler (e.g. 
surrogateescape) that makes it possible to recover the byte by encoding the 
result of url2pathname() such that it roundtrips with the encoding and error 
handler internally used by url2pathname() for percent-encoded bytes.

I’m not simply sending a patch, because this might point to a deeper issue. 
Suppose there’s the following script:

import sys
from pathlib import Path
from urllib.request import urlopen
path = Path(sys.argv[1])
path.write_text('Hello, World!')
with urlopen(path.as_uri()) as resp:
print(resp.read())

If I call this script with b'/tmp/\xff' as the argument, it fails with the 
following traceback:

Traceback (most recent call last):
  File "/usr/lib/python3.8/urllib/request.py", line 1507, in open_local_file
stats = os.stat(localfile)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/�'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test_url2pathname.py", line 6, in 
with urlopen(path.as_uri()) as resp:
  File "/usr/lib/python3.8/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
  File "/usr/lib/python3.8/urllib/request.py", line 525, in open
response = self._open(req, data)
  File "/usr/lib/python3.8/urllib/request.py", line 542, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
  File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
result = func(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 1485, in file_open
return self.open_local_file(req)
  File "/usr/lib/python3.8/urllib/request.py", line 1524, in open_local_file
raise URLError(exp)
urllib.error.URLError: 

So maybe urllib.request.url2pathname() should use the same encoding and error 
handler as os.fsencode() / os.fsdecode().

--
components: Library (Lib)
messages: 371537
nosy: mjacob
priority: normal
severity: normal
status: open
title: Can’t configure encoding used by urllib.request.url2pathname()

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



[issue39229] library/functions.rst causes translated builds to fail

2020-06-14 Thread Manuel Kaufmann

Manuel Kaufmann  added the comment:

We are having a similar issue in python-docs-es translation.


cpython/Doc/library/ctypes.rst:: WARNING: inconsistent term references in 
translated message. original: [], translated: [':ref:`evento de auditoría 
`']

https://travis-ci.org/github/python/python-docs-es/builds/698122676


Note that the WARNING does not mention a line number in the RST file. From what 
I could find, this is because the source English sentence is not in the .rst 
file, but it's a RST directive and the sentence comes from Python code: 
https://github.com/python/cpython/blob/6f8c8320e9eac9bc7a7f653b43506e75916ce8e8/Doc/tools/extensions/pyspecific.py#L135-L139

The original RST file, uses the directive here: 
https://github.com/python/cpython/blob/6f8c8320e9eac9bc7a7f653b43506e75916ce8e8/Doc/library/ctypes.rst#L1510


The PO file we are translating, does not have a header with line numbers for 
this paragraph: 
https://github.com/python/python-docs-es/blob/c51c38134ba74e26f73732ed96584325536141d3/library/ctypes.po#L1456-L1459

--
nosy: +humitos

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



[issue40868] io.TextIOBase.buffer is not necessarily a buffer

2020-06-04 Thread Manuel Jacob


New submission from Manuel Jacob :

https://docs.python.org/dev/library/io.html#io.TextIOBase.buffer says:

"The underlying binary buffer (a BufferedIOBase instance) that TextIOBase deals 
with. This is not part of the TextIOBase API and may not exist in some 
implementations."

It is not necessarily a buffer (a BufferedIOBase instance), e.g. when the 
stdout and stderr streams are set to be unbuffered. Example:

% python -u
Python 3.8.3 (default, May 17 2020, 18:15:42) 
[GCC 10.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import io, sys
>>> sys.stdout
<_io.TextIOWrapper name='' mode='w' encoding='utf-8'>
>>> isinstance(sys.stdout, io.TextIOBase)
True
>>> sys.stdout.buffer
<_io.FileIO name='' mode='wb' closefd=False>
>>> isinstance(sys.stdout.buffer, io.BufferedIOBase)
False

Therefore the name and the documentation are incorrect.

I suggest to deprecate the attribute "buffer", introduce a new attribute with a 
correct name, and forward the old attribute to the new attribute and vice versa 
in the io.TextIOBase class.

I think that "binary" would be a good attribute name for the underlying binary 
stream, as it would be consistent with io.BufferedIOBase.raw (for "the 
underlying raw stream").

--
assignee: docs@python
components: Documentation, IO
messages: 370744
nosy: docs@python, mjacob
priority: normal
severity: normal
status: open
title: io.TextIOBase.buffer is not necessarily a buffer

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



[issue40457] Python fails to compile/load _ssl module if OpenSSL is compiled with no-tls1-method

2020-05-31 Thread Manuel Jacob

Manuel Jacob  added the comment:

For the record, I’ve added a comment to the pull request about that 
ssl.PROTOCOL_TLSv1_1 / ssl.PROTOCOL_TLSv1_2 are now defined unconditionally.

https://github.com/python/cpython/commit/6e8cda91d92da72800d891b2fc2073ecbc134d98#r39569316

--
nosy: +mjacob

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



[issue39464] Allow translating argument error messages

2020-01-27 Thread José Manuel Ferrer

New submission from José Manuel Ferrer :

Argument error messages display the untranslatable text 'argument ', which 
should be translatable to other languages, just like it's possible to do with 
the rest of the constructed error message.

--
components: Library (Lib)
messages: 360764
nosy: DjMorgul
priority: normal
pull_requests: 17578
severity: normal
status: open
title: Allow translating argument error messages
type: enhancement
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

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



[issue39390] shutil.copytree - 3.8 changed argument types of the ignore callback

2020-01-24 Thread Manuel Barkhau


Manuel Barkhau  added the comment:

> If you pass a string, you will get a string, so existing code will continue 
> to work as before.

Somebody might have code that is running against a flat directory and have 
written their ignore function expecting to get a pathlib.Path, because that's 
the only case they encountered. This change would break their code and so would 
an upgrade to 3.9 with the patch that was just merged.

--

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



[issue39390] shutil.copytree - 3.8 changed argument types of the ignore callback

2020-01-24 Thread Manuel Barkhau


Manuel Barkhau  added the comment:

> For completeness, a similar problem is present also on python < 3.8

Fair point. I'll have a look.

--

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



[issue39390] shutil.copytree - 3.8 changed argument types of the ignore callback

2020-01-24 Thread Manuel Barkhau


Change by Manuel Barkhau :


--
pull_requests: +17554
pull_request: https://github.com/python/cpython/pull/18168

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



[issue39390] shutil.copytree - 3.8 changed argument types of the ignore callback

2020-01-22 Thread Manuel Barkhau


Change by Manuel Barkhau :


--
pull_requests: +17509
pull_request: https://github.com/python/cpython/pull/18122

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



[issue39390] shutil.copytree - 3.8 changed argument types of the ignore callback

2020-01-21 Thread Manuel Barkhau


Manuel Barkhau  added the comment:

Unless somebody else wants to, I could have a go at an PR to update shutil.py

--

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



[issue39390] shutil.copytree - 3.8 changed argument types of the ignore callback

2020-01-21 Thread Manuel Barkhau


Manuel Barkhau  added the comment:

Is there anything I can do to help move this forward?

--

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



[issue39390] shutil.copytree - 3.8 changed argument types of the ignore callback

2020-01-20 Thread Manuel Barkhau


Manuel Barkhau  added the comment:

> This looks like a backward incompatible change in 3.8.

Indeed. 

> Should not copytree convert arguments of the ignore callback to str and list 
> correspondingly?

Well, since any existing code probably expects that behavior (or at least 
probably works if that is the case), I would be for such a change. I'm not sure 
what your policy is though. If there is recently written code that assumes the 
new types, are you OK with that breaking if it is changed back?

I guess since it's an undocumented breaking change, it shouldn't be too much of 
an issue.

--

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



[issue39390] shutil.copytree - 3.8 changed argument types of the ignore callback

2020-01-19 Thread Manuel Barkhau


Change by Manuel Barkhau :


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

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



[issue39390] shutil.copytree - 3.8 changed argument types of the ignore callback

2020-01-19 Thread Manuel Barkhau


Change by Manuel Barkhau :


--
title: shutil.copytree - ignore callback behaviour change -> shutil.copytree - 
3.8 changed argument types of the ignore callback

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



[issue39390] shutil.copytree - ignore callback behaviour change

2020-01-19 Thread Manuel Barkhau


New submission from Manuel Barkhau :

In Python 3.8, the types of the parameters to the ignore callable appear to 
have changed.

Previously the `src` parameter was a string and the `names` parameter was a 
list of strings. Now the `src` parameter appears to be either a `pathlib.Path` 
or an `os.DirEntry`, while the `names` parameter is a set of strings.

I would suggest adding the following to the documentation 
https://github.com/python/cpython/blob/master/Doc/library/shutil.rst

   .. versionchanged:: 3.8
  The types of arguments to *ignore* have changed. The first argument 
  (the directory being visited) is a func:`os.DirEntry` or a 
  func:`pathlib.Path`; Previously it was a string. The second argument is
  a set of strings; previously it was a list of strings.

--
assignee: docs@python
components: Documentation, Library (Lib)
messages: 360271
nosy: docs@python, mbarkhau
priority: normal
severity: normal
status: open
title: shutil.copytree - ignore callback behaviour change
type: behavior
versions: Python 3.8, Python 3.9

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



[issue38710] unsynchronized write pointer in io.TextIOWrapper in 'r+' mode

2019-11-05 Thread Manuel Ignacio Pérez Alcolea

New submission from Manuel Ignacio Pérez Alcolea :

There seems to be a bug in the `io.TextIOWrapper` class while working in 'r+' 
mode, although I can't say the source of the problem is right there.

The write pointer doesn't match `file.tell()` after performing a read operation.

For example, this file, consisting of 3 lines:

  line one
  line two
  line three

Doesn't result in the expected modification running the following program:

with open('file', 'r+', buffering=1) as f:
print(f.tell())  # => 0
print(f.readline().strip())  # we read 1 line
print(f.tell())  # => 9  
print('Hello', file=f)   # we write "Hello\n"
print(f.tell())  # => 34

Instad of

  line one
  Hello
  wo
  line three

It results in

  line one
  line two
  line threeHello

But it works just fine if `f.seek(f.tell())` is added the program, right before 
the write operation.

There are several possible explanations on StackOverflow, involving the 
buffering for IO in text files:

https://stackoverflow.com/a/58722058/11601118

--
components: IO
messages: 356089
nosy: Manuel Ignacio Pérez Alcolea
priority: normal
severity: normal
status: open
title: unsynchronized write pointer in io.TextIOWrapper in 'r+' mode
type: behavior
versions: Python 3.7

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



[issue21879] str.format() gives poor diagnostic on placeholder mismatch

2019-03-04 Thread Manuel Cerón

Change by Manuel Cerón :


--
nosy:  -ceronman

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



[issue25737] array is not a Sequence

2019-02-27 Thread Manuel Cerón

Change by Manuel Cerón :


--
nosy: +ceronman

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



[issue23864] issubclass without registration only works for "one-trick pony" collections ABCs.

2019-02-27 Thread Manuel Cerón

Change by Manuel Cerón :


--
nosy: +ceronman

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



[issue35360] Update SQLite to 3.26 in Windows and macOS installer builds

2019-02-27 Thread Manuel Cerón

Change by Manuel Cerón :


--
nosy: +ceronman

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



[issue21879] str.format() gives poor diagnostic on placeholder mismatch

2019-02-24 Thread Manuel Cerón

Change by Manuel Cerón :


--
nosy: +ceronman

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



[issue18299] Change script_helper to use universal_newlines=True in _assert_python

2019-02-24 Thread Manuel Cerón

Change by Manuel Cerón :


--
nosy: +ceronman

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



[issue25026] (FreeBSD/OSX) Fix fcntl module to accept 'unsigned long' type commands for ioctl(2).

2019-02-24 Thread Manuel Cerón

Change by Manuel Cerón :


--
nosy: +ceronman

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



[issue29446] Improve tkinter 'import *' situation

2019-02-24 Thread Manuel Cerón

Change by Manuel Cerón :


--
nosy: +ceronman

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



[issue34321] mmap.mmap() should not necessarily clone the file descriptor

2018-08-02 Thread Manuel


New submission from Manuel :

mmap.mmap(fileno, length, flags, prot, access, offset) always clones the file 
descriptor that should be used [1].

The cloning of the file descriptor seems to be done to ensure that the file 
cannot be closed behind mmap's back, but if you are mmap()'ing a lot of memory 
regions of a file this can cause a 'Too many open files' error.

I would suggest to add an option to mmap.mmap() that tells it not to clone the 
file descriptor. This can cause an issue if the file is closed before accessing 
the mmapped region, so this fact should also be pointed out in the 
documentation.

[1] https://github.com/python/cpython/blob/master/Modules/mmapmodule.c#L1159

--
components: Library (Lib)
messages: 322953
nosy: manuels
priority: normal
severity: normal
status: open
title: mmap.mmap() should not necessarily clone the file descriptor
type: enhancement
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8

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



[issue33216] Wrong order of stack for CALL_FUNCTION_VAR and CALL_FUNCTION_VAR_KW

2018-04-03 Thread Manuel Vazquez Acosta

Manuel Vazquez Acosta <man...@merchise.org> added the comment:

Correction, the documentation for CALL_FUNCTION_VAR said:

Calls a function. *argc* is interpreted as in :opcode:`CALL_FUNCTION`. The top 
element on the stack contains the variable argument list, followed by keyword 
and positional arguments.


In a previous comment I pasted the version I'm putting in the PR.

--

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



[issue33216] Wrong order of stack for CALL_FUNCTION_VAR and CALL_FUNCTION_VAR_KW

2018-04-03 Thread Manuel Vazquez Acosta

Change by Manuel Vazquez Acosta <man...@merchise.org>:


--
keywords: +patch
pull_requests: +6075
stage:  -> patch review

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



[issue33216] Wrong order of stack for CALL_FUNCTION_VAR and CALL_FUNCTION_VAR_KW

2018-04-03 Thread Manuel Vazquez Acosta

New submission from Manuel Vazquez Acosta <man...@merchise.org>:

The documentation of the dis module says that:

  CALL_FUNCTION_VAR (argc)

   Calls a function. *argc* is interpreted as in CALL_FUNCTION. The
   top elements on the stack are the keyword arguments, followed by the
   variable argument list, and then the positional arguments.

However, inspecting the how ``f(b=1, *args)`` is actually compiled shows a 
different order:

   >>> import dis
   >>> dis.dis(compile('f(b=1, *args)', '<>', 'eval'))

  1   0 LOAD_NAME0 (f)
  3 LOAD_NAME1 (args)
  6 LOAD_CONST   0 ('b')
  9 LOAD_CONST   1 (1)
 12 CALL_FUNCTION_VAR  256 (0 positional, 1 keyword pair)
 15 RETURN_VALUE

Notice that the top of the stack contains the explicit keyword arguments.

The documentation of CALL_FUNCTION_VAR_KW is also incorrect.

--
assignee:  -> docs@python
components: +Documentation
nosy: +docs@python
title: CALL_FUNCTION_VAR -> Wrong order of stack for CALL_FUNCTION_VAR and 
CALL_FUNCTION_VAR_KW
versions: +Python 3.5

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



[issue33216] CALL_FUNCTION_VAR

2018-04-03 Thread Manuel Vazquez Acosta

Change by Manuel Vazquez Acosta <man...@merchise.org>:


--
nosy: mvaled
priority: normal
severity: normal
status: open
title: CALL_FUNCTION_VAR

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



CSV file edition

2018-01-09 Thread Manuel Rincon
Dear:

With what function could you separate the numerical part of each column?



 MarketTime   Price
Type   
Type=0  MarketTime=11:18:26.549  Price=112.8300
Type=0  MarketTime=11:18:28.792  Price=112.8300
Type=0  MarketTime=11:18:28.792  Price=112.8400
Type=0  MarketTime=11:18:28.792  Price=112.8300
Type=0  MarketTime=11:18:45.798  Price=112.8500
Type=0  MarketTime=11:18:45.799  Price=112.8500
Type=0  MarketTime=11:18:45.880  Price=112.8400


I would need to filter only the numeric part of all the columns.
-- 
https://mail.python.org/mailman/listinfo/python-list


Regarding the error: TypeError: can’t pickle _thread.lock objects

2017-12-21 Thread Winston Manuel Vijay
Hi,

It would be of immense help, if someone could provide a suitable solution or 
related information that helps to sort out the below stated issue-


Ø  I had installed the Python version 3.6.4

Ø  Then I installed the package: Tensorflow

Ø  Installed g2p.exe by downloading from GitHub

Ø  Then tried running the below command-

g2p-seq2seq --interactive --model  (model_folder_path: is 
the path to an English model 2-layer LSTM with 512 hidden units CMU Sphinx 
dictionary downloaded from the CMU Sphinx website)

Following the above procedure, I encountered the following error: TypeError: 
can’t pickle _thread.lock objects-please find the attached screenshot for your 
reference.


Thanks,
A.Winston Manuel Vijay




This e-mail and any files transmitted with it are for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
This email is sent for the intended recipient(s) only. If by an addressing or 
transmission error, this mail has been misdirected to you, you are requested to 
delete this mail immediately. If you are not the intended recipient(s), please 
reply to the sender and destroy all copies of the original message. Any 
unauthorized review, use, disclosure, dissemination, forwarding, printing or 
copying of this email, and/or any action taken in reliance on the contents of 
this e-mail is strictly prohibited and may be unlawful. Where permitted by 
applicable law, this e-mail and other e-mail communications sent to and from 
GSR e-mail addresses may be monitored.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue31113] Stack overflow with large program

2017-08-06 Thread Manuel Krebber

Manuel Krebber added the comment:

@Serhiy That would require me to compile Python myself though, right? Is there 
a reason why the limit is only for try/for and not for if?

@Antoine Well, the goal is to be able to generate Python 2 compatible code . I 
will try to split the code into more functions and see if that helps...

--

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



[issue31113] Stack overflow with large program

2017-08-04 Thread Manuel Krebber

Manuel Krebber added the comment:

I have already tried to reduce the nesting, but it still crashes. I have to 
admit that ~20 levels of nesting are still quite a lot. But I am surprised that 
so few levels of nesting already are a problem for the parser... I have 
attached the generated code with reduced nesting.

--
Added file: http://bugs.python.org/file47058/generated.zip

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



[issue31113] Stack overflow with large program

2017-08-03 Thread Manuel Krebber

Manuel Krebber added the comment:

1) Yes.
2) A .pyc file was not generated.
3) It is always the same location where the error occurs.
4) It did not crash on the linux machine that I tested it on.

I have tried to split the code up into multiple files, but it still crashes. I 
have uploaded the file to http://wheerd.de/generated.zip
If you want I can also provide the code with multiple files.

--

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



[issue31113] Stack overflow with large program

2017-08-03 Thread Manuel Krebber

New submission from Manuel Krebber:

With a pattern matching library I am generating some Python code that matches 
patterns. For a very big pattern set I generate a Python file which is about 
20MB and has ~300K LOC. When I try to execute the file with Python 3.6.2 on 
Windows 10 (64bit), the interpreter crashes. I do not have the Python source 
locally, but I could get it if necessary. The crash is because of a stack 
overflow when calling dfs() in compile.c. I can attach you the program, but it 
needs some dependencies which currently are only availiable via some Github 
repos.

I will try to split the ig file into multiple smaller ones, but I thought you 
might want to know about an interpreter crash.

--
components: Interpreter Core, Windows
messages: 299689
nosy: Wheerd, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Stack overflow with large program
type: crash
versions: Python 3.6

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



How to store some elements from a list into another

2017-06-12 Thread José Manuel Suárez Sierra
Hello,
I am stuck with a (perhaps) easy problem, I hope someone can help me:

My problem is:
I have a list of lists like this one:
[[55, 56, 57, 58, 83, 84, 85, 86, 89, 90, 91, 92, 107, 108, 109, 110, 111, 117, 
118, 119, 120, 128, 129, 130, 131, 135, 136, 137, 138, 184, 185, 186, 187, 216, 
217, 218, 219, 232, 233, 234, 235, 236, 237, 238, 267, 268, 269, 270, 272, 273, 
274, 275], [2, 3, 4, 5, 9, 10, 11, 12, 21, 22, 23, 24, 29, 30, 31, 32, 56, 57, 
58, 59, 65, 66, 67, 68, 74, 75, 76, 77, 78, 89, 90, 91, 92, 98, 99, 100, 101, 
102, 125, 126, 127, 128, 131, 132, 133, 134, 135]]

And what I want is to store some of these datum into another list according to 
the next conditions:
1. I just want to store data if these values are consecutive (four in four), 
for instance, for first element I would like to store into the new list: 
[[[55,58],[83,86],[n,n+3]]] and so on.
 I tried something like this:

x=0
y=0
while list6[x][y] == list6[x][y+1]-1 and list6[x][y] == list6[x][y+1]-2 
and list6[x][y] == list6[x][y+1]-3 or list6[x][0]:

list7.append(list6[x][y])
list7.append(list6[x][y+3])
y = y+1
if (list6[x][y])%(list6[x][len(list6[x])-1]) == 0:
x= x+1

if len(list6[x]) == x and len(list6[x][y]) == y:
break


It does not work

I appreciate your help 
Thank you
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue29830] pyexpat.errors doesn't have __spec__ and __loader__ set

2017-03-17 Thread Manuel Jacob

Manuel Jacob added the comment:

You're of course right that pyexpat is an extension module and not a builtin 
module.  I was confused because on PyPy it's a builtin module.

But the same question applies for ExtensionFileLoader.is_package().  It returns 
False in the case of pyexpat.  This function looks a bit strange to me anyway.  
It assumes the definition of what a package is for pure Python modules and 
applies it to extension modules.

--

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



[issue29830] pyexpat.errors doesn't have __spec__ and __loader__ set

2017-03-16 Thread Manuel Jacob

New submission from Manuel Jacob:

The same applies to pyexpat.model.

It seems like pyexpat is the only builtin module which has submodules (errors, 
model).

Normally, as I understand it, the module gets imported given a spec and the 
import machinery ensures that this spec ends up in the __spec__ attribute of 
the module.  But in this case only pyexpat gets imported by importlib.  The 
submodules are added when initializing the module.

Also, importlib's BuiltinImporter assumes that a builtin module is never a 
package.  Is this reasonable in this case?

--
messages: 289737
nosy: mjacob
priority: normal
severity: normal
status: open
title: pyexpat.errors doesn't have __spec__ and __loader__ set

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



Doubt with files

2017-02-14 Thread José Manuel Suárez Sierra
hello,
im trying to read a rtf or txt file with this python script:

with open(dirFichero,'r') as reader:
for line in reader:
print line

the problem is that shown is :

{\rtf1\ansi\ansicpg1252\cocoartf1504\cocoasubrtf810

{\fonttbl\f0\fswiss\fcharset0 Helvetica;}

{\colortbl;\red255\green255\blue255;}

{\*\expandedcolortbl;;}

\paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0

\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0



\f0\fs24 \cf0 1l2m,1svo,1lme}


INSTEAD of:
1l2m,1svo,1lme

How could I fix it?

THANK YOU
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue29418] inspect.isroutine does not return True for some bound builtin methods

2017-02-02 Thread Manuel Krebber

New submission from Manuel Krebber:

Some of the builtin methods are not recognized as such by inspect.isroutine(). 
inspect.ismethoddescriptor() only returns True for the unbound versions of the 
methods but not the bound ones.

For example:

>>> inspect.isroutine(object.__str__)
True
>>> inspect.isroutine(object().__str__)
False

The second one should also return True as it does for user-defined classes:

>>> class A:
... def f(self):
... pass
>>> inspect.isroutine(A.f)
True
>>> inspect.isroutine(A().f)
True

The types needed for that have already been added to the types module in issue 
#29377. Here is the commit: 
https://github.com/python/cpython/commit/1947d33a0a1c2ba006397579ec6235528faea9fd

--
components: Library (Lib)
messages: 286752
nosy: Wheerd, levkivskyi, yselivanov
priority: normal
severity: normal
status: open
title: inspect.isroutine does not return True for some bound builtin methods
type: behavior

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



Re: doubt loading pages

2017-02-01 Thread José Manuel Suárez Sierra
El miércoles, 1 de febrero de 2017, 11:55:11 (UTC+1), José Manuel Suárez Sierra 
 escribió:
> hello everyone,
> Im trying to make a program that takes an archive from pdb (for instance this 
> link http://www.rcsb.org/pdb/files/fasta.txt?structureIdList=5HXY
> 
> after reading it I want it to save in a list only this part of the archive:
> 
> MGSSHHSSGLVPRGSHMASMTGGQQMGRGSMPAETNEYLSRFVEYMTGERKSRYTIKEYRFLVDQFLSFMNKKPDEITPMDIERYKNFLAVKKRYSKTSQYLAIKAVKLFYKALDLRVPINLTPPKRPSHMPVYLSEDEAKRLIEAASSDTRMYAIVSVLAYTGVRVGELCNLKISDVDLQESIINVRSGKGDKDRIVIMAEECVKALGSYLDLRLSMDTDNDYLFVSNRRVRFDTSTIERMIRDLGKKAGIQKKVTPHVLRHTFATSVLRNGGDIRFIQQILGHASVATTQIYTHLNDSALREMYTQHRPRY
> 
> I have written this:
> 
> import urllib2
> 
> 
> seq=raw_input("Introduce pdb code \n")
> 
> 
> 
> seq = 
> urllib2.urlopen("http://www.rcsb.org/pdb/files/fasta.txt?structureIdList="+seq)
> print seq.read()
> 
> 
> seq.close()
> 
> 
> My question is, how do I save this into a python list?
> 
> Thank you!

What I need is to convert the whole archive into a list, how could I do it?
-- 
https://mail.python.org/mailman/listinfo/python-list


doubt loading pages

2017-02-01 Thread José Manuel Suárez Sierra
hello everyone,
Im trying to make a program that takes an archive from pdb (for instance this 
link http://www.rcsb.org/pdb/files/fasta.txt?structureIdList=5HXY

after reading it I want it to save in a list only this part of the archive:

MGSSHHSSGLVPRGSHMASMTGGQQMGRGSMPAETNEYLSRFVEYMTGERKSRYTIKEYRFLVDQFLSFMNKKPDEITPMDIERYKNFLAVKKRYSKTSQYLAIKAVKLFYKALDLRVPINLTPPKRPSHMPVYLSEDEAKRLIEAASSDTRMYAIVSVLAYTGVRVGELCNLKISDVDLQESIINVRSGKGDKDRIVIMAEECVKALGSYLDLRLSMDTDNDYLFVSNRRVRFDTSTIERMIRDLGKKAGIQKKVTPHVLRHTFATSVLRNGGDIRFIQQILGHASVATTQIYTHLNDSALREMYTQHRPRY

I have written this:

import urllib2


seq=raw_input("Introduce pdb code \n")



seq = 
urllib2.urlopen("http://www.rcsb.org/pdb/files/fasta.txt?structureIdList="+seq)
print seq.read()


seq.close()


My question is, how do I save this into a python list?

Thank you!
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue29377] Add the 'wrapper_descriptor' type to the types module

2017-02-01 Thread Manuel Krebber

Manuel Krebber added the comment:

One question I was wondering about is whether those types should be checked by 
inspect.isroutine() as well.

--

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



[issue29377] Add the 'wrapper_descriptor' type to the types module

2017-01-30 Thread Manuel Krebber

Manuel Krebber added the comment:

Okay, I added MethodDescriptorType to the types module and updated the docs. 
Hope this is okay now.

--
Added file: http://bugs.python.org/file46455/slot-wrapper-types.patch

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



[issue26355] Emit major version based canonical URLs for docs

2017-01-27 Thread Manuel Krebber

Manuel Krebber added the comment:

Sorry, I accidentally replied to the worng issue -.-

--

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



[issue29377] Add the 'wrapper_descriptor' type to the types module

2017-01-27 Thread Manuel Krebber

Manuel Krebber added the comment:

I created the last patch without commiting, so maybe this one will work 
properly with the revision tool.

--
Added file: http://bugs.python.org/file46429/slot-wrapper-types.patch

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



[issue26355] Emit major version based canonical URLs for docs

2017-01-27 Thread Manuel Krebber

Changes by Manuel Krebber <ad...@wheerd.de>:


Removed file: http://bugs.python.org/file46428/slot-wrapper-types.patch

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



[issue26355] Emit major version based canonical URLs for docs

2017-01-27 Thread Manuel Krebber

Manuel Krebber added the comment:

I create the last diff without creating a commit, so maybe this one works 
better.

--
nosy: +Wheerd
Added file: http://bugs.python.org/file46428/slot-wrapper-types.patch

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



[issue29377] Add the 'wrapper_descriptor' type to the types module

2017-01-26 Thread Manuel Krebber

Manuel Krebber added the comment:

Alright, I added some tests and tried it again with the patch.

--
Added file: http://bugs.python.org/file46427/slot-wrapper-types.patch

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



[issue29377] Add the 'wrapper_descriptor' type to the types module

2017-01-26 Thread Manuel Krebber

Manuel Krebber added the comment:

I added some docs, but I am not sure what I would want to test here. There are 
no tests for types.BuiltinMethodType either. Maybe the string representation of 
it could be tested, but an isinstance test seems pretty redundant. I hope this 
patch file works better, I created the last one with git diff.

--
Added file: http://bugs.python.org/file46425/slot-wrapper-types.patch

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



[issue29377] Add the 'wrapper_descriptor' type to the types module

2017-01-26 Thread Manuel Krebber

Manuel Krebber added the comment:

I would suggest the names SlotWrapperType and MethodWrapperType because I think 
they match their string representations the closest.

For checking whether something is a method/function one could also use 
inspect.isroutine (or inspect.ismethoddescriptor), but that is inconsistent 
with regards to builtin and python methods:

>>> import inspect
>>> inspect.isroutine(object.__init__)
True
>>> inspect.isroutine(object().__init__)
False
>>> class A:
...   def f(self):
... pass
...
>>> inspect.isroutine(A.f)
True
>>> inspect.isroutine(A().f)
True

Maybe a function to detect the second case is needed.

--

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



[issue29377] Add the 'wrapper_descriptor' type to the types module

2017-01-26 Thread Manuel Krebber

Changes by Manuel Krebber <ad...@wheerd.de>:


--
keywords: +patch
Added file: 
http://bugs.python.org/file46420/0001-Added-SlotWrapperType-and-MethodWrapperType-to-the-t.patch

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



[issue29377] Add the 'wrapper_descriptor' type to the types module

2017-01-26 Thread Manuel Krebber

New submission from Manuel Krebber:

There currently is no type in the types module for the slot 
wrappers/wrapper_descriptor types.

I would like to have something like

WrapperDescriptor = type(object.__init__)

added to it (or maybe even add it to MethodType). This would be helpful to 
check more easily if some object is a method.

I can create a pull request for this if desired.

--
components: Library (Lib)
messages: 286304
nosy: Wheerd
priority: normal
severity: normal
status: open
title: Add the 'wrapper_descriptor' type to the types module
type: enhancement

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



Doubt with matrix

2017-01-12 Thread José Manuel Suárez Sierra
Hello, I want to  go over matrix indexs with this code:
def comparador2(a, b):
c3 = ["0"]  # variables
x = -1  # contador de letras aniadidas a c3
i = 0  # contador bucle secuencia a
j = 0  # contador bucle secuencia b
l1 = len(a)
l2 = len(b)
cont = []  # contador de ciclos poner primer termino a 0
k = -1  # contador de 0 y 1 aniadidos a cont

if l1 > l2:  # metodo de la burbuja que elige la secuencia mas larga 
REVISAR puede ser alreves
aux = a
a = b
b = aux

for a[i] in a:  # en la secuencia1 recorro los elementos

for b[j] in b :

if a[i] == b[j] and i <= l1 and j <= l2:  # Si el elemento i de 
la seq1 es igual que el elemento j de la seq2, y el numero de elementos en i y 
j es menor o igual que la longitud de las secuencias 1 y 2
c3.append(a[i])  # se aniade el elemento comun a la lista c3
x = x + 1
k = k + 1
j = j + 1  # se pasa el elemento siguiente de la seq2
i = i + 1  # se pasa el elemento siguiente de la seq1
cont.append(1)



elif a[i] != b[
j] and i <= l1 and j <= l2:  # si no coinciden estos 
elementos se pasa al siguiente elemento de la lista 2
j = j + 1
k = k + 1
cont.append(0)
if cont[k] == 0 and cont[k - 1] == 1 and cont[k - 2] == 0 
and k >= 2:
i = i - 1
j = j - 1
else:
k = k + 1
cont.append(0)
if i == l2:
i = i + 1
j = 0


return c3

and this issue is prompted:
IndexError: list assignment index out of range

How could I fix it?

Thank you for your assistance
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with this code

2017-01-09 Thread José Manuel Suárez Sierra
El lunes, 9 de enero de 2017, 14:09:09 (UTC+1), José Manuel Suárez Sierra  
escribió:
> Hello, I am trying to make a code wich compares between 2 or several 
> sequences (lists). It compares every element in a list with another list 
> elements. For example, if we have a list_a=["a","b","c","d"] and 
> list_b=["a","b"] I want to obtain a new list_c containing elements that match 
> between these lists (a and b here), but, if for instance list_b were 
> ["a","c"] the program must not store this data because they are not in same 
> order.
> 
> Said this, I wrote this code but it doesnt work:
> 
> if __name__ == "__main__":
> 
> 
> def compare(a, b):
> 
> i = 0
> j = 0
> c1 = []
> 
> while a[i] == b[j]:
> c1.append(a[i])
> j = j+1
> i=i+1
> 
> return c1
> 
> 
> 
> 
> cadena_1=raw_input("Introduce list 1 \n")
> cadena_2 = raw_input("Introduce list 2 \n")
> 
> 
> transf1=list(cad_1) 
> transf2 = list(cad_2)
> 
> 
> print compare(transf1,transf2)
> 
> 
> 
> 
> Thank you

Thank you!

Here is my code, I dont understand why it doesnt work very well:
if __name__ == "__main__":


cadena_1 = raw_input("Introduce la cadena 1 \n")
cadena_2 = raw_input("Introduce la cadena 2 \n")
# n=input("De cuantas letras quieres hacer la comparacion?\n")

transf1 = list(cadena_1)  
transf2 = list(cadena_2)
l1=len(transf1)
l2=len(transf2)
c3=[]
i=0
j=0


for transf1[i] in transf1:  
for transf2[j] in transf2:   
if transf1[i]==transf2[j]: 
c3.append(transf1[i])   
i=i+1   
j=j+1   
else:  
j=j+1   

print c3

This is the traceback:
line 18, in 
   for transf2[j] in transf2:
IndexError: list assignment index out of range

If I have initialized j=0 (such as i) why does it not work?
I want the script to read sequence 1 and compares every element inside it with 
elements in sequence 2 no mattering where it matches.

Thank you!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with this code

2017-01-09 Thread José Manuel Suárez Sierra
El lunes, 9 de enero de 2017, 14:09:09 (UTC+1), José Manuel Suárez Sierra  
escribió:
> Hello, I am trying to make a code wich compares between 2 or several 
> sequences (lists). It compares every element in a list with another list 
> elements. For example, if we have a list_a=["a","b","c","d"] and 
> list_b=["a","b"] I want to obtain a new list_c containing elements that match 
> between these lists (a and b here), but, if for instance list_b were 
> ["a","c"] the program must not store this data because they are not in same 
> order.
> 
> Said this, I wrote this code but it doesnt work:
> 
> if __name__ == "__main__":
> 
> 
> def compare(a, b):
> 
> i = 0
> j = 0
> c1 = []
> 
> while a[i] == b[j]:
> c1.append(a[i])
> j = j+1
> i=i+1
> 
> return c1
> 
> 
> 
> 
> cadena_1=raw_input("Introduce list 1 \n")
> cadena_2 = raw_input("Introduce list 2 \n")
> 
> 
> transf1=list(cad_1) 
> transf2 = list(cad_2)
> 
> 
> print compare(transf1,transf2)
> 
> 
> 
> 
> Thank you

Thanks for your reply,
I wrote this code:
def comparar(cad1, cad2):
i = 0
j = 0
cad3 = []
k = True

for cad1[i] in cad1:
k = True
for cad2[j] in cad2:
while cad1[i] == cad2[j] and i<= len(cad1) and j <= len(cad2):
cad3.append(cad1[i])
i = i + 1
j = j + 1

if cad1[i] != cad2[j]:
k = False
i = i + 1
return cad3

This is a function, another important thing is the order of elements, it must 
be ordered as it appears in one of the lists, in your example, my function must 
return a list with elements 1,2,5 in that order.

I cant find my mistake in these function I wrote you above.

Thank you very much
-- 
https://mail.python.org/mailman/listinfo/python-list


Help with this code

2017-01-09 Thread José Manuel Suárez Sierra
Hello, I am trying to make a code wich compares between 2 or several sequences 
(lists). It compares every element in a list with another list elements. For 
example, if we have a list_a=["a","b","c","d"] and list_b=["a","b"] I want to 
obtain a new list_c containing elements that match between these lists (a and b 
here), but, if for instance list_b were ["a","c"] the program must not store 
this data because they are not in same order.

Said this, I wrote this code but it doesnt work:

if __name__ == "__main__":


def compare(a, b):

i = 0
j = 0
c1 = []

while a[i] == b[j]:
c1.append(a[i])
j = j+1
i=i+1

return c1




cadena_1=raw_input("Introduce list 1 \n")
cadena_2 = raw_input("Introduce list 2 \n")


transf1=list(cad_1) 
transf2 = list(cad_2)


print compare(transf1,transf2)




Thank you
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28773] typing.FrozenSet missing in documentation.

2016-11-22 Thread Manuel Krebber

Manuel Krebber added the comment:

I updated the patch to add reflect the covariance.

--
Added file: http://bugs.python.org/file45606/frozenset-doc.patch

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



[issue28773] typing.FrozenSet missing in documentation.

2016-11-22 Thread Manuel Krebber

New submission from Manuel Krebber:

The typing.FrozenSet is missing in the typing module documentation. I have 
attached a patch that adds it similar to the typing.Set which is already in the 
documentation.

--
components: Library (Lib)
files: frozenset-doc.patch
keywords: patch
messages: 281476
nosy: Wheerd
priority: normal
severity: normal
status: open
title: typing.FrozenSet missing in documentation.
type: enhancement
versions: Python 3.5, Python 3.6, Python 3.7
Added file: http://bugs.python.org/file45601/frozenset-doc.patch

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



[issue28404] Logging SyslogHandler not appending '\n' to the end

2016-10-17 Thread José Manuel

José Manuel added the comment:

Sorry to bother you again, but I've tested this not only with Fluentd, but with 
a RSYSLOG server and it does not work with TCP except if you manually add the 
trailer LF character. Other than that, UDP default transport protocol has no 
issues and works fine with both systems. Here's my simple code:

---
sHandler = logging.handlers.SysLogHandler(address=(address[0], address[1]), 
socktype = socket.SOCK_STREAM)
sHandler.setFormatter(logging.Formatter(fmt=MSG_SYSLOG_FORMAT, 
datefmt=DATE_FMT))
self.addHandler(sHandler)
---

After reading RFC 6587 I think the SyslogHandler class should implement at 
least one of the framing mechanisms proposed by this RFC, meant for TCP 
transmission:
- Octet counting
- Trailer character (e.g. LF)

Besides, I've being checking out the library "pyloggr" 
(https://github.com/stephane-martin/pyloggr) and they are implementing both 
mechanisms. As for SyslogHandler, it will be as simple as adding another field 
to the class constructor (use_delimiter?) and to add these lines to the emit 
code (it works):

---
if (self.use_delimiter):
msg = msg + '\n'
else:
msg = str(len(msg)) + ' ' + msg # default behavior
---

Thank you again

--
status: closed -> pending

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



[issue28404] Logging SyslogHandler not appending '\n' to the end

2016-10-10 Thread José Manuel

José Manuel added the comment:

After reading the RFC5424 it seems that there is no such "new line message 
delimiter":


4.3.1.  Message Length

   The message length is the octet count of the SYSLOG-MSG in the
   SYSLOG-FRAME.  A transport receiver MUST use the message length to delimit a 
syslog message


So I think it must be a Fluentd error. This is what caused my confusion:

>From in_syslog.rb 
>(https://github.com/athenahealth/fluent-plugin-newsyslog/blob/master/lib/fluent/plugin/in_newsyslog.rb):


# syslog family add "\n" to each message and this seems only way to split 
messages in tcp stream
Coolio::TCPServer.new(@bind, @port, SocketUtil::TcpHandler, log, "\n", callback)


--

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



[issue28404] Logging SyslogHandler not appending '\n' to the end

2016-10-10 Thread José Manuel

New submission from José Manuel:

I'm using SyslogHandler from logging.handlers to send syslog messages to a 
Fluentd input 
(https://github.com/fluent/fluentd/blob/master/lib/fluent/plugin/in_syslog.rb), 
both in TCP and UDP. UDP works fine, but TCP does not work. 

The "problem" is that the handler is not ending messages with a new line '\n' 
character (I realized that using tcpdump). I've temporarily added this to line 
855 of handlers.py: 
msg = prio + msg + '\n' 
And now is working. 

Now I'm confused because maybe this is not an issue but a problem of Fluentd. 
For the time, I will create a new class extending SyslogHandler and override 
the emit function.

Thank you for your time.

--
components: Library (Lib)
messages: 278412
nosy: elelement
priority: normal
severity: normal
status: open
title: Logging SyslogHandler not appending '\n' to the end
type: behavior
versions: Python 2.7

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



[issue28296] Add __le__ and __ge__ to collections.Counter

2016-09-28 Thread Manuel Krebber

Manuel Krebber added the comment:

Oh, I should have searched properly before creating this ticket. Sorry about 
that. I guess I will be subclassing Counter in my project then, to get this 
functionality... Only problem is, that when using the builtin __add__ etc. of 
my Counter subclass, I will get a Counter instance, that does not support 
ordering... So I guess I will not use it at all.

--

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



[issue28296] Add __le__ and __ge__ to collections.Counter

2016-09-28 Thread Manuel Krebber

New submission from Manuel Krebber:

I would really like there to be comparison operators for collection.Counter 
similar to the ones for sets. While you can now use minus to some degree for 
that comparison, it is very inefficient. I have attached an implementation of 
__ge__ and __le__ as a patch. I could also provide the necessary additions to 
the documentation, if that is desired.

--
components: Library (Lib)
files: counter_comparison.patch
keywords: patch
messages: 277597
nosy: Wheerd
priority: normal
severity: normal
status: open
title: Add __le__ and __ge__ to collections.Counter
type: enhancement
versions: Python 3.5, Python 3.6, Python 3.7
Added file: http://bugs.python.org/file44858/counter_comparison.patch

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



[issue27393] Command to activate venv in Windows has wrong path

2016-06-26 Thread Manuel Kaufmann

New submission from Manuel Kaufmann:

The `venv` module has a bug in the command to activate it on Windows.

In 3.3 and 3.4 the bar used is wrong: `/` instead `\`

* https://docs.python.org/3.4/library/venv.html#creating-virtual-environments
* https://docs.python.org/3.3/library/venv.html#creating-virtual-environments


In 3.5 and 3.6 that section was converted to a table with the commands and they 
are missing the `\` in the command path:

* https://docs.python.org/3.5/library/venv.html#creating-virtual-environments
* https://docs.python.org/dev/library/venv.html#creating-virtual-environments

--
assignee: docs@python
components: Documentation
files: venv-windows-command.patch
keywords: patch
messages: 269299
nosy: docs@python, facundobatista, humitos
priority: normal
severity: normal
status: open
title: Command to activate venv in Windows has wrong path
type: enhancement
versions: Python 3.3, Python 3.4, Python 3.5, Python 3.6
Added file: http://bugs.python.org/file43543/venv-windows-command.patch

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



[issue26367] importlib.__import__ does not fail for invalid relative import

2016-02-21 Thread Manuel Jacob

Manuel Jacob added the comment:

I think the "What's New" entry has two typos.  It should be 
`importlib.__import__()` instead of `importlib.__init__()` and SystemError 
instead of RuntimeError.

--

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



[issue26367] importlib.__import__ does not fail for invalid relative import

2016-02-18 Thread Manuel Jacob

Manuel Jacob added the comment:

Done.  I'm a bit surprised this wasn't necessary for my previous two patches, 
but they were even more trival than this one. ;)

Do we have to wait until my tracker profile is updated?

--

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



[issue26367] importlib.__import__ does not fail for invalid relative import

2016-02-18 Thread Manuel Jacob

Manuel Jacob added the comment:

(For some reason, I forgot to submit the previous comment).

The attached patches fix the issue (one for the 3.5 branch, one for the default 
branch) by bringing importlib.__import__ closer to the builtin __import__.

The extra code in the default / 3.6 branch is because of the changes from 
issue18018.

--

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



[issue26367] importlib.__import__ does not fail for invalid relative import

2016-02-16 Thread Manuel Jacob

Changes by Manuel Jacob <m...@manueljacob.de>:


Added file: http://bugs.python.org/file41938/relimport-3.6.patch

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



[issue26367] importlib.__import__ does not fail for invalid relative import

2016-02-16 Thread Manuel Jacob

Changes by Manuel Jacob <m...@manueljacob.de>:


--
keywords: +patch
Added file: http://bugs.python.org/file41937/relimport-3.5.patch

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



[issue26367] importlib.__import__ does not fail for invalid relative import

2016-02-15 Thread Manuel Jacob

New submission from Manuel Jacob:

Python 3.6.0a0 (default:6c6f7dff597b, Feb 16 2016, 01:24:51) 
[GCC 5.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import importlib
>>> importlib.__import__('array', globals(), locals(), level=1)

>>> __import__('array', globals(), locals(), level=1)
Traceback (most recent call last):
  File "", line 1, in 
ImportError: attempted relative import with no known parent package

Instead of failing, importlib.__import__ returns a module with a wrong name.  
This happens with both built-in modules and pure python modules.  However it 
fails when replacing 'array' with 'time' (this seems to be related to whether 
the module is in Modules/Setup.dist).

--
messages: 260338
nosy: brett.cannon, eric.snow, mjacob, ncoghlan
priority: normal
severity: normal
status: open
title: importlib.__import__ does not fail for invalid relative import
type: behavior
versions: Python 3.3, Python 3.4, Python 3.5, Python 3.6

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



Re: Supply condition in function call

2015-03-29 Thread Manuel Graune
Cameron Simpson c...@zip.com.au writes:


 In xterm and I think several other X11 terminals, Shift-Insert
 pastes. I found that _way_ more convenient than middle click. The
 mouse is not your friend.


This information might prove as useful as your answer to my
original question. ;-)

Thanks for both!

-- 
A hundred men did the rational thing. The sum of those rational choices was
called panic. Neal Stephenson -- System of the world
http://www.graune.org/GnuPG_pubkey.asc
Key fingerprint = 1E44 9CBD DEE4 9E07 5E0A  5828 5476 7E92 2DB4 3C99
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Supply condition in function call

2015-03-27 Thread Manuel Graune
Cameron Simpson c...@zip.com.au writes:

 This passes the local variables inside test1() to condition as a
 single parameter. Now, I grant that vars['i'] is a miracle of
 tediousness. So consider this elaboration:

  from collections import namedtuple

  condition_test = lambda vars: vars.i + vars.j  4

  def test1(a, b, condition):
for i, j in zip(a,b):
  c = i + j
  vars = locals()
  varnames = list(vars.keys())
  varstupletype = namedtuple(locals, varnames)
  varstuple = varstupletype(*[ vars[k] for k in varnames ])
  if condition(varstuple):
print(Foo)

 Here, the condition_test function/lambda uses vars.i and vars.j,
 which i think you'll agree is easier to read and write. The price is
 the construction of a namedtuple to hold the variable name
 values. See:

  https://docs.python.org/3/library/collections.html#collections.namedtuple


This is probably getting off topic, but is there any relevant difference
or benefit to using namedtuple instead of something like types.SimpleNamespace?

https://docs.python.org/3/library/types.html#additional-utility-classes-and-functions



-- 
A hundred men did the rational thing. The sum of those rational choices was
called panic. Neal Stephenson -- System of the world
http://www.graune.org/GnuPG_pubkey.asc
Key fingerprint = 1E44 9CBD DEE4 9E07 5E0A  5828 5476 7E92 2DB4 3C99
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Supply condition in function call

2015-03-27 Thread Manuel Graune
Peter Otten __pete...@web.de writes:

 Cameron Simpson wrote:

   test1([0,1,2,3], [1,2,3,4], condition_test)
 
 This passes the local variables inside test1() to condition as a single
 parameter. Now, I grant that vars['i'] is a miracle of tediousness. So
 consider this elaboration:
 
   from collections import namedtuple
 
   condition_test = lambda vars: vars.i + vars.j  4
 
   def test1(a, b, condition):
 for i, j in zip(a,b):
   c = i + j
   vars = locals()
   varnames = list(vars.keys())

 instead or pass the list of arguments explicitly, optionally with some 
 inspect fallback:

 $ cat pass_condition_inspect.py
 import inspect

 def test3(a, b, condition, args=None):
 if args is None:
 args = inspect.getargspec(condition).args

 for i, j in zip(a,b):
 c = i + j
 _locals = locals()
 if condition(*[_locals[name] for name in args]):
 print(Foo, i, j)

 def condition(c, i):
 return i * i  c

 test3([1, 2, 3], [2, 3, 4], condition)
 print(---)
 # note reverse order of argument names
 test3([1, 2, 3], [2, 3, 4], condition, [i, c]) 
 $ python3 pass_condition_inspect.py
 Foo 3 4
 ---
 Foo 1 2
 Foo 2 3
 Foo 3 4


I'm just comparing the different solutions. For most of them, the
logic and the costs/benefits are pretty clear to me. Can you
elaborate on your code? I'm not clear what you are achieving with
explicitly passing the arguments instead of simply passing some
variant of the complete locals()-dictionary.


-- 
A hundred men did the rational thing. The sum of those rational choices was
called panic. Neal Stephenson -- System of the world
http://www.graune.org/GnuPG_pubkey.asc
Key fingerprint = 1E44 9CBD DEE4 9E07 5E0A  5828 5476 7E92 2DB4 3C99
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Supply condition in function call

2015-03-26 Thread Manuel Graune
Gary Herron gher...@digipen.edu writes:

 On 03/25/2015 10:29 AM, Manuel Graune wrote:

 def test1(a, b, condition=True):
  for i,j in zip(a,b):
  c=i+j
  if eval(condition):
 print(Foo)

 test1([0,1,2,3],[1,2,3,4],i+j 4)
 print(Bar)
 test1([0,1,2,3],[1,2,3,4],c 4)
 print(Bar)
 test1([0,1,2,3],[1,2,3,4],a[i] 2)


 This is nicely done with lambda expressions:

 To pass in a condition as a function:
test1([0,1,2,3],[1,2,3,4], lambda i,j: i+j4)

 To check the condition in the function:
 if condition(i,j):

This seems to be the right direction and a good solution for simple
cases. Unfortunately this:

 To get the full range of conditions, you will need to include all the 
 variables needed by any condition you can imagine.  So the above suggestions 
 may need to be expanded to:
  ... lambda i,j,a,b: ... or whatever

 and
   ... condition(i,j,a,b) ... or whatever


is not as concise as I had hoped for. Is there a possibility to do
(maybe with a helper function inside the main function's body) solve
this more elegantly? I'm thinking of some combination of e. g. **kwargs,
dir() and introspection.

Regards,

Manuel



-- 
A hundred men did the rational thing. The sum of those rational choices was
called panic. Neal Stephenson -- System of the world
http://www.graune.org/GnuPG_pubkey.asc
Key fingerprint = 1E44 9CBD DEE4 9E07 5E0A  5828 5476 7E92 2DB4 3C99
-- 
https://mail.python.org/mailman/listinfo/python-list


Supply condition in function call

2015-03-25 Thread Manuel Graune
Hi,

I'm looking for a way to supply a condition to an if-statement inside a
function body when calling the function. I can sort of get what I want
with using eval (see code below) but I would like to achieve this in a
safer way. If there is a solution which is safer while being
less flexible, that would be fine. Also, supplying the condition as a
string is not necessary. What I want to do is basically like this:

def test1(a, b, condition=True):
for i,j in zip(a,b):
c=i+j
if eval(condition):
   print(Foo)

test1([0,1,2,3],[1,2,3,4],i+j 4)
print(Bar)
test1([0,1,2,3],[1,2,3,4],c 4)
print(Bar)
test1([0,1,2,3],[1,2,3,4],a[i] 2)
print(Bar)
test1([0,1,2,3],[1,2,3,4])

Resulting in

Foo
Foo
Bar
Foo
Foo
Bar
Foo
Bar
Foo
Foo
Foo
Foo

Thanks for your help

Regards,

Manuel

-- 
A hundred men did the rational thing. The sum of those rational choices was
called panic. Neal Stephenson -- System of the world
http://www.graune.org/GnuPG_pubkey.asc
Key fingerprint = 1E44 9CBD DEE4 9E07 5E0A  5828 5476 7E92 2DB4 3C99
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Supply condition in function call

2015-03-25 Thread Manuel Graune
Joel Goldstick joel.goldst...@gmail.com writes:

 On Wed, Mar 25, 2015 at 1:29 PM, Manuel Graune manuel.gra...@koeln.de wrote:

 def test1(a, b, condition=True):
 for i,j in zip(a,b):
 c=i+j
 if eval(condition):
print(Foo)

 I'm not sure I understand your question, but condition will evaluate
 to True or False regardless, so:
  if condition:
 print (Foo)
  else:
 print (Bar)


The point is (see examples below) to specify the condition that is to be
evaluated when calling the function (as opposed to when stating the function). 

 eval can be dangerous as someone could put some unknown command with
 side effects in condition


I know that. That's why I'm looking for an alternative. ;-)

 test1([0,1,2,3],[1,2,3,4],i+j 4)
 print(Bar)
 test1([0,1,2,3],[1,2,3,4],c 4)
 print(Bar)
 test1([0,1,2,3],[1,2,3,4],a[i] 2)

 Resulting in

 Foo
 Foo
 Bar
 Foo
 Foo
 Bar
 Foo

Regards,

Manuel

-- 
A hundred men did the rational thing. The sum of those rational choices was
called panic. Neal Stephenson -- System of the world
http://www.graune.org/GnuPG_pubkey.asc
Key fingerprint = 1E44 9CBD DEE4 9E07 5E0A  5828 5476 7E92 2DB4 3C99
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23742] expandvars removes single quotes ( ' )

2015-03-22 Thread Manuel Vögele

New submission from Manuel Vögele:

When executing

os.path.expandvars(%SystemDrive%\\Foo'Bar)

the function erases the ' returning

'C:\\FooBar'

using Python 3.4.3 on Windows 7

--
components: Library (Lib)
messages: 238968
nosy: manuel_v, serhiy.storchaka
priority: normal
severity: normal
status: open
title: expandvars removes single quotes ( ' )
type: behavior
versions: Python 3.4

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



[issue17576] PyNumber_Index() is not int-subclass friendly (or operator.index() docos lie)

2015-02-24 Thread Manuel Jacob

Manuel Jacob added the comment:

Maybe I'm missing something, but it seems to me that 
test_int_subclass_with_index() is testing for the exactly wrong behaviour.  
Isn't the point of this issue that operator.index(a) should be equal to 
a.__index__()?  Why are the tests checking that they are different?

--
nosy: +mjacob

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



  1   2   3   >