[issue46428] 3.11.0a3 vs 3.11.0a4

2022-01-18 Thread YoSTEALTH

New submission from YoSTEALTH :

Getting compilation error for an Cython project, since upgrade from `3.11.0a3` 
to `3.11.0a4`, same code.

/opt/python/3.11/bin/python3 setup.py build_ext --inplace -j18 clean --all

# 3.11.0a3
# 
prefix/usr
includedir/usr/include
libdir/usr/lib
libdevdir /usr/lib
relativelibdir
mandir/usr/man
datadir   /usr/share
stringop_overflow yes
array_bounds  yes
__kernel_rwf_tyes
__kernel_timespec yes
open_how  yes
statx yes
C++   yes
has_ucontext  yes
has_memfd_create  yes
liburing_nolibc   yes
CCgcc
CXX   g++
Compiling src/uring.pyx because it depends on 
/opt/python/3.11/lib/python3.11/site-packages/Cython/Includes/libc/s
tring.pxd.
[1/1] Cythonizing src/uring.pyx
running build_ext
building 'uring._uring' extension
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC 
-Ilibs/liburing/src/include -I/opt/python/3.11/inc
lude/python3.11 -c libs/liburing/src/nolibc.c -o 
build/temp.linux-x86_64-3.11/libs/liburing/src/nolibc.o -Os -g0 -
include libs/liburing/config-host.h
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC 
-Ilibs/liburing/src/include -I/opt/python/3.11/inc
lude/python3.11 -c libs/liburing/src/queue.c -o 
build/temp.linux-x86_64-3.11/libs/liburing/src/queue.o -Os -g0 -in
clude libs/liburing/config-host.h
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC 
-Ilibs/liburing/src/include -I/opt/python/3.11/inc
lude/python3.11 -c libs/liburing/src/register.c -o 
build/temp.linux-x86_64-3.11/libs/liburing/src/register.o -Os -
g0 -include libs/liburing/config-host.h
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC 
-Ilibs/liburing/src/include -I/opt/python/3.11/inc
lude/python3.11 -c libs/liburing/src/setup.c -o 
build/temp.linux-x86_64-3.11/libs/liburing/src/setup.o -Os -g0 -in
clude libs/liburing/config-host.h
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC 
-Ilibs/liburing/src/include -I/opt/python/3.11/inc
lude/python3.11 -c src/uring.c -o build/temp.linux-x86_64-3.11/src/uring.o -Os 
-g0 -include libs/liburing/config-h
ost.h
gcc -pthread -shared build/temp.linux-x86_64-3.11/libs/liburing/src/nolibc.o 
build/temp.linux-x86_64-3.11/libs/lib
uring/src/queue.o build/temp.linux-x86_64-3.11/libs/liburing/src/register.o 
build/temp.linux-x86_64-3.11/libs/libu
ring/src/setup.o build/temp.linux-x86_64-3.11/src/uring.o -o 
build/lib.linux-x86_64-3.11/uring/_uring.cpython-311-
x86_64-linux-gnu.so
copying 
build/lib.linux-x86_64-3.11/uring/_uring.cpython-311-x86_64-linux-gnu.so -> 
uring
running clean
removing 'build/temp.linux-x86_64-3.11' (and everything under it)
removing 'build/lib.linux-x86_64-3.11' (and everything under it)
removing 'build/bdist.linux-x86_64' (and everything under it)
'build/scripts-3.11' does not exist -- can't clean it
removing 'build'


# 3.11.0a4
# 
prefix/usr
includedir/usr/include
libdir/usr/lib
libdevdir /usr/lib
relativelibdir
mandir/usr/man
datadir   /usr/share
stringop_overflow yes
array_bounds  yes
__kernel_rwf_tyes
__kernel_timespec yes
open_how  yes
statx yes
C++   yes
has_ucontext  yes
has_memfd_create  yes
liburing_nolibc   yes
CCgcc
CXX   g++
Compiling src/uring.pyx because it depends on 
/opt/python/3.11/lib/python3.11/site-packages/Cython/Includes/libc/string.pxd.
[1/1] Cythonizing src/uring.pyx
running build_ext
building 'uring._uring' extension
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC 
-Ilibs/liburing/src/include -I/opt/python/3.11/include/python3.11 -c 
libs/liburing/src/nolibc.c -o 
build/temp.linux-x86_64-3.11/libs/liburing/src/nolibc.o -Os -g0 -include 
libs/liburing/config-host.h
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC 
-Ilibs/liburing/src/include -I/opt/python/3.11/include/python3.11 -c 
libs/liburing/src/queue.c -o 
build/temp.linux-x86_64-3.11/libs/liburing/src/queue.o -Os -g0 -include 
libs/liburing/config-host.h
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC 
-Ilibs/liburing/src/include -I/opt/python/3.11/include/python3.11 -c 
libs/liburing/src/register.c -o 
build/temp.linux-x86_64-3.11/libs/liburing/src/register.o -Os -g0 -include 
libs/liburing/config-host.h
gcc -pthread -Wsign-compare 

[issue46428] Cython Build: '_PyErr_StackItem’ has no member named ‘exc_traceback’

2022-01-18 Thread YoSTEALTH


YoSTEALTH  added the comment:

Thanks @iritkatriel will close this, seems like people are aware of this bug as 
working on fix it :)

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

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



[issue39053] Hide manually raised exception formatting

2019-12-15 Thread YoSTEALTH


New submission from YoSTEALTH :

class Some_Class:

