[issue1432] Strange behavior of urlparse.urljoin

2007-11-12 Thread yan

New submission from yan:

When I use python 2.4/2.5, I found a strange behavior like this:
urlparse.urljoin("http://www.python.org/[EMAIL PROTECTED]","[EMAIL PROTECTED]")
It will return "http://www.python.org/[EMAIL PROTECTED]".  But I think it
should be "http://www.python.org/[EMAIL PROTECTED]", right? And I
test it in python 2.3. The result is what I supposed it to be.

--
components: Library (Lib)
messages: 57434
nosy: yan
severity: normal
status: open
title: Strange behavior of urlparse.urljoin
type: behavior
versions: Python 2.4, Python 2.5, Python 2.6

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



[issue1432] Strange behavior of urlparse.urljoin

2007-11-14 Thread yan

yan added the comment:

Not really, it's just for PATH component. But the QUERY and PARAMETER
are not the same.
just check the RFC1808. 
5.1. Normal Examples
Base: http://a/b/c/d;p?q#f>
?y = http://a/b/c/d;p?y>
;x = http://a/b/c/d;x>

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



[issue1432] Strange behavior of urlparse.urljoin

2007-11-16 Thread yan

yan added the comment:

That sounds great, thanks a lot.

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



[issue38915] 'r[/]*', str, re.MULTILINE | re.DOTALL Won't match // in a string in Python3.6.8

2019-11-26 Thread Yan


New submission from Yan :

str="//"
matches = re.finditer('r[/]*', str, re.MULTILINE | re.DOTALL)
for match in matches:
print(match.group(0))

The above will match double forward slash in Python2.7.15  but NOT in 
Python3.6.8.

--
components: Library (Lib)
messages: 357492
nosy: yanioaioan
priority: normal
severity: normal
status: open
title: 'r[/]*', str, re.MULTILINE | re.DOTALL Won't match // in a string in 
Python3.6.8
type: behavior
versions: Python 3.6

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



[issue38915] 'r[/]*', str, re.MULTILINE | re.DOTALL Won't match // in a string in Python3.6.8

2019-11-26 Thread Yan


Change by Yan :


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

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



[issue25681] Assignment of one element in nested list changes multiple elements

2015-11-20 Thread Yan

New submission from Yan:

Is this the correct behavior?

>>> l=[['']*2]*3
>>> b=[['', ''], ['', ''], ['', '']]
>>> l == b
True
>>> l[0][1]='A'
>>> b[0][1]='A'
>>> l == b
False
>>> l
[['', 'A'], ['', 'A'], ['', 'A']]
>>> b
[['', 'A'], ['', ''], ['', '']]

--
messages: 254978
nosy: ydu
priority: normal
severity: normal
status: open
title: Assignment of one element in nested list changes multiple elements
type: behavior
versions: Python 2.7

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



[issue25681] Assignment of one element in nested list changes multiple elements

2015-11-20 Thread Yan

Yan added the comment:

Thanks for the quick response.
It makes sense to me. I misunderstood the * operator.

--

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



[issue46926] runpy.run_path didn't set __package__ as describe in doc

2022-03-04 Thread Charlie Yan


New submission from Charlie Yan :

As described in the doc: 
https://docs.python.org/3.8/library/runpy.html#runpy.run_path

> If the supplied path directly references a script file (whether as source or 
> as precompiled byte code), then __file__ will be set to the supplied path, 
> and __spec__, __cached__, __loader__ and __package__ will all be set to None.

But:
```
$ cat a.py
print(f'{__name__ = }')
print(f'{__package__ = }')

$ cat b.py
import runpy
runpy.run_path('a.py')

$ python3 b.py
__name__ = ''
__package__ = ''
```

`__package__` is not set to None as in the doc.

--
messages: 414555
nosy: yanhao.charles
priority: normal
severity: normal
status: open
title: runpy.run_path didn't set __package__ as describe in doc
versions: Python 3.8

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



[issue46926] runpy.run_path didn't set __package__ to None as describe in doc

2022-03-04 Thread Charlie Yan


Change by Charlie Yan :


--
title: runpy.run_path didn't set __package__ as describe in doc -> 
runpy.run_path didn't set __package__ to None as describe in doc

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



[issue12473] factory func of collections.defaultdict should receive the "missing key" as args when called.

2011-07-02 Thread HaiYun Yan

New submission from HaiYun Yan :

for example:

def calc(params):
""" i am factoring numbers. """
# an expensive CPU cost function but 
# passin params and return result are both lightweight

cachedcalc = collections.defaultdict(calc)
result = cachedcalc[0xFFF0AC0FFF1]

--
components: Library (Lib)
messages: 139624
nosy: lyricconch
priority: normal
severity: normal
status: open
title: factory func of collections.defaultdict should receive the "missing key" 
as args when called.
type: behavior
versions: Python 2.7

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



[issue12635] use "as" for block scope support

2011-07-25 Thread HaiYun Yan

New submission from HaiYun Yan :

use "as" for block scope support
just like mozilla javascript "let" extension
https://developer.mozilla.org/en/new_in_javascript_1.7#Block_scope_with_let_%28Merge_into_let_Statement%29

usage:

as_clause(as_declare): "as" NAME
as_stmt: NAME "as" test
as_expr: "(" expr "as" NAME ")" expr

var declare by as_clause is alive in  only
eg:
with open(...) as f:
   ...


the same rule to "except E as e: "

spec:
from socket import AF_INET as IPv4

IPv4 = None
assert socket.AF_INET == None

var in as_stmt is alive in current indentation
eg:
for i in range(10):
   
   t as f()+1 
   ...
   

var in as_expr is alive in sub expr only
eg:
t = None
x = (2+3 as t) t**2
assert t == None ane  x == 25