def error(self):
if not getattr(self, 'boo', None):
raise Exception(f'`class {self.__class__.__name__}:` raised some 
error!')


something = Some_Class()
something.error()


# This is how Error looks
# ---
Traceback (most recent call last):
  File "/test.py", line 9, in 
something.error()
  File "/test.py", line 5, in error
raise Exception(f'`class {self.__class__.__name__}:` raised some error!')
Exception: `class Some_Class:` raised some error!


# This is how Error should look
# -
Traceback (most recent call last):
  File "/test.py", line 9, in 
something.error()
  File "/test.py", line 5, in error
raise Exception(...)
Exception: `class Some_Class:` raised some error!


When a developer manually raises an error they want the user/developer 
debugging the error to see the final, nicely formatted error message itself 
"Exception: `class Some_Class:` raised some error!" not the ugly formating of 
the error message itself "raise Exception(f'`class {self.__class__.__name__}:` 
raised some error!')" which can also lead to confusion, thus it should be 
hidden as "raise Exception(...)"

It could also be said that "raise Exception(...)" shouldn't even be shown but 
what raises this error condition "if not getattr(self, 'boo', None):" but this 
seems more work so i am keeping it simple by saying lets just hide the ugly 
formatting part.

--
components: Interpreter Core
messages: 358413
nosy: YoSTEALTH
priority: normal
severity: normal
status: open
title: Hide manually raised exception formatting
versions: Python 3.9

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



[issue34938] Fix mimetype.init() to account for from import

2019-12-20 Thread YoSTEALTH


YoSTEALTH  added the comment:

I didn't receive any notification of replay on this topic.

`_default_mime_types()` should never have been a function. This function should 
be safe to remove as its an internal function. This would avoid unneeded 
function call and globals used.

Stuff like `_suffix_map_default` could be constants like `SUFFIX_MAP_DEFAULT` 
with `suffix_map = SUFFIX_MAP_DEFAULT.copy()`

Ashley if you feel like making these changes (optional)

--

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



[issue37509] OSError preadv()

2019-12-25 Thread YoSTEALTH


YoSTEALTH  added the comment:

I am closing this topic as its right for python to raise OSError as `-errno` 
must be assigned to e.g. `OSError(-errno, os.strerror(-errno))` to raise 
appropriate exception.

--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

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



[issue39234] `enum.auto()` incrementation value not specified.

2020-01-06 Thread YoSTEALTH


New submission from YoSTEALTH :

# enum in C
# -
enum {
a,
b,
c
}
# a = 0
# b = 1
# b = 2

# enum in Python
# --
class Count(enum.IntEnum):
a = enum.auto()
b = enum.auto()
c = enum.auto()
# a = 1
# b = 2
# b = 3


I am not sure why the `enum.auto()` starts with 1 in Python but this has just 
wasted a week worth of my time.

--
assignee: docs@python
components: Documentation
messages: 359452
nosy: YoSTEALTH, docs@python
priority: normal
severity: normal
status: open
title: `enum.auto()` incrementation value not specified.
versions: Python 3.6, Python 3.7, Python 3.8, Python 3.9

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



[issue39234] `enum.auto()` incrementation value not specified.

2020-01-06 Thread YoSTEALTH


Change by YoSTEALTH :


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

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



[issue39234] `enum.auto()` incrementation value not specified.

2020-01-06 Thread YoSTEALTH


Change by YoSTEALTH :


--
pull_requests: +17294
pull_request: https://github.com/python/cpython/pull/17878

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



[issue39673] TimeoutError

2020-02-18 Thread YoSTEALTH


New submission from YoSTEALTH :

import os


try:
no = -62
raise OSError(-no, os.strerror(-no))
except TimeoutError:
print('Success')
except OSError as e:
print('Failed:', e)
# Failed: [Errno 62] Timer expired


Shouldn't `TimeoutError` catch this error?

--
messages: 362187
nosy: YoSTEALTH
priority: normal
severity: normal
status: open
title: TimeoutError
type: behavior
versions: Python 3.8

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



[issue39673] TimeoutError

2020-02-18 Thread YoSTEALTH


YoSTEALTH  added the comment:

Since I provide `OSError` with appropriate `errono`, it raises that error for 
example:

import os


try:
no = -11
raise OSError(-no, os.strerror(-no))
except BlockingIOError as e:
print('Success:', e)
# Success: [Errno 11] Resource temporarily unavailable
except OSError as e:
print('Failed:', e)

should work the same to raise `TimeoutError` as well

--

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



[issue39673] TimeoutError

2020-02-18 Thread YoSTEALTH


YoSTEALTH  added the comment:

First example prints
# Failed: [Errno 62] Timer expired

Second example prints
# Success: [Errno 11] Resource temporarily unavailable

--

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



[issue39673] TimeoutError

2020-02-18 Thread YoSTEALTH


YoSTEALTH  added the comment:

I am on Linux 5.5.2-1-MANJARO

>>> sorted(errno.errorcode.items())
[(1, 'EPERM'), (2, 'ENOENT'), (3, 'ESRCH'), (4, 'EINTR'), (5, 'EIO'), (6, 
'ENXIO'), (7, 'E2BIG'), (8, 'ENOEXEC'), (9, 'EBADF'), (10, 'ECHILD'), (11, 
'EAGAIN'), (12, 'ENOMEM'), (13, 'EACCES'), (14, 'EFAULT'), (15, 'ENOTBLK'), 
(16, 'EBUSY'), (17, 'EEXIST'), (18, 'EXDEV'), (19, 'ENODEV'), (20, 'ENOTDIR'), 
(21, 'EISDIR'), (22, 'EINVAL'), (23, 'ENFILE'), (24, 'EMFILE'), (25, 'ENOTTY'), 
(26, 'ETXTBSY'), (27, 'EFBIG'), (28, 'ENOSPC'), (29, 'ESPIPE'), (30, 'EROFS'), 
(31, 'EMLINK'), (32, 'EPIPE'), (33, 'EDOM'), (34, 'ERANGE'), (35, 'EDEADLOCK'), 
(36, 'ENAMETOOLONG'), (37, 'ENOLCK'), (38, 'ENOSYS'), (39, 'ENOTEMPTY'), (40, 
'ELOOP'), (42, 'ENOMSG'), (43, 'EIDRM'), (44, 'ECHRNG'), (45, 'EL2NSYNC'), (46, 
'EL3HLT'), (47, 'EL3RST'), (48, 'ELNRNG'), (49, 'EUNATCH'), (50, 'ENOCSI'), 
(51, 'EL2HLT'), (52, 'EBADE'), (53, 'EBADR'), (54, 'EXFULL'), (55, 'ENOANO'), 
(56, 'EBADRQC'), (57, 'EBADSLT'), (59, 'EBFONT'), (60, 'ENOSTR'), (61, 
'ENODATA'), (62, 'ETIME'), (63, 'ENOSR'), (64, 'ENONET'), (65, 'ENOPKG')
 , (66, 'EREMOTE'), (67, 'ENOLINK'), (68, 'EADV'), (69, 'ESRMNT'), (70, 
'ECOMM'), (71, 'EPROTO'), (72, 'EMULTIHOP'), (73, 'EDOTDOT'), (74, 'EBADMSG'), 
(75, 'EOVERFLOW'), (76, 'ENOTUNIQ'), (77, 'EBADFD'), (78, 'EREMCHG'), (79, 
'ELIBACC'), (80, 'ELIBBAD'), (81, 'ELIBSCN'), (82, 'ELIBMAX'), (83, 
'ELIBEXEC'), (84, 'EILSEQ'), (85, 'ERESTART'), (86, 'ESTRPIPE'), (87, 
'EUSERS'), (88, 'ENOTSOCK'), (89, 'EDESTADDRREQ'), (90, 'EMSGSIZE'), (91, 
'EPROTOTYPE'), (92, 'ENOPROTOOPT'), (93, 'EPROTONOSUPPORT'), (94, 
'ESOCKTNOSUPPORT'), (95, 'ENOTSUP'), (96, 'EPFNOSUPPORT'), (97, 
'EAFNOSUPPORT'), (98, 'EADDRINUSE'), (99, 'EADDRNOTAVAIL'), (100, 'ENETDOWN'), 
(101, 'ENETUNREACH'), (102, 'ENETRESET'), (103, 'ECONNABORTED'), (104, 
'ECONNRESET'), (105, 'ENOBUFS'), (106, 'EISCONN'), (107, 'ENOTCONN'), (108, 
'ESHUTDOWN'), (109, 'ETOOMANYREFS'), (110, 'ETIMEDOUT'), (111, 'ECONNREFUSED'), 
(112, 'EHOSTDOWN'), (113, 'EHOSTUNREACH'), (114, 'EALREADY'), (115, 
'EINPROGRESS'), (116, 'ESTALE'), (117, 'EUCLEAN'), (118,
  'ENOTNAM'), (119, 'ENAVAIL'), (120, 'EISNAM'), (121,
 'EREMOTEIO'), (122, 'EDQUOT'), (123, 'ENOMEDIUM'), (124, 'EMEDIUMTYPE'), (125, 
'ECANCELED'), (126, 'ENOKEY'), (127, 'EKEYEXPIRED'), (128, 'EKEYREVOKED'), 
(129, 'EKEYREJECTED'), (130, 'EOWNERDEAD'), (131, 'ENOTRECOVERABLE'), (132, 
'ERFKILL')]


Its an automated process the value is return by the C/kernel. I suppose its 
calling `ETIME`

ETIME - Timer expired (POSIX.1 (XSI STREAMS option)).
  (POSIX.1 says "STREAM ioctl(2) timeout".)
ETIMEDOUT - Connection timed out (POSIX.1-2001).

These are both timeout errors but only `ETIMEDOUT` is accounted for?

--

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



[issue39673] TimeoutError

2020-02-18 Thread YoSTEALTH


YoSTEALTH  added the comment:

If nothing else, it could be a feature of next Python release as its 
appropriate that `TimeoutError` catches both `ETIME` and `ETIMEDOUT`.

--
versions: +Python 3.9 -Python 3.8

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



[issue40367] ImportError: libffi.so.6

2020-04-22 Thread YoSTEALTH


New submission from YoSTEALTH :

>>> /opt/python/3.8.1/lib/python3 setup.py build_ext --inplace


Traceback (most recent call last):
  File "./setup.py", line 1, in 
from setuptools import setup, find_packages
  File "/opt/python/3.8.1/lib/python3.8/site-packages/setuptools/__init__.py", 
line 19, in 
from setuptools.dist import Distribution
  File "/opt/python/3.8.1/lib/python3.8/site-packages/setuptools/dist.py", line 
34, in 
from setuptools import windows_support
  File 
"/opt/python/3.8.1/lib/python3.8/site-packages/setuptools/windows_support.py", 
line 2, in 
import ctypes
  File "/opt/python/3.8.1/lib/python3.8/ctypes/__init__.py", line 7, in 
from _ctypes import Union, Structure, Array
ImportError: libffi.so.6: cannot open shared object file: No such file or 
directory



"libffi 3.3-3" on "5.6.5-3-MANJARO" is installed as:

/usr/lib/libffi.so
/usr/lib/libffi.so.7
/usr/lib/libffi.so.7.1.0
...


Maybe `_ctypes` should try to find "libffi.so" vs "libffi.so.6" ?

--
components: ctypes
messages: 367048
nosy: YoSTEALTH
priority: normal
severity: normal
status: open
title: ImportError: libffi.so.6
type: compile error

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



[issue40367] ImportError: libffi.so.6

2020-05-23 Thread YoSTEALTH


YoSTEALTH  added the comment:

How did you get the Python installed in /opt/python/3.8.1?
- I custom installed python.

Maybe it was compiled against libffi 6, then you updated the system to libffi 
7, so that Python would need a rebuild.
- Yes, you are right about this.

So i did rebuild and no problems, Thanks :)

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

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



[issue37129] Add os.RWF_APPEND flag for os.pwritev

2020-05-23 Thread YoSTEALTH


Change by YoSTEALTH :


--
keywords: +patch
pull_requests: +19603
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/20335

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



[issue37129] Add os.RWF_APPEND flag for os.pwritev

2020-05-23 Thread YoSTEALTH


Change by YoSTEALTH :


--
pull_requests: +19604
pull_request: https://github.com/python/cpython/pull/20336

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



[issue37129] Add os.RWF_APPEND flag for os.pwritev

2020-05-23 Thread YoSTEALTH


YoSTEALTH  added the comment:

terry.reedy ok, recreated the patch.

--

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



[issue40869] errno missing descriptions

2020-06-04 Thread YoSTEALTH


New submission from YoSTEALTH :

`errno` https://docs.python.org/3/library/errno.html is missing description for 
symbols like `ECANCELED` 
https://www.gnu.org/software/libc/manual/html_node/Error-Codes.html There might 
be others missing description as well, i haven't investigated further, figure i 
start the bug report process.

--
assignee: docs@python
components: Documentation
messages: 370749
nosy: YoSTEALTH, docs@python
priority: normal
severity: normal
status: open
title: errno missing descriptions

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



[issue40869] errno missing descriptions

2020-06-05 Thread YoSTEALTH


Change by YoSTEALTH :


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

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



[issue40869] errno missing descriptions

2020-06-05 Thread YoSTEALTH


Change by YoSTEALTH :


--
type:  -> enhancement
versions: +Python 3.7, Python 3.8, Python 3.9

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



[issue40869] errno missing descriptions

2020-06-05 Thread YoSTEALTH


Change by YoSTEALTH :


--
versions: +Python 3.10

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



[issue40869] errno missing descriptions

2020-06-09 Thread YoSTEALTH


Change by YoSTEALTH :


--
components: +C API

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



[issue40869] errno missing descriptions

2020-06-10 Thread YoSTEALTH


YoSTEALTH  added the comment:

Hello Arpit,

Welcome to python bugs. I have already created the patch at 
https://github.com/python/cpython/pull/20665 if you feel like i missed 
something you can comment on it. That said there is always something to do with 
python, just keep your eye out for it ;)

--

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



[issue41375] `mode` security concern

2020-07-23 Thread YoSTEALTH


New submission from YoSTEALTH :

import os
import stat
import os.path


def problem(tmp_path):
# result:
# ---
# check: False
# mode: 416

# create temp file
fd = os.open(tmp_path, os.O_CREAT, 0o660)
os.close(fd)

# Directory is effected as well
# os.mkdir(tmp_path, 0o660)


def solution(tmp_path):
# result:
# ---
# check: True
# mode: 432

old_umask = os.umask(0)

# create temp file
fd = os.open(tmp_path, os.O_CREAT, 0o660)
os.close(fd)

# create temp dir
# os.mkdir(tmp_path, 0o660)

os.umask(old_umask)


def main():
tmp_path = '_testing-chmod'

problem(tmp_path)
# solution(tmp_path)

try:
s = os.stat(tmp_path)
mode = stat.S_IMODE(s.st_mode)
print('check:', mode == 0o660)
print('mode:', mode)  # this should be: 432
finally:
# delete temp file
try:
os.unlink(tmp_path)
except IsADirectoryError:
os.rmdir(tmp_path)


if __name__ == '__main__':
main()


This result is not same for all os and distro, on multiple linux system for 
example the results will be different. I think Python should account for such 
behavior by default as it can lead to file/dir creation with security issues.

--
components: IO
messages: 374138
nosy: YoSTEALTH
priority: normal
severity: normal
status: open
title: `mode` security concern

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



[issue41375] `mode` security concern

2020-07-23 Thread YoSTEALTH


YoSTEALTH  added the comment:

I am closing this as its not a issue anymore... I was trying to solve a problem 
that has become a core feature!

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

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



[issue41314] PEP 563 and annotations __future__ mandatory version

2020-07-25 Thread YoSTEALTH


Change by YoSTEALTH :


--
keywords: +patch
nosy: +YoSTEALTH
nosy_count: 5.0 -> 6.0
pull_requests: +20758
stage: resolved -> patch review
pull_request: https://github.com/python/cpython/pull/21616

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



[issue41314] PEP 563 and annotations __future__ mandatory version

2020-07-25 Thread YoSTEALTH


Change by YoSTEALTH :


--
versions: +Python 3.7

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



[issue41314] PEP 563 and annotations __future__ mandatory version

2020-07-25 Thread YoSTEALTH


YoSTEALTH  added the comment:

@gvanrossum I found couple of odd places where 4.0 is mentioned like 
https://docs.python.org/3/library/array.html for example, should a new issue be 
created? I am not sure how many more there are.

--

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



[issue41405] python 3.9.0b5 test

2020-07-26 Thread YoSTEALTH

New submission from YoSTEALTH :

>>> /opt/python/3.9.0/bin/python3 -m test -uall
== CPython 3.9.0b5 (default, Jul 22 2020, 13:13:23) [GCC 10.1.0]
== Linux-5.8.0-1-MANJARO-x86_64-with-glibc2.31 little-endian
== cwd: /tmp/test_python_39605æ
== CPU count: 16
== encodings: locale=UTF-8, FS=utf-8
0:00:00 load avg: 1.24 Run tests sequentially
0:00:00 load avg: 1.24 [  1/425] test_grammar
0:00:00 load avg: 1.24 [  2/425] test_opcodes
0:00:00 load avg: 1.24 [  3/425] test_dict
0:00:00 load avg: 1.24 [  4/425] test_builtin
0:00:00 load avg: 1.24 [  5/425] test_exceptions
0:00:02 load avg: 1.22 [  6/425] test_types
0:00:02 load avg: 1.22 [  7/425] test_unittest
0:00:05 load avg: 1.22 [  8/425] test_doctest
0:00:06 load avg: 1.20 [  9/425] test_doctest2
0:00:07 load avg: 1.20 [ 10/425] test_support
0:00:09 load avg: 1.20 [ 11/425] test___all__
0:00:11 load avg: 1.20 [ 12/425] test___future__
0:00:11 load avg: 1.27 [ 13/425] test__locale
0:00:11 load avg: 1.27 [ 14/425] test__opcode
0:00:12 load avg: 1.27 [ 15/425] test__osx_support
0:00:12 load avg: 1.27 [ 16/425] test__xxsubinterpreters
0:00:13 load avg: 1.27 [ 17/425] test_abc
0:00:14 load avg: 1.27 [ 18/425] test_abstract_numbers
0:00:14 load avg: 1.27 [ 19/425] test_aifc
0:00:15 load avg: 1.27 [ 20/425] test_argparse
0:00:18 load avg: 1.24 [ 21/425] test_array
0:00:21 load avg: 1.22 [ 22/425] test_asdl_parser
test_asdl_parser skipped -- test irrelevant for an installed Python
0:00:21 load avg: 1.22 [ 23/425] test_ast -- test_asdl_parser skipped
0:00:24 load avg: 1.22 [ 24/425] test_asyncgen
0:00:25 load avg: 1.22 [ 25/425] test_asynchat
0:00:27 load avg: 1.13 [ 26/425] test_asyncio
0:02:10 load avg: 1.39 [ 27/425] test_asyncore -- test_asyncio passed in 1 min 
43 sec
0:02:12 load avg: 1.28 [ 28/425] test_atexit
0:02:12 load avg: 1.28 [ 29/425] test_audioop
0:02:13 load avg: 1.28 [ 30/425] test_audit
0:02:14 load avg: 1.28 [ 31/425] test_augassign
0:02:15 load avg: 1.28 [ 32/425] test_base64
0:02:15 load avg: 1.28 [ 33/425] test_baseexception
0:02:15 load avg: 1.28 [ 34/425] test_bdb
0:02:16 load avg: 1.28 [ 35/425] test_bigaddrspace
0:02:16 load avg: 1.26 [ 36/425] test_bigmem
0:02:17 load avg: 1.26 [ 37/425] test_binascii
0:02:17 load avg: 1.26 [ 38/425] test_binhex
0:02:17 load avg: 1.26 [ 39/425] test_binop
0:02:18 load avg: 1.26 [ 40/425] test_bisect
0:02:18 load avg: 1.26 [ 41/425] test_bool
0:02:18 load avg: 1.26 [ 42/425] test_buffer
0:02:29 load avg: 1.30 [ 43/425] test_bufio
0:02:30 load avg: 1.30 [ 44/425] test_bytes
0:02:32 load avg: 1.35 [ 45/425] test_bz2
0:02:37 load avg: 1.33 [ 46/425] test_c_locale_coercion
0:02:40 load avg: 1.33 [ 47/425] test_calendar
0:02:44 load avg: 1.38 [ 48/425] test_call
0:02:44 load avg: 1.38 [ 49/425] test_capi
0:03:07 load avg: 1.23 [ 50/425] test_cgi
0:03:08 load avg: 1.23 [ 51/425] test_cgitb
0:03:08 load avg: 1.23 [ 52/425] test_charmapcodec
0:03:09 load avg: 1.23 [ 53/425] test_check_c_globals
test_check_c_globals skipped -- c-analyzer directory could not be found
0:03:09 load avg: 1.23 [ 54/425] test_class -- test_check_c_globals skipped
0:03:09 load avg: 1.23 [ 55/425] test_clinic
test_clinic skipped -- clinic directory could not be found
0:03:10 load avg: 1.23 [ 56/425] test_cmath -- test_clinic skipped
0:03:10 load avg: 1.23 [ 57/425] test_cmd
0:03:10 load avg: 1.23 [ 58/425] test_cmd_line
0:03:14 load avg: 1.21 [ 59/425] test_cmd_line_script
0:03:18 load avg: 1.27 [ 60/425] test_code
0:03:19 load avg: 1.27 [ 61/425] test_code_module
0:03:19 load avg: 1.27 [ 62/425] test_codeccallbacks
0:03:19 load avg: 1.27 [ 63/425] test_codecencodings_cn
0:03:20 load avg: 1.27 [ 64/425] test_codecencodings_hk
0:03:20 load avg: 1.27 [ 65/425] test_codecencodings_iso2022
0:03:21 load avg: 1.25 [ 66/425] test_codecencodings_jp
0:03:22 load avg: 1.25 [ 67/425] test_codecencodings_kr
0:03:23 load avg: 1.25 [ 68/425] test_codecencodings_tw
0:03:23 load avg: 1.25 [ 69/425] test_codecmaps_cn
0:03:27 load avg: 1.23 [ 70/425] test_codecmaps_hk
0:03:28 load avg: 1.23 [ 71/425] test_codecmaps_jp
0:03:33 load avg: 1.13 [ 72/425] test_codecmaps_kr
0:03:37 load avg: 1.12 [ 73/425] test_codecmaps_tw
0:03:40 load avg: 1.12 [ 74/425] test_codecs
0:03:42 load avg: 1.83 [ 75/425] test_codeop
0:03:42 load avg: 1.83 [ 76/425] test_collections
0:03:43 load avg: 1.83 [ 77/425] test_colorsys
0:03:44 load avg: 1.83 [ 78/425] test_compare
0:03:44 load avg: 1.83 [ 79/425] test_compile
0:03:47 load avg: 1.85 [ 80/425] test_compileall
0:04:00 load avg: 1.71 [ 81/425] test_complex
0:04:01 load avg: 1.71 [ 82/425] test_concurrent_futures
0:06:35 load avg: 1.28 [ 83/425] test_configparser -- test_concurrent_futures 
passed in 2 min 34 sec
0:06:36 load avg: 1.26 [ 84/425] test_contains
0:06:37 load avg: 1.26 [ 85/425] test_context
0:06:39 load avg: 1.26 [ 86/425] test_contextlib
0:06:39 load avg: 1.26 [ 87/425] test_contextlib_async
Task was destroyed but it is pending!
task: ()>>
Task was destroyed but it is pending!
task: ()>>
Task wa