Suggestion:
new opcode
ENTER_BLOCK #depth #varslots

--
components: Interpreter Core
messages: 141076
nosy: lyricconch
priority: normal
severity: normal
status: open
title: use "as" for block scope support
type: feature request

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



[issue46926] runpy.run_path didn't set __package__ to None as describe in doc

2022-03-08 Thread Charlie Yan


Change by Charlie Yan :


--
components: +Library (Lib)
type:  -> behavior

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



[issue38280] Feature request: Add support to compile to native binary like as golang

2019-09-25 Thread WHK Yan


New submission from WHK Yan :

It would be very useful to be able to compile at a low level a complete Python 
functional script and generate a native binary for each type of operating 
system and architecture just like golang does.

For example:

Run script: $ go run script.go
Compile script: $ GOOS=linux GOARCH=amd64 go build -o test test.go

The generated binary does not require goland installed to be executed and does 
not require complex dependencies. This allows me to distribute applications in 
binary are an excellent performance without requiring the installation of the 
entire interpreter.

Golang's problem is that it is not an intuitive language and the learning curve 
is very long, they had a very good idea but they carried it out in a horrible 
way.

On the other hand, python is very flexible and very intuitive, the learning 
curve is very short, I learned python in less than a week and I have been 
creating python applications for several years, instead I have been trying to 
learn golang for months and it is excessively strange.

Why not combine the best of both worlds? Unite non-dependence and 
cross-platform distribution without relying on the interpreter and the most 
versatile and intuitive language?

For example:

Run script: $ python script.py
Compile pyc $ python -m compileall
Compile native: $ python -m ncompileall -k linux -a amd_64

When compileall generate the pyc files and ncompileall generate a native 
binaries without complex dependencies or python dependencies.

This would be a great advantage in equipment that does not require additional 
installation of components.

For example, on servers of some companies they do not allow you to install 
something that can affect the entire environment or ecosystem, in addition, in 
many cases the scripts require a specific version of python and cause problems 
when different versions are required to other applications, the complete 
compilation at low level would allow to resolve this conflict.

There are currently few projects that allow you to translate a python script to 
binary but most do not have support or do not have a good performance, if 
python already brought it integrated it would increase its use even more since 
it would not depend on the interpreter to be able to distribute a complete 
application that already include all its modules and others.

--
components: Cross-Build
messages: 353224
nosy: Alex.Willmer, WHK Yan
priority: normal
severity: normal
status: open
title: Feature request: Add support to compile to native binary like as golang
type: enhancement
versions: Python 3.6, Python 3.7, Python 3.8, Python 3.9

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



[issue39210] Sorting falls back to use __gt__ when __lt__ is not present

2020-01-04 Thread Yan Mitrofanov


New submission from Yan Mitrofanov :

Sorting documentation claims that sorting algorithm is only using < comparisons
https://docs.python.org/3/howto/sorting.html#odd-and-ends
https://docs.python.org/3/library/stdtypes.html#list.sort

When __lt__ implementation is missing, you get an exception
class Foo:
pass
sorted([Foo(), Foo(), Foo()])
TypeError: '<' not supported between instances of 'Foo' and 'Foo'

However, if implement __gt__ method, you doesn't get an exception
class Foo:
def __gt__(self, other):
return False
sorted([Foo(), Foo(), Foo()])  # ok


Is it supposed to work like this? Or is it lack of documentation?

--
assignee: docs@python
components: Documentation
messages: 359293
nosy: docs@python, yanmitrofanov
priority: normal
severity: normal
status: open
title: Sorting falls back to use __gt__ when __lt__ is not present
versions: Python 3.8

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



[issue39210] Sorting falls back to use __gt__ when __lt__ is not present

2020-01-04 Thread Yan Mitrofanov


Yan Mitrofanov  added the comment:

I got your point. So it seems that two pieces of documentation are not 
equivalent: 

https://docs.python.org/3/howto/sorting.html#odd-and-ends
> The sort routines are guaranteed to use __lt__() when making comparisons 
> between two objects.

https://docs.python.org/3/library/stdtypes.html#list.sort
> This method sorts the list in place, using only < comparisons between items.

--

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



[issue42575] Suggest to add an LinkedList data structure to python

2020-12-04 Thread Sam Yan


New submission from Sam Yan :

There has been no LinkedList data structure for Python. Therefore suggest 
adding a LinkedList data structure.

--
components: C API
files: LinkedList.py
messages: 382557
nosy: SamUnimelb
priority: normal
severity: normal
status: open
title: Suggest to add an LinkedList data structure to python
type: enhancement
versions: Python 3.10
Added file: https://bugs.python.org/file49658/LinkedList.py

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



[issue43139] test_ttk test_compound and test_tk test_type fails with Tk 8.6.11.1

2021-02-05 Thread Felix Yan


New submission from Felix Yan :

==
FAIL: test_compound (tkinter.test.test_ttk.test_widgets.ButtonTest)
--
Traceback (most recent call last):
  File 