[issue41405] python 3.9.0b5 test

2020-07-26 Thread YoSTEALTH

YoSTEALTH  added the comment:

while compiling i got this warning, maybe its related!

gcc -pthread -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall 
   -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter 
-Wno-missing-field-initializers -Werror=implicit-function-declaration 
-fvisibility=hidden  -I../Include/internal -IObjects -IInclude -IPython -I. 
-I../Include-DPy_BUILD_CORE -o Python/getcompiler.o ../Python/getcompiler.c
In function ‘assemble_lnotab’,
inlined from ‘assemble_emit’ at ../Python/compile.c:5714:25,
inlined from ‘assemble’ at ../Python/compile.c:6053:18:
../Python/compile.c:5668:19: warning: writing 1 byte into a region of size 0 
[-Wstringop-overflow=]
 5668 | *lnotab++ = k;
  | ~~^~~

--

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



[issue41405] python 3.9.0b5 test

2020-07-27 Thread YoSTEALTH


YoSTEALTH  added the comment:

>>> /opt/python/3.9.0/bin/python3 -m test.pythoninfo
Python debug information


CC.version: gcc (GCC) 10.1.0
Py_DEBUG: No (sys.gettotalrefcount() missing)
_decimal.__libmpdec_version__: 2.5.0
builtins.float.double_format: IEEE, little-endian
builtins.float.float_format: IEEE, little-endian
config[_config_init]: 2
config[_init_main]: 1
config[_install_importlib]: 1
config[_isolated_interpreter]: 0
config[_orig_argv]: ['/opt/python/3.9.0/bin/python3', '-m', 'test.pythoninfo']
config[_use_peg_parser]: 1
config[argv]: ['-m']
config[base_exec_prefix]: '/opt/python/3.9.0'
config[base_executable]: '/opt/python/3.9.0/bin/python3'
config[base_prefix]: '/opt/python/3.9.0'
config[buffered_stdio]: 1
config[bytes_warning]: 0
config[check_hash_pycs_mode]: 'default'
config[configure_c_stdio]: 1
config[dev_mode]: 0
config[dump_refs]: 0
config[exec_prefix]: '/opt/python/3.9.0'
config[executable]: '/opt/python/3.9.0/bin/python3'
config[faulthandler]: 0
config[filesystem_encoding]: 'utf-8'
config[filesystem_errors]: 'surrogateescape'
config[hash_seed]: 0
config[home]: None
config[import_time]: 0
config[inspect]: 0
config[install_signal_handlers]: 1
config[interactive]: 0
config[isolated]: 0
config[malloc_stats]: 0
config[module_search_paths]: ['/opt/python/3.9.0/lib/python39.zip', 
'/opt/python/3.9.0/lib/python3.9', 
'/opt/python/3.9.0/lib/python3.9/lib-dynload']
config[optimization_level]: 0
config[parse_argv]: 1
config[parser_debug]: 0
config[pathconfig_warnings]: 1
config[platlibdir]: 'lib'
config[prefix]: '/opt/python/3.9.0'
config[program_name]: '/opt/python/3.9.0/bin/python3'
config[pycache_prefix]: None
config[pythonpath_env]: None
config[quiet]: 0
config[run_command]: None
config[run_filename]: None
config[run_module]: 'test.pythoninfo'
config[show_ref_count]: 0
config[site_import]: 1
config[skip_source_first_line]: 0
config[stdio_encoding]: 'utf-8'
config[stdio_errors]: 'strict'
config[tracemalloc]: 0
config[use_environment]: 1
config[use_hash_seed]: 0
config[user_site_directory]: 1
config[verbose]: 0
config[warnoptions]: []
config[write_bytecode]: 1
config[xoptions]: []
datetime.datetime.now: 2020-07-27 14:03:42.099769
expat.EXPAT_VERSION: expat_2.2.8
fips.openssl_fips_mode: 0
gdb_version: GNU gdb (GDB) 9.2
gdbm.GDBM_VERSION: 1.18.1
global_config[Py_BytesWarningFlag]: 0
global_config[Py_DebugFlag]: 0
global_config[Py_DontWriteBytecodeFlag]: 0
global_config[Py_FileSystemDefaultEncodeErrors]: 'surrogateescape'
global_config[Py_FileSystemDefaultEncoding]: 'utf-8'
global_config[Py_FrozenFlag]: 0
global_config[Py_HasFileSystemDefaultEncoding]: 0
global_config[Py_HashRandomizationFlag]: 1
global_config[Py_IgnoreEnvironmentFlag]: 0
global_config[Py_InspectFlag]: 0
global_config[Py_InteractiveFlag]: 0
global_config[Py_IsolatedFlag]: 0
global_config[Py_NoSiteFlag]: 0
global_config[Py_NoUserSiteDirectory]: 0
global_config[Py_OptimizeFlag]: 0
global_config[Py_QuietFlag]: 0
global_config[Py_UTF8Mode]: 0
global_config[Py_UnbufferedStdioFlag]: 0
global_config[Py_VerboseFlag]: 0
global_config[_Py_HasFileSystemDefaultEncodeErrors]: 0
locale.encoding: UTF-8
os.cpu_count: 16
os.environ[DISPLAY]: :0
os.environ[HOME]: /home/stealth
os.environ[LANG]: en_CA.UTF-8
os.environ[LC_ADDRESS]: en_CA.UTF-8
os.environ[LC_IDENTIFICATION]: en_CA.UTF-8
os.environ[LC_MEASUREMENT]: en_CA.UTF-8
os.environ[LC_MONETARY]: en_CA.UTF-8
os.environ[LC_NAME]: en_CA.UTF-8
os.environ[LC_NUMERIC]: en_CA.UTF-8
os.environ[LC_PAPER]: en_CA.UTF-8
os.environ[LC_TELEPHONE]: en_CA.UTF-8
os.environ[LC_TIME]: en_CA.UTF-8
os.environ[PATH]: 
/home/stealth/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/opt/cuda/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
os.environ[SHELL]: /bin/bash
os.environ[TERM]: xterm-256color
os.getcwd: /home/stealth
os.getegid: 1000
os.geteuid: 1000
os.getgid: 1000
os.getgrouplist: 1000, 3, 7, 10, 90, 91, 93, 95, 96, 98, 619
os.getgroups: 3, 7, 10, 90, 91, 93, 95, 96, 98, 619, 1000
os.getloadavg: (0.26, 0.6, 0.59)
os.getrandom: ready (initialized)
os.getresgid: (1000, 1000, 1000)
os.getresuid: (1000, 1000, 1000)
os.getuid: 1000
os.login: stealth
os.name: posix
os.supports_bytes_environ: True
os.supports_effective_ids: ['access']
os.supports_fd: ['chdir', 'chmod', 'chown', 'execve', 'listdir', 'pathconf', 
'scandir', 'stat', 'statvfs', 'truncate', 'utime']
os.supports_follow_symlinks: ['access', 'chown', 'link', 'stat', 'utime']
os.umask: 0o022
os.uname: posix.uname_result(sysname='Linux', nodename='stealth', 
release=&

[issue41405] python 3.9.0b5 test

2020-07-27 Thread YoSTEALTH


YoSTEALTH  added the comment:

I compiled and tested for same issues in 3.8.5 and they exist as well.

--

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



[issue40841] Provide mimetypes.sniff API as stdlib

2020-07-29 Thread YoSTEALTH


YoSTEALTH  added the comment:

Start and end position of the signature must be accounted for, not all file 
signature start at ``0`` or ``< 512`` bytes

Rather then writing all the signatures manually might be a good idea to use 
already collected resource like 
https://www.garykessler.net/library/file_sigs.html

--
nosy: +YoSTEALTH

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



[issue41475] __future__.annotations set to become default in Python 4.0?

2020-08-05 Thread YoSTEALTH


YoSTEALTH  added the comment:

@rhettinger https://bugs.python.org/issue41314

--
nosy: +YoSTEALTH

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



[issue41475] __future__.annotations set to become default in Python 4.0?

2020-08-05 Thread YoSTEALTH


YoSTEALTH  added the comment:

@cool-RR since your patch focuses on ``3.7`` there might be a merge issue.

There might be other place where ``4.0`` is mentioned though. Its better to let 
core dev like Raymond make the call.

--

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



[issue37129] Add RWF_APPEND flag

2019-06-05 Thread YoSTEALTH


Change by YoSTEALTH :


--
nosy: +YoSTEALTH

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



[issue37299] RuntimeWarning is NOT raised

2019-06-15 Thread YoSTEALTH


New submission from YoSTEALTH :

from asyncio import run


async def true():
return True


async def false():
return False


async def error():
a = false()
b = true()
return await (a or b)
# Good Error
#   "RuntimeWarning: coroutine 'true' was never awaited print(await 
error())"


async def no_error():
return await (false() or true())  # False
# Bad Problem
#   `RuntimeWarning` is not raised for 'true'.

# Note
#   The correct syntax is `return (await false()) or (await true()) as it 
should return `True`
#   not `False`


async def test():
print(await no_error())  # False
print(await error()) # RuntimeWarning(...), False


if __name__ == '__main__':
run(test())


- Tested in Python 3.8.0b1
- Why does `error()` return `RuntimeWarning` but `no_error()` does not?

--
components: asyncio
messages: 345723
nosy: YoSTEALTH, asvetlov, yselivanov
priority: normal
severity: normal
status: open
title: RuntimeWarning is NOT raised
type: behavior
versions: Python 3.8

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



[issue37299] RuntimeWarning is NOT raised

2019-06-17 Thread YoSTEALTH


YoSTEALTH  added the comment:

Yes, this was the previous conclusion.

In a large code base, its hard to find such solution easily! There are many 
cases where `await` is not called and `RuntimeWarning` is not raised. Hard to 
narrow down the exact problem.

Maybe there needs to be a better way to evaluate coroutine vs waiting for the 
garbage collection to happen to riase `RuntimeWarning`

Paul, thanks for taking time to answer :)

--

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



[issue37299] RuntimeWarning is NOT raised

2019-06-17 Thread YoSTEALTH


YoSTEALTH  added the comment:

As far as i can tell "static analyzers" like flake8 and "type hints" like mypy 
does not detect this problem

--

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



[issue37352] Typo in documentation: "to making it easy"

2019-06-20 Thread YoSTEALTH


YoSTEALTH  added the comment:

"Writing test suites is very helpful, and you might want to plan your code 
based on expectation of making it easy for testing."

--
nosy: +YoSTEALTH

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



[issue37352] Typo in documentation: "to making it easy"

2019-06-20 Thread YoSTEALTH


YoSTEALTH  added the comment:

programmers "plan" their code, they don't "design" it, as far as i know!

--

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



[issue37509] OSError preadv()

2019-07-05 Thread YoSTEALTH


New submission from YoSTEALTH :

import os
import ctypes

# Stdlib
# --
def test_preadv_stdlib(path):
fd = os.open(path, os.O_RDWR | os.O_CREAT)
buffer = bytearray(10)
buffers = [buffer]
try:
length = os.preadv(fd, buffers, 0, os.RWF_NOWAIT)
# OSError: [Errno 95] Operation not supported
print('length:', length)
print('buffer:', buffer)
finally:
os.close(fd)


# Cyptes Libc
# ---
class iovec(ctypes.Structure):
_fields_ = [('iov_base', ctypes.c_char_p), ('iov_len', ctypes.c_size_t)]


libc = ctypes.CDLL('libc.so.6')


def test_preadv_libc(path):
fd = os.open(path, os.O_RDWR | os.O_CREAT)
buffer = bytes(10)
buffers = (iovec*1)()
buffers[0].iov_base = buffer
buffers[0].iov_len = 10
try:
length = libc.preadv2(fd, buffers, len(buffers), 0, os.RWF_NOWAIT)
print('length:', length)  # length: -1
print('buffer:', buffer)  # buffer: 
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
finally:
os.close(fd)


# Test Run
# 
def test():
path = '/dev/shm/test-preadv-in-ram-file'

# Test-1 stdlib implementation
try:
test_preadv_stdlib(path)  # OSError: [Errno 95] Operation not supported
except OSError:
print('OSError is raised. This should not raise OSError')

# Test-2 custom ctype `libc` implementation
test_preadv_libc(path)


if __name__ == '__main__':
test()


This code is just to demonstrate working vs receiving an OSError in this 
specific usage.

System:   Linux 4.19.56-1-MANJARO
Python:   3.8.0b2

When the file in question is stored in ram ('/dev/shm') stdlib implementation 
raises an OSError while libc version does not.

--
messages: 347364
nosy: YoSTEALTH, pablogsal, vstinner
priority: normal
severity: normal
status: open
title: OSError preadv()
type: behavior
versions: Python 3.8

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



[issue31368] RWF_NONBLOCK

2017-09-06 Thread YoSTEALTH

New submission from YoSTEALTH:

Asynchronous, Non-blocking Buffered File Read

"RWF_NONBLOCK" flag for os.open()

Link:
https://lwn.net/Articles/612483/
https://lwn.net/Articles/613068/
https://lwn.net/Articles/636967/

--
messages: 301508
nosy: YoSTEALTH
priority: normal
severity: normal
status: open
title: RWF_NONBLOCK
type: enhancement
versions: Python 3.7

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



[issue32529] Call readinto in shutil.copyfileobj

2018-01-11 Thread YoSTEALTH

YoSTEALTH  added the comment:

Martin, your points got me thinking... to make a proper copy of a file, it 
should be done using bytes! Text IO could easily lead to corrupting your file.

for example (current function):
with open(old_path, 'r', encoding='latin-1') as fsrc:
with open(new_path, 'w') as fdst:
copyfileobj(fsrc, fdst)

This would lead you to have wrongly encoded file with different filesize.

--

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



[issue32529] Call readinto in shutil.copyfileobj

2018-01-11 Thread YoSTEALTH

Change by YoSTEALTH :


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

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



[issue32529] Call readinto in shutil.copyfileobj

2018-01-11 Thread YoSTEALTH

Change by YoSTEALTH :


--
pull_requests:  -5004

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



[issue32529] Call readinto in shutil.copyfileobj

2018-01-11 Thread YoSTEALTH