"/build/python/src/Python-3.9.1/Lib/tkinter/test/test_ttk/test_widgets.py", 
line 173, in test_compound
self.checkEnumParam(widget, 'compound',
  File "/build/python/src/Python-3.9.1/Lib/tkinter/test/widget_tests.py", line 
152, in checkEnumParam
self.checkInvalidParam(widget, name, '',
  File "/build/python/src/Python-3.9.1/Lib/tkinter/test/widget_tests.py", line 
75, in checkInvalidParam
widget[name] = value
AssertionError: TclError not raised

=
FAIL: test_type (tkinter.test.test_tkinter.test_widgets.MenuTest)
--
Traceback (most recent call last):
  File 
"/build/python/src/Python-3.9.1/Lib/tkinter/test/test_tkinter/test_widgets.py", 
line 1245, in test_type
self.checkEnumParam(widget, 'type',
  File "/build/python/src/Python-3.9.1/Lib/tkinter/test/widget_tests.py", line 
152, in checkEnumParam
self.checkInvalidParam(widget, name, '',
  File "/build/python/src/Python-3.9.1/Lib/tkinter/test/widget_tests.py", line 
75, in checkInvalidParam
widget[name] = value
AssertionError: TclError not raised

--

--
components: Tests
messages: 386538
nosy: felixonmars
priority: normal
severity: normal
status: open
title: test_ttk test_compound and test_tk test_type fails with Tk 8.6.11.1
type: behavior
versions: Python 3.9

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



[issue43139] test_ttk test_compound and test_tk test_type fails with Tk 8.6.11.1

2021-02-12 Thread Felix Yan


Felix Yan  added the comment:

It's Arch Linux x86_64 with system tcl/tk. It's build in a clean chroot for 
packaging and always reproducible.

--

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



[issue41302] _decimal failed to build with system libmpdec 2.5

2020-07-15 Thread Felix Yan

New submission from Felix Yan :

In bpo-40874, mpdecimal.h in the vendored libmpdec has defines of UNUSED while 
the standalone released version of mpdecimal 2.5.0 doesn't. This breaks 
_decimal module build with system libmpdec due to UNUSED is undefined.

Errors are like:

cpython/Modules/_decimal/_decimal.c:277:36: error: expected ‘;’, ‘,’ or ‘)’ 
before ‘UNUSED’
  277 | dec_traphandler(mpd_context_t *ctx UNUSED) /* GCOV_NOT_REACHED */
  |^~

Reproducible in both 3.8 branch and master (didn't test 3.9, but should be 
affected too).

--
components: Extension Modules
messages: 373676
nosy: felixonmars, skrah
priority: normal
severity: normal
status: open
title: _decimal failed to build with system libmpdec 2.5
type: compile error
versions: Python 3.10, Python 3.8, Python 3.9

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



[issue41302] _decimal failed to build with system libmpdec 2.5

2020-07-15 Thread Felix Yan


Change by Felix Yan :


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

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



[issue41302] _decimal failed to build with system libmpdec 2.5

2020-07-15 Thread Felix Yan


Felix Yan  added the comment:

Yes, I am currently defining it manually as a workaround for building 3.8.4 in 
Arch.

Also opened GH-21481 for this :)

--

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



[issue41302] _decimal failed to build with system libmpdec 2.5

2020-07-15 Thread Felix Yan


Change by Felix Yan :


--
pull_requests: +20631
status: pending -> open
pull_request: https://github.com/python/cpython/pull/21488

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



[issue41306] test_tk failure on Arch Linux

2020-07-15 Thread Felix Yan


New submission from Felix Yan :

test_from (tkinter.test.test_tkinter.test_widgets.ScaleTest) is currently 
failing on Arch Linux, and at least another place: 
https://python-build-standalone.readthedocs.io/en/latest/status.html

The error looks like:

==
FAIL: test_from (tkinter.test.test_tkinter.test_widgets.ScaleTest)
--
Traceback (most recent call last):
  File "/usr/lib/python3.8/tkinter/test/test_tkinter/test_widgets.py", line 
939, in test_from
self.checkFloatParam(widget, 'from', 100, 14.9, 15.1, conv=float_round)
  File "/usr/lib/python3.8/tkinter/test/widget_tests.py", line 106, in 
checkFloatParam
self.checkParam(widget, name, value, conv=conv, **kwargs)
  File "/usr/lib/python3.8/tkinter/test/widget_tests.py", line 64, in checkParam
self.assertEqual2(widget.cget(name), expected, eq=eq)
  File "/usr/lib/python3.8/tkinter/test/widget_tests.py", line 47, in 
assertEqual2
self.assertEqual(actual, expected, msg)
AssertionError: 14.9 != 15.0

It's the only failure in the current Python 3.8.4 release's test suite here. 
Also adding Python 3.9 and 3.10 as I am able to reproduce it on master too.

--
components: Tests
messages: 373710
nosy: felixonmars
priority: normal
severity: normal
status: open
title: test_tk failure on Arch Linux
versions: Python 3.10, Python 3.8, Python 3.9

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



[issue41306] test_tk failure on Arch Linux

2020-07-16 Thread Felix Yan


Felix Yan  added the comment:

tkinter.TCL_VERSION: 8.6
tkinter.TK_VERSION: 8.6
tkinter.info_patchlevel: 8.6.10

It's always reproducible in either a real desktop or Xvfb with arbitrary 
resolution etc as far as I have tested.

--

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



[issue41346] test_thousand and compileall hangs on riscv64

2020-07-20 Thread Felix Yan


New submission from Felix Yan :

In my riscv64 build, test_thousand 
(test.test_multiprocessing_forkserver.WithProcessesTestBarrier) always hangs on 
some locking thing, and the compileall part during installation hangs the same 
way. I am not sure if it's toolchain related or something else, though.

Some relevant versions:

Linux riscv64-unknown-linux-gnu
Python 3.8.4
glibc 2.31
gcc 10.1.0

configure switches:

  ./configure --prefix=/usr \
  --enable-shared \
  --with-computed-gotos \
  --enable-optimizations \
  --with-lto \
  --enable-ipv6 \
  --with-system-expat \
  --with-dbmliborder=gdbm:ndbm \
  --with-system-ffi \
  --with-system-libmpdec \
  --enable-loadable-sqlite-extensions \
  --without-ensurepip

When Ctrl-C:

test_thousand (test.test_multiprocessing_forkserver.WithProcessesTestBarrier) 
... ^CProcess Process-1305:
Traceback (most recent call last):
  File "/build/python/src/Python-3.8.4/Lib/multiprocessing/process.py", line 
315, in _bootstrap
self.run()
  File "/build/python/src/Python-3.8.4/Lib/multiprocessing/process.py", line 
108, in run
self._target(*self._args, **self._kwargs)
  File "/build/python/src/Python-3.8.4/Lib/test/_test_multiprocessing.py", line 
1970, in _test_thousand_f
barrier.wait()
  File "/build/python/src/Python-3.8.4/Lib/threading.py", line 610, in wait
self._enter() # Block while the barrier drains.
  File "/build/python/src/Python-3.8.4/Lib/threading.py", line 631, in _enter
self._cond.wait()
  File "/build/python/src/Python-3.8.4/Lib/multiprocessing/synchronize.py", 
line 261, in wait
return self._wait_semaphore.acquire(True, timeout)
KeyboardInterrupt
Process Process-1304:
Traceback (most recent call last):
  File "/build/python/src/Python-3.8.4/Lib/multiprocessing/process.py", line 
315, in _bootstrap
self.run()
  File "/build/python/src/Python-3.8.4/Lib/multiprocessing/process.py", line 
108, in run
self._target(*self._args, **self._kwargs)
  File "/build/python/src/Python-3.8.4/Lib/test/_test_multiprocessing.py", line 
1970, in _test_thousand_f
barrier.wait()
  File "/build/python/src/Python-3.8.4/Lib/threading.py", line 610, in wait
self._enter() # Block while the barrier drains.
  File "/build/python/src/Python-3.8.4/Lib/threading.py", line 631, in _enter
self._cond.wait()
  File "/build/python/src/Python-3.8.4/Lib/multiprocessing/synchronize.py", 
line 261, in wait
return self._wait_semaphore.acquire(True, timeout)
KeyboardInterrupt
Process Process-1306:
Traceback (most recent call last):
  File "/build/python/src/Python-3.8.4/Lib/multiprocessing/process.py", line 
315, in _bootstrap
self.run()
  File "/build/python/src/Python-3.8.4/Lib/multiprocessing/process.py", line 
108, in run
self._target(*self._args, **self._kwargs)
  File "/build/python/src/Python-3.8.4/Lib/test/_test_multiprocessing.py", line 
1970, in _test_thousand_f
barrier.wait()
  File "/build/python/src/Python-3.8.4/Lib/threading.py", line 610, in wait
self._enter() # Block while the barrier drains.
  File "/build/python/src/Python-3.8.4/Lib/threading.py", line 631, in _enter
self._cond.wait()
  File "/build/python/src/Python-3.8.4/Lib/multiprocessing/synchronize.py", 
line 261, in wait
return self._wait_semaphore.acquire(True, timeout)
KeyboardInterrupt
Process Process-1302:
Traceback (most recent call last):
  File "/build/python/src/Python-3.8.4/Lib/multiprocessing/process.py", line 
315, in _bootstrap
self.run()
  File "/build/python/src/Python-3.8.4/Lib/multiprocessing/process.py", line 
108, in run
self._target(*self._args, **self._kwargs)
  File "/build/python/src/Python-3.8.4/Lib/test/_test_multiprocessing.py", line 
1970, in _test_thousand_f
barrier.wait()
  File "/build/python/src/Python-3.8.4/Lib/threading.py", line 610, in wait
self._enter() # Block while the barrier drains.
  File "/build/python/src/Python-3.8.4/Lib/threading.py", line 631, in _enter
self._cond.wait()
  File "/build/python/src/Python-3.8.4/Lib/multiprocessing/synchronize.py", 
line 261, in wait
return self._wait_semaphore.acquire(True, timeout)
KeyboardInterrupt
Process Process-1303:
Traceback (most recent call last):
  File "/build/python/src/Python-3.8.4/Lib/multiprocessing/process.py", line 
315, in _bootstrap
self.run()
  File "/build/python/src/Python-3.8.4/Lib/multiprocessing/process.py", line 
108, in run
self._target(*self._args, **self._kwargs)
  File "/build/python/src/Python-3.8.4/Lib/test/_test_multiprocessing.py", line 
1970, in _test_thousand_f
barrier.wait()
  File "/build/python

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

2020-09-21 Thread Yan Ren


Yan Ren  added the comment:

append Nosy List.

--
nosy: +pemryan

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



[issue41952] Extra Space Between "Oct" and "5"

2020-10-05 Thread Steven Yan


Change by Steven Yan :


--
assignee: terry.reedy
components: IDLE
nosy: sy, terry.reedy
priority: normal
severity: normal
status: open
title: Extra Space Between "Oct" and "5"
type: enhancement
versions: Python 3.9

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



[issue41952] Top Sentence Had a Extra Space Between "Oct" and "5"

2020-10-05 Thread Steven Yan


Change by Steven Yan :


--
title: Extra Space Between "Oct" and "5" -> Top Sentence Had a Extra Space 
Between "Oct" and "5"

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



[issue41970] test_lib2to3 fails since Python 3.9

2020-10-07 Thread Felix Yan


New submission from Felix Yan :

I am packaging Python for Arch and the tests suite of Python 3.8.6 pass here 
without this:

```
0:09:06 load avg: 0.87 [205/424] test_lib2to3   


  
test test_lib2to3 crashed -- Traceback (most recent call last): 


  
  File "/build/python/src/Python-3.9.0/Lib/test/libregrtest/runtest.py", line 
270, in _runtest_inner  


refleak = _runtest_inner2(ns, test_name)


  
  File "/build/python/src/Python-3.9.0/Lib/test/libregrtest/runtest.py", line 
221, in _runtest_inner2 


the_module = importlib.import_module(abstest)   


  
  File "/build/python/src/Python-3.9.0/Lib/importlib/__init__.py", line 127, in 
import_module   

  
return _bootstrap._gcd_import(name[level:], package, level) 


  
  File "", line 1030, in _gcd_import   


  
  File "", line 1007, in _find_and_load


  
  File "", line 986, in _find_and_load_unlocked


  
  File "", line 680, in _load_unlocked 


  
  File "", line 790, in exec_module   


  
  File "", line 228, in _call_with_frames_removed  


  
  File "/build/python/src/Python-3.9.0/Lib/test/test_lib2to3.py", line 5, in 


 
from lib2to3.tests import load_tests


   

[issue41971] multiple tests in test_tools fail since Python 3.9

2020-10-07 Thread Felix Yan


New submission from Felix Yan :

I am packaging Python for Arch and the test suite of Python 3.8.6 passes here 
without these:

==
FAIL: test_multiple_roots 
(test.test_tools.test_c_analyzer.test_common.test_files.IterFilesTests)
--
Traceback (most recent call last):
  File 
"/build/python/src/Python-3.9.0/Lib/test/test_tools/test_c_analyzer/test_common/test_files.py",
 line 118, in test_multiple_roots
self.assertEqual(self.calls, [
AssertionError: Lists differ: [('_w[26 chars]tion walk at 0x7ff2eb562f70>)), 
('_walk', ('eg[42 chars]0>))] != [('_w[26 chars]tion _walk_tree at 
0x7ff2e5babdc0>)), ('_walk'[54 chars]0>))]

First differing element 0:
('_walk', ('spam', '.c', ))
('_walk', ('spam', '.c', ))

- [('_walk', ('spam', '.c', )),
? ^

+ [('_walk', ('spam', '.c', )),
? ++   + 

-  ('_walk', ('eggs', '.c', ))]
? ^

+  ('_walk', ('eggs', '.c', ))]
? ++   + 


==
FAIL: test_multiple_suffixes 
(test.test_tools.test_c_analyzer.test_common.test_files.IterFilesTests)
--
Traceback (most recent call last):
  File 
"/build/python/src/Python-3.9.0/Lib/test/test_tools/test_c_analyzer/test_common/test_files.py",
 line 189, in test_multiple_suffixes
self.assertEqual(self.calls, [
AssertionError: Lists differ: [('_walk', ('spam', None, ))] != [('_walk', ('spam', None, ))]

First differing element 0:
('_walk', ('spam', None, ))
('_walk', ('spam', None, ))

- [('_walk', ('spam', None, ))]
? ^

+ [('_walk', ('spam', None, ))]
? ++   + 


==
FAIL: test_no_suffix 
(test.test_tools.test_c_analyzer.test_common.test_files.IterFilesTests) [None]
--
Traceback (most recent call last):
  File 
"/build/python/src/Python-3.9.0/Lib/test/test_tools/test_c_analyzer/test_common/test_files.py",
 line 209, in test_no_suffix
self.assertEqual(self.calls, [
AssertionError: Lists differ: [('_walk', ('spam', None, ))] != [('_walk', ('spam', None, ))]

First differing element 0:
('_walk', ('spam', None, ))
('_walk', ('spam', None, ))

- [('_walk', ('spam', None, ))]
? ^

+ [('_walk', ('spam', None, ))]
? ++   + 


==
FAIL: test_no_suffix 
(test.test_tools.test_c_analyzer.test_common.test_files.IterFilesTests) []
--
Traceback (most recent call last):
  File 
"/build/python/src/Python-3.9.0/Lib/test/test_tools/test_c_analyzer/test_common/test_files.py",
 line 209, in test_no_suffix
self.assertEqual(self.calls, [
AssertionError: Lists differ: [('_walk', ('spam', '', ))] != [('_walk', ('spam', '', ))]

First differing element 0:
('_walk', ('spam', '', ))
('_walk', ('spam', '', ))

- [('_walk', ('spam', '', ))]
?   ^

+ [('_walk', ('spam', '', ))]
?   ++   + 


==
FAIL: test_no_suffix 
(test.test_tools.test_c_analyzer.test_common.test_files.IterFilesTests) [()]
--
Traceback (most recent call last):
  File 
"/build/python/src/Python-3.9.0/Lib/test/test_tools/test_c_analyzer/test_common/test_files.py",
 line 209, in test_no_suffix
self.assertEqual(self.calls, [
AssertionError: Lists differ: [('_walk', ('spam', (), ))] != [('_walk', ('spam', (), ))]

First differing element 0:
('_walk'

[issue41970] test_lib2to3 fails since Python 3.9

2020-10-08 Thread Felix Yan


Felix Yan  added the comment:

I use this in Arch's packaging:

LC_CTYPE=en_US.UTF-8 xvfb-run -s "-screen 0 1920x1080x16 -ac +extension GLX" -a 
-n "$servernum" \
"${srcdir}/Python-${pkgver}/python" -m test.regrtest -v -uall -x test_tk

(test_tk is currently skipped due to https://bugs.python.org/issue41306)

--

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



[issue42204] "import setuptools" Results in "ModuleNotFoundError: No module named '_distutils_hack'"

2020-10-30 Thread Steven Yan


Change by Steven Yan :


--
components: Distutils
files: pic.png
nosy: dstufft, eric.araujo, sy
priority: normal
severity: normal
status: open
title: "import setuptools" Results in "ModuleNotFoundError: No module named 
'_distutils_hack'"
type: behavior
versions: Python 3.9
Added file: https://bugs.python.org/file49550/pic.png

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



[issue42204] "import setuptools" Results in "ModuleNotFoundError: No module named '_distutils_hack'"

2020-10-30 Thread Steven Yan


Change by Steven Yan :


Added file: https://bugs.python.org/file49551/pic.png

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



[issue42204] "import setuptools" Results in "ModuleNotFoundError: No module named '_distutils_hack'"

2020-10-30 Thread Steven Yan


Change by Steven Yan :


Removed file: https://bugs.python.org/file49550/pic.png

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



[issue42301] Lack function to track index of an element in heapq

2020-11-09 Thread Sam Yan


New submission from Sam Yan :

Github PR #23204:
For a given element in a heap, we can leverage the fact that we can
search this element quicker thinking of the property of a heap. Therefore
out of h.index(x) that a list linear search uses, I propose to use a special 
written index method to look for an index of a heap element.This issue has been 
proposed on Github (with my changes to heapq also put there). Open a discussion 
under suggestion of Karthikeyan Singaravelan (tirkarthi).

--
components: Extension Modules
hgrepos: 393
messages: 380628
nosy: SamUnimelb
priority: normal
pull_requests: 22110
severity: normal
status: open
title: Lack function to track index of an element in heapq
type: behavior
versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9

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



[issue33835] Too strong side effect?

2018-06-11 Thread X. Yan


New submission from X. Yan :

I am familiar with quite a few languages such as C++, C, PASCAL, Matlab, etc., 
but starting to practice Python. When I tested the code:

def f(a, L=[]):
L.append(a)
return L

followed by calls as follows,

v1 = f(1)
v2 = f(2)

, to my surprise, I saw the v1's content was changed from initial [1] to [1, 
2], when the second call, v2=f(2), was executed. This means when you produce 
the new value for v2, you have to be very very careful for all the results 
produced by this function previously, such as what in the v1. They can be 
changed in the background! I wonder if this side-effect was designed on 
purpose, or is actually a BUG, because it is too dangerous.

--
messages: 319308
nosy: xgyan
priority: normal
severity: normal
status: open
title: Too strong side effect?
type: behavior
versions: Python 3.6

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



[issue33835] Too strong side effect?

2018-06-11 Thread X. Yan


X. Yan  added the comment:

Hi Serhiy,

Thanks for your reply. However, the issue I reported was not about sharing the 
default value. I understand that the parameter L would keep its value [1] from 
function f's first run, and used it in the second run to get [1, 2].

My point is that the variable v1 only got involved in f's first run. It should 
keep the result [1] since then. The second calling v2=f(2) is irrelevant to v1, 
therefore, v1's content shouldn't be changed. v1 should be independent from f's 
later activities. Please let me know if this makes sense.

--
status: closed -> open

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



[issue33835] Too strong side effect?

2018-06-11 Thread X. Yan


X. Yan  added the comment:

I see.

Thanks for the detailed explanations.

Best,

Xiaogang

On 6/11/2018 2:00 PM, Steven D'Aprano wrote:
> Steven D'Aprano  added the comment:
>
> Both names "v1" and "v2" refer to the same object. Python does not make 
> copies of objects on assignment, so if you write:
>
> a = []
> b = a
>
> then a and b both refer to the same list object, and the names "a" and "b" 
> are effectively aliases. This is standard object-sharing behaviour used by 
> many languages, including Lisp, Ruby, Javascript and Java.
>
> If you are familiar with languages like Pascal and C++ you are probably 
> thinking that variables are boxes at fixed memory locations, and assignment 
> copies values into that box. That is not a good model for Python (and others).
>
> This is not a bug. If you are unfamiliar with this object model, it can seem 
> a bit strange at first, but for people who are used to Python, the C and 
> Pascal model seems strange too.
>
> Some people call this distinction Values Types (like Pascal and C) versus 
> Reference Types (like Python, Ruby, Javascript)
>
> https://softwareengineering.stackexchange.com/questions/314808/why-variables-in-python-are-different-from-other-programming-languages
>
> --
> nosy: +steven.daprano
>
> ___
> Python tracker 
> <https://bugs.python.org/issue33835>
> ___
>

--

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



[issue21638] Seeking to EOF is too inefficient!

2014-06-02 Thread Linlin Yan

New submission from Linlin Yan:

I noticed this problem when I run a Python2 program (MACS: 
http://liulab.dfci.harvard.edu/MACS/) very inefficiently on a large storage on 
a high performace server (64-bit Linux). It was much slower (more than two 
days) than running it on a normal PC (less than two hours).

After ruling out many optimizing conditions, I finally located the problem on 
the seek() function of Python2. Now I can reproduce the problem in a very 
simple example:

#!/usr/bin/python2
f = open("Input.sort.bam", "rb")
f.seek(0, 2)
f.close()

Here, the size of file 'Input.sort.bam' is 4,110,535,920 bytes. When I run the 
program with 'strace' to see the system calls on Linux:

$ strace python2 foo.py
...
open("Input.sort.bam", O_RDONLY)= 3
fstat(3, {st_mode=S_IFREG|0644, st_size=4110535920, ...}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=4110535920, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0x7f23d4492000
fstat(3, {st_mode=S_IFREG|0644, st_size=4110535920, ...}) = 0
lseek(3, 4110532608, SEEK_SET)  = 4110532608
read(3, 
"f\203\337<\334\350\313\315\345&T\227\211\fC\212a\260\204P\235\366\326\353\230\327>\373\361\221\357\373"...,
 3312) = 3312
close(3)= 0
...

It seems that python2 just move file cursor to a specific position (4110532608 
in this case) and read ahead the rest bytes, rather than seek to the file end 
directly. I tried to run the exact the same program on the large storage, the 
position changed to 1073741824, left 889310448 bytes to read to reach the file 
end, which reduced the performance a lot!

--
components: IO
messages: 219586
nosy: yanlinlin82
priority: normal
severity: normal
status: open
title: Seeking to EOF is too inefficient!
type: performance
versions: Python 2.7

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



[issue21638] Seeking to EOF is too inefficient!

2014-06-02 Thread Linlin Yan

Linlin Yan added the comment:

I agree that Python 2 should use fopen / fread rather than directly read().
But you may misunderstand this. The 'strace' tool reports Linux system
calls, including read() rather than fread(), and I guess that read() should
be finally called in fread() implementation.

What I mean is that Python 2's seek(0, 2) does not use fseek(0, SEEK_END),
but fseek(somewhere, SEEK_SET) and fread(rest-bytes) instead, which is too
inefficient in some kind of storage.

By the way, Python 3 does not behavior like this.

On Tue, Jun 3, 2014 at 4:35 AM, STINNER Victor 
wrote:

>
> STINNER Victor added the comment:
>
> I don't think that Python calls directly read(). Python 2 uses fopen /
> fread.
>
> Python 3 doesn't use buffered files, but call open / read directly.
>
> --
> nosy: +haypo, neologix
>
> ___
> Python tracker 
> <http://bugs.python.org/issue21638>
> ___
>

--

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



[issue21638] Seeking to EOF is too inefficient!

2014-06-03 Thread Linlin Yan

Linlin Yan added the comment:

Thanks! I agree with that.

--

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



[issue21638] Seeking to EOF is too inefficient!

2014-06-03 Thread Linlin Yan

Linlin Yan added the comment:

I ensured that the problem is in libc. I will try to figure out it by updating 
libc or optimizing some related parameters.

--
resolution:  -> third party
status: open -> closed

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



[issue27650] Implement `__repr__` methods for logging.Logger and others

2016-12-27 Thread Felix Yan

Changes by Felix Yan :


--
nosy: +felixonmars

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



[issue24950] FAIL: test_expanduser when $HOME=/

2015-08-27 Thread Felix Yan

New submission from Felix Yan:

test_expanduser in test.test_posixpath.PosixPathTest fails when the users $HOME 
being exactly "/", after the patch in issue17809 was introduced.

test test_posixpath failed -- Traceback (most recent call last):
  File "/build/python/src/Python-3.5.0rc2/Lib/test/test_posixpath.py", line 
249, in test_expanduser
self.assertEqual(posixpath.expanduser("~"), home.rstrip("/"))
AssertionError: '/' != ''
- /
+

Would it be appropriate to apply the rstrip() also to the left part of the 
equation?

--
components: Tests
messages: 249273
nosy: felixonmars
priority: normal
severity: normal
status: open
title: FAIL: test_expanduser when $HOME=/
type: behavior
versions: Python 3.3, Python 3.4, Python 3.5

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



[issue24950] FAIL: test_posixpath when $HOME=/

2015-08-27 Thread Felix Yan

Changes by Felix Yan :


--
title: FAIL: test_expanduser when $HOME=/ -> FAIL: test_posixpath when $HOME=/

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



[issue24950] FAIL: test_expanduser when $HOME=/

2015-08-27 Thread Felix Yan

Changes by Felix Yan :


--
title: FAIL: test_posixpath when $HOME=/ -> FAIL: test_expanduser when $HOME=/

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



[issue24950] FAIL: test_expanduser when $HOME=/

2015-08-27 Thread Felix Yan

Felix Yan added the comment:

btw, there seems to be a relevant failure in test_pathlib as well:

test test_pathlib failed -- Traceback (most recent call last):
  File "/build/python/src/Python-3.5.0rc2/Lib/test/test_pathlib.py", line 2015, 
in test_expanduser
self.assertEqual(p1.expanduser(), P(userhome) / 'Documents')
AssertionError: PosixPath('/Documents') != PosixPath('Documents')

(not sure if they are really relevant, though)

--

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



[issue25096] test_gdb failed to read version for gdb >= 7.10

2015-09-13 Thread Felix Yan

New submission from Felix Yan:

The regex in test_gdb reads only one digit of gdb's minor version, which would 
fail for gdb >= 7.10, and skip the test as 7.1 < 7.4.

Original commit: https://hg.python.org/cpython/rev/b71cda2f48c6#l1.9

Patch attached.

--
components: Tests
files: test_gdb-version-fix.patch
keywords: patch
messages: 250608
nosy: felixonmars
priority: normal
severity: normal
status: open
title: test_gdb failed to read version for gdb >= 7.10
type: behavior
versions: Python 3.4, Python 3.5
Added file: http://bugs.python.org/file40453/test_gdb-version-fix.patch

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



[issue25195] mock.ANY doesn't match mock.MagicMock() object

2015-09-20 Thread Felix Yan

Changes by Felix Yan :


--
type:  -> behavior

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



[issue25195] mock.ANY doesn't match mock.MagicMock() object

2015-09-20 Thread Felix Yan

New submission from Felix Yan:

Since Python 3.5.0 mock.MagicMock() object seems not matched by mock.ANY. This 
behavior looks weird and breaks tests of boto.

Minimized example:

In Python 3.4.3:
>>> from unittest import mock
>>> m = mock.MagicMock()
>>> m(mock.MagicMock())

>>> m.assert_called_with(mock.ANY)
>>>

In Python 3.5.0:
>>> from unittest import mock
>>> m = mock.MagicMock()
>>> m(mock.MagicMock())

>>> m.assert_called_with(mock.ANY)
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.5/unittest/mock.py", line 792, in assert_called_with
raise AssertionError(_error_message()) from cause
AssertionError: Expected call: mock()
Actual call: mock()

--
components: Library (Lib)
messages: 251162
nosy: felixonmars
priority: normal
severity: normal
status: open
title: mock.ANY doesn't match mock.MagicMock() object
versions: Python 3.5

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



[issue38296] unittest expectedFailure does not differentiate errors from failures

2019-09-27 Thread Kit Yan Choi


Kit Yan Choi  added the comment:

For your test:

class T(unittest.TestCase):
def test_f(self): raise TypeError()

If you run this test with unittest test runner, you should get this result:

E
==
ERROR: test_f (test_main.T)
--
Traceback (most recent call last):
  File "test_main.py", line 5, in test_f
def test_f(self): raise TypeError()
TypeError

--
Ran 1 test in 0.000s

FAILED (errors=1)


I expect to get this behaviour even if the test is decorated with 
unittest.expectedFailure. However, currently we get a success.


Scenario:


You create a class named Duck with a method "quack".  Then you added a test, 
and test needs to call Duck.quack.

Later on for whatever reason, you need to decorate the test with 
expectedFailure.  The test passes with the expected failure.

Then you rename the "quack" method to "walk", but you forget to update the 
test.  Now the test is actually failing with an AttributeError, but you won't 
notice it because expectedFailure silences it.

In this scenario, it is important to differentiate a "test error" and a "test 
failure". A test has four status: success, failure, error, skipped.  I expect 
unittest.expectedFailure to make "failure" a "success" and a "success" a 
"failure", and it should leave "error" and "skipped" unchanged.

Please consider reopening this issue.

--
nosy: +Kit Yan Choi

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



[issue38296] unittest expectedFailure does not differentiate errors from failures

2019-09-27 Thread Kit Yan Choi


Change by Kit Yan Choi :


--
nosy:  -Kit Choi

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



[issue38296] unittest expectedFailure does not differentiate errors from failures

2019-09-28 Thread Kit Yan Choi


Kit Yan Choi  added the comment:

Pining Chris based on previous discussion in issue16997 ... Hope that's okay.

I notice that the language in my initial message also conflates error and 
failure. My apologies on the carelessness.

Just to clarify:


@unittest.expectedFailure
def test(self):
THIS_VARIABLE_IS_UNDEFINED  # ---> NameError


should give: ERROR (errors=1)
currently gives: OK (expected failures=1)


By fixing this, we can help projects to maintain their tests decorated with 
expectedFailure so that the tests remaining to be meaningful.

--
nosy: +chris.jerdonek

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



[issue38296] unittest expectedFailure does not differentiate errors from failures

2019-09-28 Thread Kit Yan Choi


Kit Yan Choi  added the comment:

I think Python does differentiate "test error" and "test failure" such that a 
test outcome state can be one of these: success, failure, error, skipped. One 
could refine these to six: expected success, unexpected success, expected 
failure, unexpected failure, error, skipped.


For example, in the documentation for failureException:

* failureException: determines which exception will be raised when
the instance's assertion methods fail; test methods raising this
exception will be deemed to have 'failed' rather than 'errored'.


Another evidence: unittest.runner.TextTestResult, there are methods called 
"addSuccess", "addError", "addFailure", "addSkip", "addExpectedFailure" and 
"addUnexpectedSuccess".


For example, this test outcome is marked as "FAILED":

def test(self):
x = 1
y = 2
self.assertEqual(x + y, 4)


==
FAIL: test (test_main.T)
--
Traceback (most recent call last):
  File "test_main.py", line 9, in test
self.assertEqual(x + y, 4)
AssertionError: 3 != 4


But the test outcome for this test is "ERROR":

def test(self):
x = 1
y = 2 + z  # NameError  
self.assertEqual(x + y, 4)


==
ERROR: test (test_main.T)
--
Traceback (most recent call last):
  File "test_main.py", line 8, in test
y = 2 + z  # NameError
NameError: global name 'z' is not defined


The issue here being "expectedFailure" converting "error" to "success", which 
is not expected, and is causing decorated tests to become unmaintained. While 
the rest of unittest differentiates "error" and "failure", expectedFailure does 
not. This is either a bug in the behaviour of expectedFailure, or a bug in the 
documentation for not being clear on the fact that unexpected error will be 
considered as expected failure (which I think is wrong).

--

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



[issue39385] Add an assertNoLogs context manager to unittest TestCase

2020-01-18 Thread Kit Yan Choi


New submission from Kit Yan Choi :

assertLogs is really useful (issue18937). Unfortunately it does not cover the 
use cases where one wants to ensure no logs are emitted.

Similar to assertLogs, we can have a context manager for asserting no logs, 
something like this?:

with assertNoLogs(logger, level):
...


If logs are unexpected found, the test would fail with the logs captured 
included in the error message.

Happy to submit a PR if there is interest.

--
components: Library (Lib)
messages: 360250
nosy: Kit Yan Choi
priority: normal
severity: normal
status: open
title: Add an assertNoLogs context manager to unittest TestCase
type: enhancement

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



[issue39385] Add an assertNoLogs context manager to unittest TestCase

2020-01-19 Thread Kit Yan Choi


Change by Kit Yan Choi :


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

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



[issue39385] Add an assertNoLogs context manager to unittest TestCase

2020-04-23 Thread Kit Yan Choi


Kit Yan Choi  added the comment:

Thank you for looking into this.
Yes, I agree it makes sense to have assertNoWarns for the same reason.

--

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



[issue30724] ZipFile.open treats directory path as empty file

2017-06-21 Thread Kit Yan Choi

New submission from Kit Yan Choi:

Given a zipfile with the following content:

subdir/
file1.txt
subdir/file2.txt

>>> archive = ZipFile(file_path, "r")
>>> f = archive.open("subdir/", "r")
>>>f.read()
b''

It is quite odd that the subdirectory can be opened as if it was an empty file. 
 One would expect it to raise.

One use case is that the archive is created using shutil.make_archive, which 
includes the subdirectory paths in the namelist.  Upon looping 
ZipFile.namelist(), you end up opening a subdirectory and getting the empty 
content, which should have led to error and prompted the developers to filter 
the namelist first.

--
messages: 296564
nosy: Kit Yan Choi
priority: normal
severity: normal
status: open
title: ZipFile.open treats directory path as empty file
type: behavior
versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5

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