YoSTEALTH  added the comment:

Ok, updated the patch to account for:
- improved memory usage for bytes io using readinto
- still supporting negative length
- potential encoding mismatch bug fix while using text io

did i miss anything?

--

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



[issue32529] Call readinto in shutil.copyfileobj

2018-01-11 Thread YoSTEALTH

Change by YoSTEALTH :


--
pull_requests: +5014

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



[issue32529] Call readinto in shutil.copyfileobj

2018-01-11 Thread YoSTEALTH

YoSTEALTH  added the comment:

here is the links to benchmark:
https://repl.it/@altendky/timeit-of-proposed-shutilfileobjcopy
https://gist.github.com/altendky/ff5ccee2baf9822dce69ae8aa66a0fdf
https://paste.pound-python.org/show/urORPXztcbDlqXKTORAj/  # time ./file.py

the problem is the result times are so sparitic that not sure what to post as 
the result! I have tried with actual file as well and the results are all over 
the place.

If any of you out there are can do benchmark that can produce accurate results 
and post the result it would help.

--

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



[issue31368] RWF_NONBLOCK

2018-01-13 Thread YoSTEALTH

YoSTEALTH  added the comment:

preadv2(2) syscall with RWF_NONBLOCK feature is now released starting linux4.14
https://kernelnewbies.org/Linux_4.14#Asynchronous_buffered_I.2FO_support

--

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



[issue32561] Add API to io objects for non-blocking reads/writes

2018-01-16 Thread YoSTEALTH

YoSTEALTH  added the comment:

There will be lot of confusion using "buffered" & "unbuffered" terminology, 
since python already has BufferedIOBase (as mentioned by Martin). It would be 
more appropriate to create io.CachedIOBase and add non-blocking argument to 
open(blocking=False) to enable this feature.

------
nosy: +YoSTEALTH

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



[issue31368] Support asynchronous, non-blocking buffered reads (RWF_NONBLOCK)

2018-01-16 Thread YoSTEALTH

YoSTEALTH  added the comment:

According to this nginx test 
https://www.nginx.com/blog/thread-pools-boost-performance-9x/ there is a huge 
boost in performance when using thread poll for File IO. It is postulated that 
when preadv2() & RWF_NONBLOCK feature are available it would further benefit 
(latency, thread sync, ...)

I am not a C coder so i can't just jump into this and code this feature (if i 
could i would have done it long ago). As Antoine mentioned, it needs to written 
at C (+ctypes) level.

I am willing to help, hit me up on #python user: stealth_

--

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



[issue32529] Call readinto in shutil.copyfileobj

2018-01-17 Thread YoSTEALTH

Change by YoSTEALTH :


--
stage: patch review -> resolved
status: open -> closed

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



[issue31368] Add os.preadv() and os.pwritev()

2018-01-27 Thread YoSTEALTH

YoSTEALTH  added the comment:

Thank you Pablo Galindo for your amazingly hard work. Also Victor Stinner for 
your guidance, thanks you :)

--

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



[issue31356] Add context manager to temporarily disable GC

2018-01-31 Thread YoSTEALTH

YoSTEALTH  added the comment:

Since "ensure_disabled" is a class 
https://docs.python.org/3.7/library/gc.html#gc.ensure_disabled it should be 
"EnsureDisabled" according to 
https://www.python.org/dev/peps/pep-0008/#class-names

------
nosy: +YoSTEALTH

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



[issue31356] Add context manager to temporarily disable GC

2018-01-31 Thread YoSTEALTH

YoSTEALTH  added the comment:

ps, maybe a better name "DisabledZone" ?

--

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



[issue31356] Add context manager to temporarily disable GC

2018-01-31 Thread YoSTEALTH

YoSTEALTH  added the comment:

Actually i don't remember the last time where i saw anyone call a function 
using a "with" statement. This is very sloppy, sure PEP8 isn't ironclad but 
this is going to lead to confusion and we might have another case of datetime 
model (where you don't know whats what!!!).

--

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



[issue31368] Add os.preadv() and os.pwritev()

2018-01-31 Thread YoSTEALTH

Change by YoSTEALTH :


--
pull_requests: +5293

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



[issue32842] Fixing epoll timeout logics

2018-02-13 Thread YoSTEALTH

New submission from YoSTEALTH :

# current
if timeout is None:
timeout = -1
elif timeout <= 0:
timeout = 0

# changed
if timeout is None:
timeout = -1
elif timeout < -1:
timeout = 0

what if "timeout=-1" ?
- currently it would result in being timeout=0

--
messages: 312150
nosy: YoSTEALTH
priority: normal
severity: normal
status: open
title: Fixing epoll timeout logics
type: behavior
versions: Python 3.7

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



[issue32842] Fixing epoll timeout logics

2018-02-13 Thread YoSTEALTH

Change by YoSTEALTH :


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

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



[issue32842] Fixing epoll timeout logics

2018-02-13 Thread YoSTEALTH

Change by YoSTEALTH :


--
pull_requests: +5474

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



[issue32842] Fixing epoll timeout logics

2018-02-13 Thread YoSTEALTH

YoSTEALTH  added the comment:

my confusion comes from epoll.poll(timeout=-1, maxevents=-1) has nothing to do 
with selectors.BaseSelector.select(timeout=None)

--
resolution:  -> not a bug
stage: patch review -> resolved
status: open -> closed

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



[issue28134] socket.socket(fileno=fd) does not work as documented

2018-02-23 Thread YoSTEALTH

YoSTEALTH  added the comment:

I am using 3.7.0b1 i don't think this issue is fixed!

# simple mockup:
# --
def accept(sock):
client, addr = sock.accept()
inside = socket(fileno=client.fileno())
print(inside)
# <__main__.Socket fd=5, family=AddressFamily.AF_INET, 
type=SocketKind.SOCK_STREAM, proto=6, laddr=('127.0.0.1', 8000), 
raddr=('127.0.0.1', 42532)>
return inside

outside = accept(sock)
print(outside)
# <__main__.Socket fd=5, family=AddressFamily.AF_INET, 
type=SocketKind.SOCK_STREAM, proto=6>


So the "laddr" and "raddr" goes missing the second its out of the function???

This has wasted days of my time, to even get to this point of figuring out 
whats going on wasn't easy! extremely frustrating.

--
nosy: +YoSTEALTH

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



[issue28134] socket.socket(fileno=fd) does not work as documented

2018-02-23 Thread YoSTEALTH

YoSTEALTH  added the comment:

Christian thank you for your reply, i really appreciate it.

Lets analyze this a bit:
- Technically speaking i can "return client" directly and it would NOT close 
the socket.
- Shouldn't "inside" having reference to same fd mean +1 to reference count. 
Considering its a new object?
id(client): 140340037397192
id(inside): 140340010863560

I could understand making a duplicate of the fd if it were being passed across 
thread/process but in its original thread making a duplicate! This behavior is 
extremely odd.

I fell like everyone that uses socket(fileno) will run into days wasted and 
frustration just to figure out these solutions.

--

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



[issue28134] socket.socket(fileno=fd) does not work as documented

2018-03-02 Thread YoSTEALTH

YoSTEALTH  added the comment:

It would be nice if "python" accounted for such low level os things. None the 
less client.detach() method works fine.

I really did enjoy your talk, kinda bummed it was short and didn't get into 
more details.

Thanks for your help and patience Christian :)

--

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



[issue32401] No module named '_ctypes'

2017-12-21 Thread YoSTEALTH

New submission from YoSTEALTH :

I tried to install python3.7.0a3 just to test it out and i keep getting error:

Traceback (most recent call last):
  File "/tmp/psi/Python-3.7.0a3/Lib/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
  File "/tmp/psi/Python-3.7.0a3/Lib/runpy.py", line 85, in _run_code
exec(code, run_globals)
  File "/tmp/psi/Python-3.7.0a3/Lib/ensurepip/__main__.py", line 5, in 
sys.exit(ensurepip._main())
  File "/tmp/psi/Python-3.7.0a3/Lib/ensurepip/__init__.py", line 204, in _main
default_pip=args.default_pip,
  File "/tmp/psi/Python-3.7.0a3/Lib/ensurepip/__init__.py", line 117, in 
_bootstrap
return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "/tmp/psi/Python-3.7.0a3/Lib/ensurepip/__init__.py", line 27, in _run_pip
import pip
  File "/tmp/tmpuwh0fjm1/pip-9.0.1-py2.py3-none-any.whl/pip/__init__.py", line 
28, in 
  File "/tmp/tmpuwh0fjm1/pip-9.0.1-py2.py3-none-any.whl/pip/vcs/mercurial.py", 
line 9, in 
  File "/tmp/tmpuwh0fjm1/pip-9.0.1-py2.py3-none-any.whl/pip/download.py", line 
36, in 
  File "/tmp/tmpuwh0fjm1/pip-9.0.1-py2.py3-none-any.whl/pip/utils/glibc.py", 
line 4, in 
  File "/tmp/psi/Python-3.7.0a3/Lib/ctypes/__init__.py", line 7, in 
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
Makefile:1108: recipe for target 'install' failed
make: *** [install] Error 1

System:
Linux (4.10.0-42-generic) 64bit

I have installed 3.6.0 and 3.6.4 without any problems.

--
components: Installation
messages: 308897
nosy: YoSTEALTH
priority: normal
severity: normal
status: open
title: No module named '_ctypes'
type: compile error
versions: Python 3.7

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



[issue32401] No module named '_ctypes'

2017-12-27 Thread YoSTEALTH

YoSTEALTH  added the comment:

Yes, it does work without pip.

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

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



[issue32529] improved shutil.py function

2018-01-10 Thread YoSTEALTH

New submission from YoSTEALTH :

improved "copyfileobj" function to use less memory

--
messages: 309784
nosy: YoSTEALTH
priority: normal
pull_requests: 5004
severity: normal
status: open
title: improved shutil.py function
type: performance
versions: Python 3.7

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



[issue31368] Add os.preadv() and os.pwritev()

2018-05-30 Thread YoSTEALTH


YoSTEALTH  added the comment:

I can't at the moment, i am out of country for couple more months.

--

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



[issue34926] Adding "mine_type" method to pathlib.Path

2018-10-07 Thread YoSTEALTH


New submission from YoSTEALTH :

How about adding basic "mime_type" method to "pathlib.Path" ?

Code would do something like:

import mimetypes


def mime_type(name):
"""Mime-type of the file."""
find = name.rfind('.')
ext = '' if find == -1 else name[find:]
return mimetypes.types_map.get(ext, 'application/octet-stream')


Users would use it like so:

import pathlib

file = pathlib.Path('hello_world.py')
print(file.mime_type)  # 'text/x-python'

--
components: Extension Modules
messages: 327323
nosy: YoSTEALTH
priority: normal
severity: normal
status: open
title: Adding "mine_type" method to pathlib.Path
type: enhancement
versions: Python 3.8

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



[issue34938] Fix mimetype.init() to account for from import

2018-10-08 Thread YoSTEALTH


New submission from YoSTEALTH :

When a user uses from import, there is a flaw in how mimetype.init() updates 
its global references.

# Option-1 (flawed)
# -
from mimetypes import init, types_map

print(types_map.get('.gz'))  # None
init()  # <- initialize
print(types_map.get('.gz'))  # None

# Option-2
# 
import mimetypes

print(mimetypes.types_map.get('.gz'))  # None
mimetypes.init()  # <- initialize
print(mimetypes.types_map.get('.gz'))  # application/gzip

As you can see in 
https://github.com/python/cpython/blob/master/Lib/mimetypes.py#L344 line:358 
global reference is reassigned and thus it prevents `from mimetype import 
types_map` from being updated and using old `types_map` reference.

Potential solution would be to `types_map.update(new dict content)` vs 
reassigning the variable.

--
messages: 327375
nosy: YoSTEALTH
priority: normal
severity: normal
status: open
title: Fix mimetype.init() to account for from import
type: behavior
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/issue34938>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34926] Adding "mime_type" method to pathlib.Path

2018-10-08 Thread YoSTEALTH


Change by YoSTEALTH :


--
components:  -Extension Modules

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



[issue28861] Type Hints Syntax

2016-12-03 Thread YoSTEALTH

New submission from YoSTEALTH:

Type Hints Syntax
-

Goal: Is to make it easy to read function/methods arguments, yet keep the new 
and cool Type Hints.

For example this is a code from one of my function. Its getting to that point 
of what the heck is going on here?

def find_replace(string: str, find: (str, dict, list, tuple, set), replace: 
(str, list, tuple, set)='') -> str:
pass

I know it can be rewritten as:

T = (str, dict, list, tuple, set)
def find_replace(string: str, find: T, replace: T='') -> str:
pass

But when you start using variable to represent another variables type... maybe 
we are losing the plot here!

What if we could have both? Readability and type reference, what if it could be 
written as:

def find_replace(string, find, replace):
targ str, *(str, dict, list, tuple, set) -> str
# code here ...

targ = type argument (like *args and **kwargs)

Calling a "targ" like we call "global" but to represent types.

Simple Examples:

def Redirect(url='', code=301):
targ (str, int) -> None


Just think about it...

--
messages: 282304
nosy: YoSTEALTH
priority: normal
severity: normal
status: open
title: Type Hints Syntax
type: enhancement

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



[issue28861] Type Hints Syntax

2016-12-03 Thread YoSTEALTH

YoSTEALTH added the comment:

I was told to post this in python-ideas and also i totally missed the most 
important part (type aliases) in my example (rushed it)

--
status: open -> closed

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



[issue29134] contextlib doc bug

2017-01-02 Thread YoSTEALTH

New submission from YoSTEALTH:

Link: 
https://docs.python.org/3/library/contextlib.html#contextlib.ContextDecorator

"from contextlib import ContextDecorator

class mycontext(ContextBaseClass, ContextDecorator):"

"ContextBaseClass" is referenced but its no where to be found in source.

--
messages: 284489
nosy: YoSTEALTH
priority: normal
severity: normal
status: open
title: contextlib doc bug

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



[issue29134] contextlib doc bug

2017-01-02 Thread YoSTEALTH

YoSTEALTH added the comment:

@SilentGhost
You are right, I see it now!

If this is the case maybe "ContextBaseClass" should be changed to 
"UserDefinedContextClass" (or something...) having "Base" in the class name was 
confusing, since module "io" has IOBase class that refer to its "base class" 
figured it was the same concept for contextlib as well.

Also it would be nice if example was improved a bit.


Another Idea:
 - why not have an empty context manager base class? like:

def ContextBase:

def __enter__(self):
return self

def __exit__(self, *errors):
pass

This is something anyone can use to extend their class to support context 
manager? I actually have a class like this i have used many times in my 
projects! Its simple yet useful.

--

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



[issue29134] contextlib doc bug

2017-01-02 Thread YoSTEALTH

YoSTEALTH added the comment:

typo:
def ContextBase:
to
class ContextBase:

--

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



[issue29186] TimeoutError isn't being raised?

2017-01-06 Thread YoSTEALTH

New submission from YoSTEALTH:

TimeoutError isn't being raised?

My Python Version: 3.5.1 (64bit, linux)

# Document:
https://docs.python.org/3/library/exceptions.html#TimeoutError
""" exception TimeoutError
Raised when a system function timed out at the system level. Corresponds to 
errno ETIMEDOUT.
New in version 3.3: All the above OSError subclasses were added.
See also PEP 3151 - Reworking the OS and IO exception hierarchy """

# PEP: According to pep-3151
link: https://www.python.org/dev/peps/pep-3151/
""" TimeoutError : connection timed out (ETIMEDOUT); this can be re-cast as a 
generic timeout exception, replacing socket.timeout and also useful for other 
types of timeout (for example in Lock.acquire()) """


# This Does NOT Work:
def Send(conn, data):
# Set Timeout.
conn.settimeout(3.0)
try:
while data:
sent = conn.send(data)
data = data[sent:]
except TimeoutError as e:
print("TimeoutError:", e)  #
close_connection()
else:
pass  # Do Stuff...


# This Works
def Send(conn, data):
# Set Timeout.
conn.settimeout(3.0)
try:
while data:
sent = conn.send(data)
data = data[sent:]
except socket.timeout as e:
print("socket.timeout:", e)  # socket.timeout: timed out
close_connection()
else:
pass  # Do Stuff...


# This Works
def Send(conn, data):
# Set Timeout.
conn.settimeout(3.0)
try:
while data:
sent = conn.send(data)
data = data[sent:]
except OSError as e:
print('ERROR Send:', e)  # ERROR Send: timed out
close_connection()
else:
pass  # Do Stuff...


According to PEP "TimeoutError" is suppose to replace "socket.timeout" but it 
doesn't seem to work! Any ideas why?

--
messages: 284868
nosy: YoSTEALTH
priority: normal
severity: normal
status: open
title: TimeoutError isn't being raised?
type: behavior
versions: Python 3.5

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



[issue29186] TimeoutError isn't being raised?

2017-01-06 Thread YoSTEALTH

Changes by YoSTEALTH :


--
resolution:  -> not a bug
status: open -> closed

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



[issue27339] Security Issue: Typosquatting

2016-06-16 Thread YoSTEALTH

New submission from YoSTEALTH:

I read this new article that explains Typosquatting well: 
http://incolumitas.com/2016/06/08/typosquatting-package-managers/ making it 
known here so python developers can address this issue accordingly!

--
messages: 268692
nosy: YoSTEALTH
priority: normal
severity: normal
status: open
title: Security Issue: Typosquatting

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



[issue27751] Itertools -> Recipes -> pairwise()

2016-08-12 Thread YoSTEALTH

New submission from YoSTEALTH:

# Link: https://docs.python.org/3/library/itertools.html#itertools-recipes
# Function pairwise() in Itertools -> Recipes could be improved!? Here is the 
code:


import time
import itertools


def pairwise(iterable):
"s -> (s0,s1), (s1,s2), (s2, s3), ..."
a, b = itertools.tee(iterable)
next(b, None)
return zip(a, b)


def new_pairwise(iterable):
"s -> (s0,s1), (s1,s2), (s2, s3), ..."
return zip(iterable, iterable[1:])


combine = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)


if __name__ == '__main__':
start_time = time.time()

# Current
print('Current:')
print(list(pairwise(combine)))
# output: [(0, 1), (1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8), 
(8, 9)]

print()

# New
print('New:')
print(list(new_pairwise(combine)))
# output: [(0, 1), (1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8), 
(8, 9)]

# Benchmark
# for _ in range(100):
# list(pairwise(combine))  # Time: 2.61199975
# list(new_pairwise(combine))  # Time: 1.14828038

print('\n\nTime: {}'.format(round(time.time() - start_time, 8)), end='')

--
messages: 272572
nosy: YoSTEALTH
priority: normal
severity: normal
status: open
title: Itertools -> Recipes -> pairwise()
type: performance
versions: Python 3.5

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



[issue27751] Itertools -> Recipes -> pairwise()

2016-08-12 Thread YoSTEALTH

YoSTEALTH added the comment:

Tim, I get what you are saying good point.

--
status: open -> closed

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



[issue27852] itertools -> flatten_all()

2016-08-24 Thread YoSTEALTH

New submission from YoSTEALTH:

# Maybe a Recipe for itertools

from collections.abc import Iterable

def flatten_all(iterable):
# -> 'one'
# <- ['one']
# -> ['one', [b'two', b'three'], ['four', ('five', (1, {'e', 'ee'}, (2, (3, 
))), ['six'])], generator()]
# <- ['one', b'two', b'three', 'four', 'five', 1, 'ee', 'e', 2, 3, 'six', 
0, 1, 2]

if isinstance(iterable, Iterable) and not isinstance(iterable, (str, 
bytes)):
for it in iterable:
yield from flatten_all(it)
else:  # int & others types as is.
yield iterable


if __name__ == "__main__":

# Test Only
def generator():
for i in range(3):
yield i

a = ['one', [b'two', b'three'], ['four', ('five', (1, {'e', 'ee'}, (2, (3, 
))), ['six'])], generator()]
# a = 'one'
# a = (True, False)

print(list(flatten_all(a)))

--
messages: 273581
nosy: YoSTEALTH
priority: normal
severity: normal
status: open
title: itertools -> flatten_all()
type: enhancement
versions: Python 3.6

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



[issue27852] itertools -> flatten_all()

2016-08-25 Thread YoSTEALTH

YoSTEALTH added the comment:

Currently there is flatten() function in itertools Recipes section. This is 
what it does:
-> a = ['one', 'plus', [b'two', b'three'], ['four', ('five', (1, {'e', 'ee'}, 
(2, (3, ))), ['six'])], generator()]
<- ['o', 'n', 'e', 'p', 'l', 'u', 's', b'two', b'three', 'four', ('five', (1, 
{'ee', 'e'}, (2, (3,))), ['six']), 0, 1, 2]

As you can see it only flattens 1 nested level and for some reason it explodes 
the 'one' and 'plus' str items (maybe intentionally designed or lazily ignored, 
i don't know).

This is useful maybe in special circumstances where you have:
-> a = [[1, 2, 3], ['one', 'two', 'three']]
<- [1, 2, 3, 'one', 'two', 'three']

Also it doesn't work with bytearray, memoryview ...


In real worldly use something like flatten_all() is more useful!

--

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



[issue13299] namedtuple row factory for sqlite3

2015-01-20 Thread YoSTEALTH

YoSTEALTH added the comment:

note: sqlite_namedtuplerow.patch _cache method conflicts with attached database 
with say common table.column name like "id"

Using namedtuple method over sqlite3.Row was a terrible idea for me. I thought 
namedtuple is like tuple so should be faster then dict! wrong. I wasted 2 days 
change my work to namedtuple and back to sqlite3.Row, the speed difference on 
my working project was:

namedtuple 0.035s/result
sqlite3.Rows 0.0019s/result

for(speed test) range: 1
namedtuple 17.3s
sqlite3.Rows 0.4s

My solution was to use sqlite3.Row (for speed) but to get named like usage by 
convert dict keys() with setattr names:

class dict2named(dict):
def __init__(self, *args, **kwargs):
super(dict2named, self).__init__(*args, **kwargs)
self.__dict__ = self

Usage:

for i in con.execute('SELECT * FROM table'):
yield dict2named(i)

Now i can use:

print(i.title)

and handy dict methods for dash column names:

print(i['my-title'])
print(i.get('my-title', 'boo'))

Now working project speed:
sqlite3.Rows 0.0020s/result

for(speed test) range: 1
sqlite3.Rows 0.8s with dict2named converting

This i can work with, tiny compromise in speed with better usage.

--
nosy: +YoSTEALTH

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



[issue25790] shutil.chown function enhancement

2015-12-03 Thread YoSTEALTH

New submission from YoSTEALTH:

A very simple but useful enhancement for shutil.chown function

Currently "shutil.chown" function effects only one directory or file user/group 
permission by adding "recursive" parameter it can easily effect all 
sub-directories/files

Source: https://hg.python.org/cpython/file/3.5/Lib/shutil.py#l1007


# Current:
def chown(path, user=None, group=None):

"""Change owner user and group of the given path.


user and group can be the uid/gid or the user/group names, and in that case,

they are converted to their respective uid/gid.

"""


if user is None and group is None:

raise ValueError("user and/or group must be set")


_user = user

_group = group


# -1 means don't change it

if user is None:

_user = -1

# user can either be an int (the uid) or a string (the system username)

elif isinstance(user, str):

_user = _get_uid(user)

if _user is None:

raise LookupError("no such user: {!r}".format(user))


if group is None:

_group = -1

elif not isinstance(group, int):

_group = _get_gid(group)

if _group is None:

raise LookupError("no such group: {!r}".format(group))


os.chown(path, _user, _group)


# Enhanced:

import os.path


# Internal Function
def _dir_walk(path):
''' Get All Directories & Files'''

for dir_path, dir_names, file_names in os.walk(path):

# Directories
for dir_name in dir_names:
yield os.path.join(dir_path, dir_name)

# Files
for file_name in file_names:
yield os.path.join(dir_path, file_name)

def chown(path, user=None, group=None, recursive=False):

"""Change owner user and group of the given path.


user and group can be the uid/gid or the user/group names, and in that case,

they are converted to their respective uid/gid.

"""


if user is None and group is None:

raise ValueError("user and/or group must be set")


_user = user

_group = group


# -1 means don't change it

if user is None:

_user = -1

# user can either be an int (the uid) or a string (the system username)

elif isinstance(user, str):

_user = _get_uid(user)

if _user is None:

raise LookupError("no such user: {!r}".format(user))


if group is None:

_group = -1

elif not isinstance(group, int):

_group = _get_gid(group)

if _group is None:

raise LookupError("no such group: {!r}".format(group))

# Default Do First
if not recursive:
os.chown(path, _user, _group)
    else:
for recursive_path in _dir_walk(path):
os.chown(recursive_path, _user, _group)


hope this helps :)

--
hgrepos: 324
messages: 255834
nosy: YoSTEALTH
priority: normal
severity: normal
status: open
title: shutil.chown function enhancement
type: enhancement
versions: Python 3.5

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



[issue25790] shutil.chown function enhancement

2015-12-03 Thread YoSTEALTH

YoSTEALTH added the comment:

I am new to this, not exactly sure how to go about doing that!

--

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



[issue25790] shutil.chown function enhancement

2015-12-03 Thread YoSTEALTH

YoSTEALTH added the comment:

Thanks David.

I hope this is what a patch file should be! Attached.

--
keywords: +patch
Added file: http://bugs.python.org/file41230/shutil.patch

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



[issue13033] Add shutil.chowntree

2015-12-04 Thread YoSTEALTH

YoSTEALTH added the comment:

Can this chowntree() function proposed here be implemented? It would have saved 
me a bunch of time and its a good feature to have.

--
nosy: +YoSTEALTH, r.david.murray

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